Minor refactoring and remove code duplication
This commit is contained in:
parent
199effb7ef
commit
750c71fb5a
1 changed files with 10 additions and 8 deletions
|
@ -699,20 +699,22 @@ class Config:
|
||||||
check for cycles.
|
check for cycles.
|
||||||
'''
|
'''
|
||||||
graph = {}
|
graph = {}
|
||||||
for cdist_object in self.object_list():
|
|
||||||
|
def _add_requirements(cdist_object, requirements):
|
||||||
obj_name = cdist_object.name
|
obj_name = cdist_object.name
|
||||||
if obj_name not in graph:
|
if obj_name not in graph:
|
||||||
graph[obj_name] = []
|
graph[obj_name] = []
|
||||||
|
|
||||||
|
for requirement in cdist_object.requirements_unfinished(
|
||||||
|
requirements):
|
||||||
|
graph[obj_name].append(requirement.name)
|
||||||
|
|
||||||
|
for cdist_object in self.object_list():
|
||||||
if cdist_object.state == cdist_object.STATE_DONE:
|
if cdist_object.state == cdist_object.STATE_DONE:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for requirement in cdist_object.requirements_unfinished(
|
_add_requirements(cdist_object, cdist_object.requirements)
|
||||||
cdist_object.requirements):
|
_add_requirements(cdist_object, cdist_object.autorequire)
|
||||||
graph[obj_name].append(requirement.name)
|
|
||||||
|
|
||||||
for requirement in cdist_object.requirements_unfinished(
|
|
||||||
cdist_object.autorequire):
|
|
||||||
graph[obj_name].append(requirement.name)
|
|
||||||
return graph_check_cycle(graph)
|
return graph_check_cycle(graph)
|
||||||
|
|
||||||
def iterate_until_finished(self):
|
def iterate_until_finished(self):
|
||||||
|
|
Loading…
Reference in a new issue