How to use the lbuild.exception.LbuildConfigException 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 / exception.py View on Github external
"Hint: Check your config paths in '{}':\n\n"
            "   def init(repo):\n"
            "       repo.add_configuration(name, \"{}\", description)"
            .format(_call_site(repo._functions['init']),
                    _hl(_rel(repo._filename)), _hl(filename)))
        super().__init__(filename, message)
        self.node = repo

class LbuildConfigAliasNotFoundException(LbuildConfigException):
    def __init__(self, parser, alias):
        message = (": alias '{}' not found in any repository!"
                   .format(_hl(alias)) + _dump(parser))
        filename = next( (f for f, a in parser._config_flat._extends.items() if alias in a), None)
        super().__init__(filename, message)

class LbuildConfigAliasAmbiguousException(LbuildConfigException):
    def __init__(self, parser, alias, matches):
        aliases = _bp(sorted(c.fullname for c in matches))
        message = (": alias '{}' is ambiguous!\n"
                   "Hint: Found multiple matches:\n\n{}"
                   .format(_hl(alias), aliases) + _dump(parser))
        filename = next( (f for f, a in parser._config_flat._extends.items() if alias in a), None)
        super().__init__(filename, message)


# ============================= OPTION EXCEPTIONS =============================
class LbuildOptionException(LbuildException):
    def __init__(self, message, option):
        msg = ("{}({}){}\n{}\n"
               .format(option.class_name, _hl(_rel(option.fullname)),
                       message, option.description))
        super().__init__(msg, option)
github modm-io / lbuild / lbuild / exception.py View on Github external
.format(_hl("path/to/repo.lb"), _dump(parser)))
        super().__init__(parser._config.filename, message)

class LbuildConfigNoModulesException(LbuildConfigException):
    def __init__(self, parser):
        message = (": no modules selected to build!\n"
            "Hint: Add one or more modules either in your configuration files:\n\n"
            "    \n"
            "      {0}\n"
            "    \n\n"
            "Or via the command line:\n\n"
            "    lbuild build -m {0}"
            .format(_hl("repo:module")) + _dump(parser))
        super().__init__(parser._config.filename, message)

class LbuildConfigAddNotFoundException(LbuildConfigException):
    def __init__(self, repo, filename):
        filename = _rel(filename)
        message = (" not found!\n{}\n"
            "Hint: Check your config paths in '{}':\n\n"
            "   def init(repo):\n"
            "       repo.add_configuration(name, \"{}\", description)"
            .format(_call_site(repo._functions['init']),
                    _hl(_rel(repo._filename)), _hl(filename)))
        super().__init__(filename, message)
        self.node = repo

class LbuildConfigAliasNotFoundException(LbuildConfigException):
    def __init__(self, parser, alias):
        message = (": alias '{}' not found in any repository!"
                   .format(_hl(alias)) + _dump(parser))
        filename = next( (f for f, a in parser._config_flat._extends.items() if alias in a), None)
github modm-io / lbuild / lbuild / config.py View on Github external
xmlschema = lxml.etree.fromstring(
                pkgutil.get_data('lbuild', 'resources/configuration.xsd'))
            schema = lxml.etree.XMLSchema(xmlschema)
            schema.assertValid(xmlroot)

            xmltree = xmlroot.getroot()
        except OSError as error:
            raise LbuildConfigException(configfile, error)
        except (lxml.etree.DocumentInvalid,
                lxml.etree.XMLSyntaxError,
                lxml.etree.XMLSchemaParseError,
                lxml.etree.XIncludeError) as error:
            # lxml.etree has the used exception, but pylint is not able to detect them:
            # pylint: disable=no-member
            raise LbuildConfigException(configfile, ": Validation failed!\n\n{}".format(error))
        return xmltree
github modm-io / lbuild / lbuild / exception.py View on Github external
class LbuildConfigNoReposException(LbuildConfigException):
    def __init__(self, parser):
        message = (": no repositories loaded!\n"
            "Hint: Add a path to one or more repositories, either in your configuration files:\n\n"
            "    \n"
            "      \n"
            "        \n"
            "      \n"
            "    \n\n"
            "Or via the command line:\n\n"
            "    lbuild -r {0} discover"
            "{1}"
            .format(_hl("path/to/repo.lb"), _dump(parser)))
        super().__init__(parser._config.filename, message)

class LbuildConfigNoModulesException(LbuildConfigException):
    def __init__(self, parser):
        message = (": no modules selected to build!\n"
            "Hint: Add one or more modules either in your configuration files:\n\n"
            "    \n"
            "      {0}\n"
            "    \n\n"
            "Or via the command line:\n\n"
            "    lbuild build -m {0}"
            .format(_hl("repo:module")) + _dump(parser))
        super().__init__(parser._config.filename, message)

class LbuildConfigAddNotFoundException(LbuildConfigException):
    def __init__(self, repo, filename):
        filename = _rel(filename)
        message = (" not found!\n{}\n"
            "Hint: Check your config paths in '{}':\n\n"
github modm-io / lbuild / lbuild / config.py View on Github external
def _load_and_verify(configfile):
        try:
            xmlroot = lxml.etree.parse(str(configfile))

            xmlschema = lxml.etree.fromstring(
                pkgutil.get_data('lbuild', 'resources/configuration.xsd'))
            schema = lxml.etree.XMLSchema(xmlschema)
            schema.assertValid(xmlroot)

            xmltree = xmlroot.getroot()
        except OSError as error:
            raise LbuildConfigException(configfile, error)
        except (lxml.etree.DocumentInvalid,
                lxml.etree.XMLSyntaxError,
                lxml.etree.XMLSchemaParseError,
                lxml.etree.XIncludeError) as error:
            # lxml.etree has the used exception, but pylint is not able to detect them:
            # pylint: disable=no-member
            raise LbuildConfigException(configfile, ": Validation failed!\n\n{}".format(error))
        return xmltree
github modm-io / lbuild / lbuild / exception.py View on Github external
class LbuildConfigNotFoundException(LbuildConfigException):
    def __init__(self, filename, parent=None):
        filename = _rel(filename)
        if parent is None:
            message = (" not found!\n"
                "Hint: Check your command line call:\n\n"
                "    lbuild -c {} discover\n"
                .format(_hl(filename)))
        else:
            message = (" not found!\n"
                "Hint: Check your configuration paths in '{}':\n\n"
                "    {}\n"
                .format(_hl(parent), _hl(filename)))
        super().__init__(filename, message)

class LbuildConfigNoReposException(LbuildConfigException):
    def __init__(self, parser):
        message = (": no repositories loaded!\n"
            "Hint: Add a path to one or more repositories, either in your configuration files:\n\n"
            "    \n"
            "      \n"
            "        \n"
            "      \n"
            "    \n\n"
            "Or via the command line:\n\n"
            "    lbuild -r {0} discover"
            "{1}"
            .format(_hl("path/to/repo.lb"), _dump(parser)))
        super().__init__(parser._config.filename, message)

class LbuildConfigNoModulesException(LbuildConfigException):
    def __init__(self, parser):