How to use the lbuild.exception 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 / option.py View on Github external
def __set_value(self, value):
        try:
            self._input = self._in(value)
            self._output = self._out(value)
        except (TypeError, ValueError) as error:
            raise le.LbuildOptionInputException(self, value, error)
github modm-io / lbuild / lbuild / node.py View on Github external
'CallableCollector': lbuild.collector.CallableCollector,

        'StringOption': lbuild.option.StringOption,
        'PathOption': lbuild.option.PathOption,
        'BooleanOption': lbuild.option.BooleanOption,
        'NumericOption': lbuild.option.NumericOption,
        'EnumerationOption': lbuild.option.EnumerationOption,
        'SetOption': lbuild.option.SetOption,
    })

    try:
        local = lu.load_module_from_file(filename, local)
        functions = lu.get_global_functions(local, required, optional)
        return functions

    except le.LbuildUtilsFunctionNotFoundException as error:
        raise le.LbuildNodeMissingFunctionException(repository, filename, error)
github modm-io / lbuild / lbuild / utils.py View on Github external
def get(name, fail=True):
        if isinstance(env, dict):
            val = env.get(name, None)
        else:
            val = getattr(env, name, None)
        if fail and val is None:
            raise le.LbuildUtilsFunctionNotFoundException(name, required, optional)
        return val
github modm-io / lbuild / lbuild / parser.py View on Github external
def merge_module_options(self):
        # only deal with repo options that contain one `:`
        resolver = self.option_resolver
        for name, (value, filename) in filter(lambda i: i[0].count(":") > 1,
                                              self.config.options.items()):
            try:
                option = resolver[name]
                option._filename = filename
                option.value = value
            except le.LbuildOptionException as error:
                raise le.LbuildParserOptionInvalidException(self, error, filename)
            except le.LbuildResolverNoMatchException as error:
                raise le.LbuildParserNodeNotFoundException(self, name, self.Type.OPTION, filename)
github modm-io / lbuild / lbuild / parser.py View on Github external
# Enforce that the submodules are always build before their parent modules
            for group in (groups[index] for index in sorted(groups)):
                for modules in (group[index] for index in sorted(group, reverse=True)):
                    random.shuffle(modules)
                    for module in modules:
                        yield module

        # Merge config collectors values
        resolver = self.collector_available_resolver
        for (name, value, filename) in self.config.collectors:
            try:
                collector = resolver[name]
                collector.add_values(value, collector.repository.fullname, filename=filename)
            except le.LbuildOptionException as error:
                raise le.LbuildParserOptionInvalidException(self, error, filename)
            except le.LbuildResolverNoMatchException as error:
                raise le.LbuildParserNodeNotFoundException(self, name, self.Type.COLLECTOR, filename)

        exceptions = []
        for runner in walk_modules():
            try:
                runner.validate()
            except le.LbuildException as error:
                exceptions.append(error)

        if exceptions:
            raise le.LbuildAggregateException(exceptions)

        # Cannot build without a buildlog
        if buildlog is None:
            return
        lbuild.environment.SIMULATE = simulate
github modm-io / lbuild / lbuild / repository.py View on Github external
nname = "{}.{}".format(self.name, name)
                LOGGER.warning("Namespacing repository filter '{}' to '{}'!"
                               .format(name, nname))
                name = nname
            self._filters[name] = func

        try:
            for child in (repo._options + repo._queries):
                self.add_child(child)
            for (name, path, description) in repo._configurations:
                path = self._relocate_relative_path(path)
                if not os.path.isfile(path):
                    raise le.LbuildConfigAddNotFoundException(repo, path)
                self.add_child(Configuration(name, path, description))

        except le.LbuildNodeDuplicateChildException as error:
            raise le.LbuildRepositoryDuplicateChildException(repo._parser, repo, error)

        # List of module filenames which are later transfered into
        # module objects
        self._module_files = []
        # List of programatically added modules
        self._submodules = []
github modm-io / lbuild / lbuild / node.py View on Github external
'StringOption': lbuild.option.StringOption,
        'PathOption': lbuild.option.PathOption,
        'BooleanOption': lbuild.option.BooleanOption,
        'NumericOption': lbuild.option.NumericOption,
        'EnumerationOption': lbuild.option.EnumerationOption,
        'SetOption': lbuild.option.SetOption,
    })

    try:
        local = lu.load_module_from_file(filename, local)
        functions = lu.get_global_functions(local, required, optional)
        return functions

    except le.LbuildUtilsFunctionNotFoundException as error:
        raise le.LbuildNodeMissingFunctionException(repository, filename, error)
github modm-io / lbuild / lbuild / node.py View on Github external
def _resolve_partial_max(self, query, max_results=1, raise_on_fail=True):
        nodes = self._resolve_partial(query, None)
        if nodes is None:
            if not raise_on_fail: return None;
            raise le.LbuildResolverNoMatchException(self, query)
        if len(nodes) > max_results:
            if not raise_on_fail: return None;
            raise le.LbuildResolverAmbiguousMatchException(self, query, nodes)
        return nodes