Improve unfinished object requirements bool check
When we need only boolean value for unfinished object requirements then we don't need to determine the whole list of unfinished objects.
This commit is contained in:
parent
ab811ad282
commit
199effb7ef
2 changed files with 19 additions and 6 deletions
|
@ -537,7 +537,7 @@ class Config:
|
|||
objects_changed = False
|
||||
|
||||
for cdist_object in self.object_list():
|
||||
if cdist_object.requirements_unfinished(
|
||||
if cdist_object.has_requirements_unfinished(
|
||||
cdist_object.requirements):
|
||||
"""We cannot do anything for this poor object"""
|
||||
continue
|
||||
|
@ -548,7 +548,7 @@ class Config:
|
|||
self.object_prepare(cdist_object)
|
||||
objects_changed = True
|
||||
|
||||
if cdist_object.requirements_unfinished(
|
||||
if cdist_object.has_requirements_unfinished(
|
||||
cdist_object.autorequire):
|
||||
"""The previous step created objects we depend on -
|
||||
wait for them
|
||||
|
@ -567,7 +567,8 @@ class Config:
|
|||
|
||||
cargo = []
|
||||
for cdist_object in self.object_list():
|
||||
if cdist_object.requirements_unfinished(cdist_object.requirements):
|
||||
if cdist_object.has_requirements_unfinished(
|
||||
cdist_object.requirements):
|
||||
"""We cannot do anything for this poor object"""
|
||||
continue
|
||||
|
||||
|
@ -621,12 +622,13 @@ class Config:
|
|||
|
||||
del cargo[:]
|
||||
for cdist_object in self.object_list():
|
||||
if cdist_object.requirements_unfinished(cdist_object.requirements):
|
||||
if cdist_object.has_requirements_unfinished(
|
||||
cdist_object.requirements):
|
||||
"""We cannot do anything for this poor object"""
|
||||
continue
|
||||
|
||||
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
||||
if cdist_object.requirements_unfinished(
|
||||
if cdist_object.has_requirements_unfinished(
|
||||
cdist_object.autorequire):
|
||||
"""The previous step created objects we depend on -
|
||||
wait for them
|
||||
|
|
|
@ -280,7 +280,7 @@ class CdistObject:
|
|||
'{}: {}').format(self, error))
|
||||
|
||||
def requirements_unfinished(self, requirements):
|
||||
"""Return state whether requirements are satisfied"""
|
||||
"""Return unsatisfied requirements"""
|
||||
|
||||
object_list = []
|
||||
|
||||
|
@ -291,3 +291,14 @@ class CdistObject:
|
|||
object_list.append(cdist_object)
|
||||
|
||||
return object_list
|
||||
|
||||
def has_requirements_unfinished(self, requirements):
|
||||
"""Return whether requirements are satisfied"""
|
||||
|
||||
for requirement in requirements:
|
||||
cdist_object = self.object_from_name(requirement)
|
||||
|
||||
if cdist_object.state != self.STATE_DONE:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue