How to use the lbuild.format 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 / node.py View on Github external
self._fullname = name
        self._filename = None

        # Dependency management
        self._repository = repository
        self._dependency_module_names = []
        self._dependencies_resolved = False
        self._dependencies = []

        self._build_order = 0
        self._description = ""
        # All _update()-able traits: defaults
        self._available_default = True
        self._selected_default = True
        self._format_description_default = lbuild.format.format_description
        self._format_short_description_default = lbuild.format.format_short_description

        # All _update()-able traits: defaults
        self._available = (self._type != BaseNode.Type.MODULE)
        self._selected = True
        self._format_description = self._format_description_default
        self._format_short_description = self._format_short_description_default
        self._ignore_patterns = lbuild.utils.DEFAULT_IGNORE_PATTERNS
        self._filters = lbuild.filter.DEFAULT_FILTERS
github modm-io / lbuild / lbuild / exception.py View on Github external
def __init__(self, parent, child, conflict):
        prompt = ("{}({}) conflicts with existing {} for parent '{}'!\n"
                  .format(_hl(child.class_name), _hl(child.fullname),
                          _hl(conflict.class_name), _hl(parent.fullname)))
        hint = ("Hint: This {}{}:\n\n"
                "    >>> {}\n\n"
                "conflicts with this {}{}:\n\n"
                "    >>> {}\n"
                .format(_hl(child.class_name), "" if child._filename is None else
                            " defined in '{}'".format(_hl(_rel(child._filename))),
                        lbuild.format.format_node(child, 0, 0),
                        _hl(conflict.class_name), "" if conflict._filename is None else
                            " defined in '{}'".format(_hl(_rel(conflict._filename))),
                        lbuild.format.format_node(conflict, 0, 0)))
        super().__init__(prompt + hint, parent._repository)
        self.prompt = prompt
        self.hint = hint
        self.parent = parent
        self.child = child
        self.conflict = conflict
github modm-io / lbuild / lbuild / repository.py View on Github external
def __init__(self, parser, filename):
        self._filename = os.path.realpath(filename)
        self._filepath = os.path.dirname(self._filename) if filename else None
        self._functions = {}
        self._parser = parser

        self.name = None
        self.description = ""
        self._format_description = lbuild.format.format_description
        self._format_short_description = lbuild.format.format_short_description

        self._submodules = []
        self._options = []
        self._filters = []
        self._queries = []
        self._ignore_patterns = []
        self._configurations = []
github modm-io / lbuild / lbuild / main.py View on Github external
def run(args):
    lbuild.logger.configure_logger(args.verbose)
    lbuild.facade.VERBOSE_DEPRECATION = args.verbose
    lbuild.format.PLAIN = args.plain

    try:
        command = args.execute_action
    except AttributeError:
        raise lbuild.exception.LbuildArgumentException("No command specified!")

    builder = Builder(config=args.config, options=args.options, collectors=args.collectors)
    return command(args, builder)
github modm-io / lbuild / lbuild / node.py View on Github external
def render(self, filterfunc=None):
        return lbuild.format.format_node_tree(self, filterfunc)
github modm-io / lbuild / lbuild / exception.py View on Github external
def _hl(name, plain = False):
    if plain: return str(name);
    return str(lbuild.format._cw(str(name)).wrap("bold"))
github modm-io / lbuild / lbuild / module.py View on Github external
def __init__(self, repository, filename, parent=None):
        self.filename = os.path.realpath(filename)
        self.filepath = os.path.dirname(self.filename) if filename else None
        self.repository = repository

        self.name = None
        self.parent = None
        self.context_parent = parent
        self.description = ""
        self.functions = {}
        self.available = False
        self.order = 0
        self._format_description = lbuild.format.format_description
        self._format_short_description = lbuild.format.format_short_description

        self._submodules = []
        self._options = []
        self._dependencies = []
        self._filters = []
        self._queries = []
        self._collectors = []
github modm-io / lbuild / lbuild / main.py View on Github external
def perform(args, builder):
        nodes = builder.parser.find_any(["*", ":**"])
        nodes.sort(key=lambda n: n.fullname)
        show_nodes = lbuild.format.SHOW_NODES
        plain = lbuild.format.PLAIN

        search = "|".join(args.queries)
        fnodes = []
        ostream = ""
        lbuild.format.PLAIN = True

        for node in nodes:
            lbuild.format.SHOW_NODES = {node.type}
            description = node.description.splitlines()
            olines = []

            for line, descr in enumerate(description):
                if re.search(search, descr, flags=re.I):
                    olines.append("{:>3}  ".format(line-1) + descr)

            if olines:
                fnodes.append(node)
                ostream += "\n\n\n" + description[0]
                if olines[0].startswith(" -1  >> "):
                    olines = olines[1:]
                if olines:
                    ostream += "\n\n" + "\n".join(olines)

        tnodes = {a  for n in fnodes  for a in n.ancestors} | set(fnodes)
github modm-io / lbuild / lbuild / repository.py View on Github external
def __init__(self, parser, filename):
        self._filename = os.path.realpath(filename)
        self._filepath = os.path.dirname(self._filename) if filename else None
        self._functions = {}
        self._parser = parser

        self.name = None
        self.description = ""
        self._format_description = lbuild.format.format_description
        self._format_short_description = lbuild.format.format_short_description

        self._submodules = []
        self._options = []
        self._filters = []
        self._queries = []
        self._ignore_patterns = []
        self._configurations = []
github modm-io / lbuild / lbuild / module.py View on Github external
def __init__(self, repository, filename, parent=None):
        self.filename = os.path.realpath(filename)
        self.filepath = os.path.dirname(self.filename) if filename else None
        self.repository = repository

        self.name = None
        self.parent = None
        self.context_parent = parent
        self.description = ""
        self.functions = {}
        self.available = False
        self.order = 0
        self._format_description = lbuild.format.format_description
        self._format_short_description = lbuild.format.format_short_description

        self._submodules = []
        self._options = []
        self._dependencies = []
        self._filters = []
        self._queries = []
        self._collectors = []