How to use the lbuild.exception.LbuildDumpConfigException 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
.format(_hl(module), _hl(_rel(file)), _call_site(), _hl(conflict)))
        super().__init__(msg)


# =========================== REPOSITORY EXCEPTIONS ===========================
class LbuildRepositoryNoNameException(LbuildDumpConfigException):
    def __init__(self, parser, repo): # RepositoryInit
        msg = ("The '{}' function must set a repo name!\n{}\n"
               "Hint:\n\n"
               "    def init(repo):\n"
               "        {}"
               .format(_hl("init"), _call_site(repo._functions['init']),
                       _hl("repo.name = \":parent:name\"")))
        super().__init__(msg, parser)

class LbuildRepositoryAddModuleNotFoundException(LbuildDumpConfigException):
    def __init__(self, repo, path):
        msg = ("Module file '{}' not found!\n{}\n"
               "Hint: Use '{}' or '{}' for relative paths."
               .format(_hl(_rel(path)), _call_site(),
                       _hl("localpath(path)"), _hl("repopath(path)")))
        super().__init__(msg, repo)

class LbuildRepositoryAddModuleRecursiveNotFoundException(LbuildDumpConfigException):
    def __init__(self, repo, path):
        msg = ("Found no module files in '{}'!\n{}\n"
               "Hint: Use '{}' or '{}' for relative paths."
               .format(_hl(_rel(path)), _call_site(),
                       _hl("localpath(path)"), _hl("repopath(path)")))
        super().__init__(msg, repo)

class LbuildRepositoryDuplicateChildException(LbuildDumpConfigException):
github modm-io / lbuild / lbuild / exception.py View on Github external
"    prepare(repo, options):\n"
               "        repo.add_modules({})\n"
               "        repo.add_modules_recursive({})\n"
               .format(_hl(repo.fullname), _hl(_rel(repo._filename)),
                       _hl("prepare"), _hl('"path/to/module.lb"'), _hl('"directory"')))
        super().__init__(msg, repo)

class LbuildParserDuplicateModuleException(LbuildDumpConfigException):
    def __init__(self, parser, error):
        msg = ("{}({}) already has a submodule named '{}'!\n{}"
               .format(error.parent.class_name, _hl(error.parent.fullname),
                       _hl(error.child.fullname), error.hint))
        super().__init__(msg, parser)

# ============================= MODULE EXCEPTIONS =============================
class LbuildModuleNoNameException(LbuildDumpConfigException):
    def __init__(self, module): # ModuleInit
        msg = ("The '{}' function must set a module name!\n{}\n"
               "Hint:\n\n"
               "    def init(module):\n"
               "        {}"
               .format(_hl("init"), _call_site(module.functions['init']),
                       _hl("module.name = \":parent:name\"")))
        super().__init__(msg, module.repository)

