How to use the lbuild.node.BaseNode.Type 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
node = node[0]
        if not node._available:
            if not raise_on_fail: return None;
            raise le.LbuildResolverSearchException(self, node, "is not available!")

        if self._selected and not node._selected:
            if not raise_on_fail: return None;
            raise le.LbuildResolverSearchException(self, node, "is not selected!")

        if node._type != self._type:
            if not raise_on_fail: return None;
            raise le.LbuildResolverSearchException(self, node,
                    "is of type '{}', but searching for '{}'!".format(
                            node._type.name.lower(), self._type.name.lower()))

        if check_dependencies and node.type in {BaseNode.Type.OPTION, BaseNode.Type.QUERY, BaseNode.Type.COLLECTOR}:
            if node.parent != self._node:
                if all(n.type not in {BaseNode.Type.PARSER, BaseNode.Type.REPOSITORY} for n in {self._node, node.module}):
                    if node.parent not in self._node.dependencies:
                        if self._selected or node.type not in {BaseNode.Type.COLLECTOR}:
                            LOGGER.warning("Module '{}' accessing '{}' without depending on '{}'!"
                                           .format(self._node.fullname, node.fullname, node.module.fullname))

        return node
github modm-io / lbuild / lbuild / node.py View on Github external
if not raise_on_fail: return None;
            raise le.LbuildResolverSearchException(self, node, "is not available!")

        if self._selected and not node._selected:
            if not raise_on_fail: return None;
            raise le.LbuildResolverSearchException(self, node, "is not selected!")

        if node._type != self._type:
            if not raise_on_fail: return None;
            raise le.LbuildResolverSearchException(self, node,
                    "is of type '{}', but searching for '{}'!".format(
                            node._type.name.lower(), self._type.name.lower()))

        if check_dependencies and node.type in {BaseNode.Type.OPTION, BaseNode.Type.QUERY, BaseNode.Type.COLLECTOR}:
            if node.parent != self._node:
                if all(n.type not in {BaseNode.Type.PARSER, BaseNode.Type.REPOSITORY} for n in {self._node, node.module}):
                    if node.parent not in self._node.dependencies:
                        if self._selected or node.type not in {BaseNode.Type.COLLECTOR}:
                            LOGGER.warning("Module '{}' accessing '{}' without depending on '{}'!"
                                           .format(self._node.fullname, node.fullname, node.module.fullname))

        return node
github modm-io / lbuild / lbuild / parser.py View on Github external
def repositories(self):
        return {r.fullname:r for r in self._findall(BaseNode.Type.REPOSITORY)}
github modm-io / lbuild / lbuild / node.py View on Github external
# 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 / main.py View on Github external
def perform(args, builder):
        builder._filter_modules()
        if args.show_developer_view:
            lbuild.format.SHOW_NODES.update(lbuild.node.BaseNode.Type)
        names = args.names + args.names_explicit
        if names:
            ostream = []
            for node in builder.parser.find_all(names):
                if args.show_subtree:
                    ostream.append(node.render())
                else:
                    if args.values and node.type == node.Type.OPTION:
                        ostream.extend(node.values)
                    else:
                        ostream.append(node.description)
            if not args.values:
                return "\n\n\n\n".join(ostream)
            return "\n".join(ostream)

        return builder.parser.render()
github modm-io / lbuild / lbuild / format.py View on Github external
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))