Only check for unknown dependencies once
This commit is contained in:
parent
a9a9878de0
commit
2a93a8f1dd
1 changed files with 14 additions and 6 deletions
|
@ -19,8 +19,10 @@ class ModuleNotLoadedWarning(ModuleWarning):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ModuleDependencyNotFulfilled(ModuleException):
|
class ModuleDependencyNotFulfilled(ModuleException):
|
||||||
def __init__(self, message, dependency):
|
def __init__(self, module, dependency):
|
||||||
ModuleException.__init__(self, message)
|
ModuleException.__init__(self, "Dependency for %s not fulfilled: %s"
|
||||||
|
% (module, dependency))
|
||||||
|
self.module = module
|
||||||
self.dependency = dependency
|
self.dependency = dependency
|
||||||
|
|
||||||
class ModuleType(enum.Enum):
|
class ModuleType(enum.Enum):
|
||||||
|
@ -155,9 +157,8 @@ class ModuleManager(object):
|
||||||
dependencies = definition.get_dependencies()
|
dependencies = definition.get_dependencies()
|
||||||
for dependency in dependencies:
|
for dependency in dependencies:
|
||||||
if not dependency in self.modules:
|
if not dependency in self.modules:
|
||||||
raise ModuleDependencyNotFulfilled(
|
raise ModuleDependencyNotFulfilled(definition.name,
|
||||||
"Dependency for %s not fulfilled: %s" %
|
dependency)
|
||||||
(definition.name, dependency) ,dependency)
|
|
||||||
|
|
||||||
for hashflag, value in definition.hashflags:
|
for hashflag, value in definition.hashflags:
|
||||||
if hashflag == "ignore":
|
if hashflag == "ignore":
|
||||||
|
@ -235,6 +236,12 @@ class ModuleManager(object):
|
||||||
definition_dependencies = {
|
definition_dependencies = {
|
||||||
d.name: d.get_dependencies() for d in definitions}
|
d.name: d.get_dependencies() for d in definitions}
|
||||||
|
|
||||||
|
for name, deps in definition_dependencies.items():
|
||||||
|
for dep in deps:
|
||||||
|
if not dep in definition_dependencies:
|
||||||
|
# unknown dependency!
|
||||||
|
raise ModuleDependencyNotFulfilled(name, dep)
|
||||||
|
|
||||||
while definition_dependencies:
|
while definition_dependencies:
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
|
@ -256,7 +263,8 @@ class ModuleManager(object):
|
||||||
for name, deps in definition_dependencies.items():
|
for name, deps in definition_dependencies.items():
|
||||||
for dep_name in deps:
|
for dep_name in deps:
|
||||||
if name in definition_dependencies[dep_name]:
|
if name in definition_dependencies[dep_name]:
|
||||||
self.log.warn("Circular dependencies: %s<->%s",
|
self.log.warn(
|
||||||
|
"Circular dependencies detected: %s<->%s",
|
||||||
[name, dep_name])
|
[name, dep_name])
|
||||||
# snap a circular dependence
|
# snap a circular dependence
|
||||||
deps.remove(dep_name)
|
deps.remove(dep_name)
|
||||||
|
|
Loading…
Reference in a new issue