class LbuildModuleNoReturnAvailableException(LbuildDumpConfigException):
    def __init__(self, module): # ModuleInit
        msg = ("The '{}' function of Module({}) must return a {}!\n{}\n"
               "Hint: The return value indicates whether or not this module"
               "is available given the repository options:\n\n"
               "    def prepare(module, options):\n"
               "        is_available = {{check repo options}}\n"
github modm-io / lbuild / lbuild / exception.py View on Github external
msg = "{}{}\n{}".format(
                error.prompt, _call_site(module._functions["prepare"]), error.hint)
        super().__init__(msg, error.node)


# ============================ BUILDLOG EXCEPTIONS ============================
class LbuildBuildlogOverwritingFileException(LbuildException):
    def __init__(self, module, file, conflict): # RepositoryInit
        msg = ("Module({}) is overwriting file '{}'!\n{}\n"
               "Hint: File previously generated by Module({})!"
               .format(_hl(module), _hl(_rel(file)), _call_site(), _hl(conflict)))
        super().__init__(msg)


# =========================== REPOSITORY EXCEPTIONS ===========================
class LbuildRepositoryNoNameException(LbuildDumpConfigException):
    def __init__(self, parser, repo): # RepositoryInit
        msg = ("The '{}' function must set a repo name!\n{}\n"
               "Hint:\n\n"
               "    def init(repo):\n"
               "        {}"
               .format(_hl("init"), _call_site(repo._functions['init']),
                       _hl("repo.name = \":parent:name\"")))
        super().__init__(msg, parser)

class LbuildRepositoryAddModuleNotFoundException(LbuildDumpConfigException):
    def __init__(self, repo, path):
        msg = ("Module file '{}' not found!\n{}\n"
               "Hint: Use '{}' or '{}' for relative paths."
               .format(_hl(_rel(path)), _call_site(),
                       _hl("localpath(path)"), _hl("repopath(path)")))
        super().__init__(msg, repo)
github modm-io / lbuild / lbuild / exception.py View on Github external
super().__init__(msg, module.repository)

class LbuildModuleNoReturnAvailableException(LbuildDumpConfigException):
    def __init__(self, module): # ModuleInit
        msg = ("The '{}' function of Module({}) must return a {}!\n{}\n"
               "Hint: The return value indicates whether or not this module"
               "is available given the repository options:\n\n"
               "    def prepare(module, options):\n"
               "        is_available = {{check repo options}}\n"
               "        {} is_available\n"
               .format(_hl("prepare"), _hl(module.fullname), _hl("boolean"),
                       _call_site(module.functions['prepare']),
                       _hl("return")))
        super().__init__(msg, module.repository)

class LbuildModuleParentNotFoundException(LbuildDumpConfigException):
    def __init__(self, module, parent): # Module
        msg = ("The parent '{}' for Module({}) in '{}' cannot be found!\n"
               "Hint: Make sure the parent module exists and is available for these repository options!"
               .format(_hl(parent), _hl(module.fullname), _hl(_rel(module._filename))))
        super().__init__(msg, module._repository)

class LbuildModuleDuplicateChildException(LbuildDumpConfigException):
    def __init__(self, module, error):
        msg = "{}{}\n{}".format(
                error.prompt, _call_site(module._functions["prepare"]), error.hint)
        super().__init__(msg, error.node)


# ============================ BUILDLOG EXCEPTIONS ============================
class LbuildBuildlogOverwritingFileException(LbuildException):
    def __init__(self, module, file, conflict): # RepositoryInit
github modm-io / lbuild / lbuild / exception.py View on Github external
# ============================= PARSER EXCEPTIONS =============================
class LbuildParserDuplicateRepoException(LbuildDumpConfigException):
    def __init__(self, parser, repo, conflict):
        msg = ("Repository({}) conflicts with existing Repository!\n{}\n"
               "Hint: This Repository from '{}':\n\n"
               "    >>> {}\n\n"
               "conflicts with this Repository from '{}':\n\n"
               "    >>> {}\n"
               .format(_hl(repo.name), _call_site(repo._functions['init']),
                       _hl(_rel(repo._filename)), lbuild.format.format_node(repo, 0, 0),
                       _hl(_rel(conflict._filename)), lbuild.format.format_node(conflict, 0, 0)))
        super().__init__(msg, parser)

class LbuildParserAddRepositoryNotFoundException(LbuildDumpConfigException):
    def __init__(self, parser, filename):
        msg = ("Repository file '{0}' not found!\n"
               "Hint: Check your command line call:\n\n"
               "    lbuild -r {0} discover\n\n"
               "Hint: Check your repository paths in '{1}':\n\n"
               "    \n"
               "      \n"
               "        \n"
               "      \n"
               "    \n\n"
               .format(_hl(_rel(filename)), _hl(parser._config.filename)))
        super().__init__(msg, parser)

class LbuildParserCannotResolveDependencyException(LbuildDumpConfigException):
    def __init__(self, parser, error):
        is_ambiguos = isinstance(error, LbuildResolverAmbiguousMatchException)
github modm-io / lbuild / lbuild / exception.py View on Github external
class LbuildParserAddRepositoryNotFoundException(LbuildDumpConfigException):
    def __init__(self, parser, filename):
        msg = ("Repository file '{0}' not found!\n"
               "Hint: Check your command line call:\n\n"
               "    lbuild -r {0} discover\n\n"
               "Hint: Check your repository paths in '{1}':\n\n"
               "    \n"
               "      \n"
               "        \n"
               "      \n"
               "    \n\n"
               .format(_hl(_rel(filename)), _hl(parser._config.filename)))
        super().__init__(msg, parser)

class LbuildParserCannotResolveDependencyException(LbuildDumpConfigException):
    def __init__(self, parser, error):
        is_ambiguos = isinstance(error, LbuildResolverAmbiguousMatchException)
        msg = ("Cannot resolve {}dependency '{}' of Module({})!\n{}\n"
               .format("ambiguous " if is_ambiguos else "",
                       _hl(error.query), _hl(error.node.fullname),
                       _call_site(error.node._functions['prepare'])))
        if is_ambiguos:
            msg += "Hint: Found these results:\n\n{}".format(
                            _bp(lbuild.format.format_node(r, 0, 0) for r in error.results))
        else:
            msg += ("Hint: Did you use the full module name?\n"
                    "      Is the module available and selected?\n")
        super().__init__(msg, parser)

class LbuildParserNodeNotFoundException(LbuildDumpConfigException):
    def __init__(self, parser, query, types=None, config=None):
github modm-io / lbuild / lbuild / exception.py View on Github external
def __init__(self, repo, path):
        msg = ("Module file '{}' not found!\n{}\n"
               "Hint: Use '{}' or '{}' for relative paths."
               .format(_hl(_rel(path)), _call_site(),
                       _hl("localpath(path)"), _hl("repopath(path)")))
        super().__init__(msg, repo)

class LbuildRepositoryAddModuleRecursiveNotFoundException(LbuildDumpConfigException):
    def __init__(self, repo, path):
        msg = ("Found no module files in '{}'!\n{}\n"
               "Hint: Use '{}' or '{}' for relative paths."
               .format(_hl(_rel(path)), _call_site(),
                       _hl("localpath(path)"), _hl("repopath(path)")))
        super().__init__(msg, repo)

class LbuildRepositoryDuplicateChildException(LbuildDumpConfigException):
    def __init__(self, parser, repo, error):
        msg = "{}{}\n{}".format(error.prompt, _call_site(repo._functions["init"]), error.hint)
        super().__init__(msg, repo)


# ============================== NODE EXCEPTIONS ==============================
class LbuildNodeMissingFunctionException(LbuildDumpConfigException):
    def __init__(self, repo, filename, error, submodule=None):
        msg = ("{}{} is missing the '{}' function!\n{}\n"
               "Hint: Required functions are:\n\n{}\n"
               "Hint: Optional functions are:\n\n{}"
               .format("Repository" if isinstance(repo, lbuild.repository.RepositoryInit) else "Module",
                       " file in '{}'".format(_hl(_rel(filename))) if submodule is None else "",
                       _hl(error.missing),
                       "" if submodule is None else _call_site(submodule.__class__),
                       _bp(error.required), _bp(error.optional)))
github modm-io / lbuild / lbuild / exception.py View on Github external
types = [_hl(t.name.capitalize()) for t in types]
            if is_plural:
                types = ", ".join(types)
                typestr["types"] = " of types {}".format(types)
                typestr["plural"] = "Are the {}".format(types)
            else:
                typestr["types"] = " of type {}".format(types[0])
                typestr["plural"] = "Is the {}".format(types[0])
        msg = ("Cannot resolve name '{}'{types}{config}!\n\n"
               "Hint: Did you use the full name?\n"
               "      {plural} available and selected?\n"
               "      Check your command line and config files.\n"
               .format(_hl(query), **typestr))
        super().__init__(msg, parser)

class LbuildParserOptionInvalidException(LbuildDumpConfigException):
    def __init__(self, parser, error, config):
        msg = ("Configuration({}): Failed to validate {}!\n{}"
               .format(_hl(_rel(config)), _hl(error.node.type.name.capitalize()), error))
        super().__init__(msg, parser)

class LbuildParserRepositoryEmptyException(LbuildDumpConfigException):
    def __init__(self, repo):
        msg = ("Repository({}) in '{}' did not add any modules!\n\n"
               "Hint: Add module files in the '{}' function:\n\n"
               "    prepare(repo, options):\n"
               "        repo.add_modules({})\n"
               "        repo.add_modules_recursive({})\n"
               .format(_hl(repo.fullname), _hl(_rel(repo._filename)),
                       _hl("prepare"), _hl('"path/to/module.lb"'), _hl('"directory"')))
        super().__init__(msg, repo)
github modm-io / lbuild / lbuild / exception.py View on Github external
class LbuildParserCannotResolveDependencyException(LbuildDumpConfigException):
    def __init__(self, parser, error):
        is_ambiguos = isinstance(error, LbuildResolverAmbiguousMatchException)
        msg = ("Cannot resolve {}dependency '{}' of Module({})!\n{}\n"
               .format("ambiguous " if is_ambiguos else "",
                       _hl(error.query), _hl(error.node.fullname),
                       _call_site(error.node._functions['prepare'])))
        if is_ambiguos:
            msg += "Hint: Found these results:\n\n{}".format(
                            _bp(lbuild.format.format_node(r, 0, 0) for r in error.results))
        else:
            msg += ("Hint: Did you use the full module name?\n"
                    "      Is the module available and selected?\n")
        super().__init__(msg, parser)

class LbuildParserNodeNotFoundException(LbuildDumpConfigException):
    def __init__(self, parser, query, types=None, config=None):
        typestr = {"types": "", "plural": "Is the node",
                   "config": "" if config is None else " in '{}'".format(_hl(_rel(config)))}
        if types is not None:
            types = lbuild.utils.listify(types)
            is_plural = len(types) > 1
            types = [_hl(t.name.capitalize()) for t in types]
            if is_plural:
                types = ", ".join(types)
                typestr["types"] = " of types {}".format(types)
                typestr["plural"] = "Are the {}".format(types)
            else:
                typestr["types"] = " of type {}".format(types[0])
                typestr["plural"] = "Is the {}".format(types[0])
        msg = ("Cannot resolve name '{}'{types}{config}!\n\n"
               "Hint: Did you use the full name?\n"
github modm-io / lbuild / lbuild / exception.py View on Github external
"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

class LbuildNodeConstructionException(LbuildDumpConfigException):
    def __init__(self, repo, node, reason):
        msg = "'{}({})':\n{}\n{}".format(node.__class__.__name__, _hl(node.name),
                                         _call_site(), _hl(reason))
        super().__init__(msg, repo)


# ============================ RESOLVER EXCEPTIONS ============================
class LbuildResolverException(LbuildDumpConfigException):
    def __init__(self, msg, node):
        super().__init__(msg, node)

class LbuildResolverSearchException(LbuildResolverException):
    def __init__(self, resolver, result, reason):
        msg = "{}({}) {}".format(_hl(result.class_name), _hl(result.fullname), reason)
        super().__init__(msg, resolver._node)
        self.result = result