How to use the lbuild.format.ColorWrapper function in lbuild

To help you get started, we’ve selected a few lbuild examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github modm-io / lbuild / lbuild / format.py View on Github external
if node._type == node.Type.REPOSITORY:
        name = _cw(node.name + " @ " + os.path.relpath(node._filepath))
    elif node._type == node.Type.OPTION:
        name = format_option_name(node, fullname=False)
    elif node._type in {node.Type.MODULE, node.Type.CONFIG}:
        name = _cw(node.fullname).wrap(node)
    elif node._type in {node.Type.QUERY, node.Type.COLLECTOR}:
        name = name.wrap("bold")
    if node._type in {node.Type.MODULE} and node._selected:
        name = name.wrap("underlined")

    descr = (class_name + _cw("(") + name + _cw(")")).wrap(node)

    offset = (node.depth - depth) * 4
    if node._type == node.Type.OPTION:
        descr += _cw(" = ")
        descr += format_option_value_description(node, offset=offset + len(descr), single_line=True)
    elif node._type == node.Type.COLLECTOR:
        descr += _cw(" in [")
        descr += format_option_values(node, offset=offset + len(descr), single_line=True)
        descr += _cw("]")

    descr += _cw("   " + node.short_description)

    return descr.limit(offset)
github modm-io / lbuild / lbuild / format.py View on Github external
if node._type == node.Type.QUERY:
        class_name = class_name.wrap("underlined")

    name = _cw(node.name)
    if node._type == node.Type.REPOSITORY:
        name = _cw(node.name + " @ " + os.path.relpath(node._filepath))
    elif node._type == node.Type.OPTION:
        name = format_option_name(node, fullname=False)
    elif node._type in {node.Type.MODULE, node.Type.CONFIG}:
        name = _cw(node.fullname).wrap(node)
    elif node._type in {node.Type.QUERY, node.Type.COLLECTOR}:
        name = name.wrap("bold")
    if node._type in {node.Type.MODULE} and node._selected:
        name = name.wrap("underlined")

    descr = (class_name + _cw("(") + name + _cw(")")).wrap(node)

    offset = (node.depth - depth) * 4
    if node._type == node.Type.OPTION:
        descr += _cw(" = ")
        descr += format_option_value_description(node, offset=offset + len(descr), single_line=True)
    elif node._type == node.Type.COLLECTOR:
        descr += _cw(" in [")
        descr += format_option_values(node, offset=offset + len(descr), single_line=True)
        descr += _cw("]")

    descr += _cw("   " + node.short_description)

    return descr.limit(offset)
github modm-io / lbuild / lbuild / format.py View on Github external
def __add__(self, other):
        color = ColorWrapper()
        if isinstance(other, ColorWrapper):
            color._content = self._content + other._content
            color._string = self._string + other._string
        else:
            color._content = self._content
            color._string = other
        return color
github modm-io / lbuild / lbuild / option.py View on Github external
def format_values(self):
        if self._default:
            return _cw("True").wrap("underlined") + _cw(", False")
        return _cw("True, ") + _cw("False").wrap("underlined")
github modm-io / lbuild / lbuild / format.py View on Github external
def format_description(node, description):
    type_description = "  [{}]".format(node.class_name)
    output = [_cw(">> ") + _cw(node.description_name).wrap(node).wrap("bold") + _cw(type_description)]
    if description:
        description = description.strip()
        if len(description):
            output += [_cw(""), _cw(description)]

    if node.type == node.Type.OPTION:
        value = format_option_value(node, single_line=False)[0]
        values = format_option_values(node, offset=9, single_line=False)
        output += [_cw(""), _cw("Value: ") + value, _cw("Inputs: [") + values + _cw("]")]
    elif node.type == node.Type.COLLECTOR:
        values = format_option_values(node, offset=9, single_line=False)
        output += [_cw(""), _cw("Inputs: [") + values + _cw("]")]

    children = []
    # Print every node except the submodule, due to obvious recursion
    for ntype in (SHOW_NODES - {lbuild.node.BaseNode.Type.MODULE}):
        children += node._findall(ntype, depth=2)

    for child in sorted(children, key=lambda c: (c.type, c.name)):
        output.extend([_cw("\n"), _cw(">>") + _cw(child.description)])

    return "\n".join(map(str, output))
github modm-io / lbuild / lbuild / format.py View on Github external
def format_option_value_description(node, offset=0, single_line=None):
    value = format_option_value(node, bool(single_line))
    offset = offset + len(value[0]) if value[1] < 0 else value[1]
    single_line = value[2] if single_line is None else single_line
    values = format_option_values(node, offset + 5, single_line)
    return value[0] + _cw(" in [") + values + _cw("]")