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
|
objects_changed = False
|
||||||
|
|
||||||
for cdist_object in self.object_list():
|
for cdist_object in self.object_list():
|
||||||
if cdist_object.requirements_unfinished(
|
if cdist_object.has_requirements_unfinished(
|
||||||
cdist_object.requirements):
|
cdist_object.requirements):
|
||||||
"""We cannot do anything for this poor object"""
|
"""We cannot do anything for this poor object"""
|
||||||
continue
|
continue
|
||||||
|
@ -548,7 +548,7 @@ class Config:
|
||||||
self.object_prepare(cdist_object)
|
self.object_prepare(cdist_object)
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
|
|
||||||
if cdist_object.requirements_unfinished(
|
if cdist_object.has_requirements_unfinished(
|
||||||
cdist_object.autorequire):
|
cdist_object.autorequire):
|
||||||
"""The previous step created objects we depend on -
|
"""The previous step created objects we depend on -
|
||||||
wait for them
|
wait for them
|
||||||
|
@ -567,7 +567,8 @@ class Config:
|
||||||
|
|
||||||
cargo = []
|
cargo = []
|
||||||
for cdist_object in self.object_list():
|
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"""
|
"""We cannot do anything for this poor object"""
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -621,12 +622,13 @@ class Config:
|
||||||
|
|
||||||
del cargo[:]
|
del cargo[:]
|
||||||
for cdist_object in self.object_list():
|
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"""
|
"""We cannot do anything for this poor object"""
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
||||||
if cdist_object.requirements_unfinished(
|
if cdist_object.has_requirements_unfinished(
|
||||||
cdist_object.autorequire):
|
cdist_object.autorequire):
|
||||||
"""The previous step created objects we depend on -
|
"""The previous step created objects we depend on -
|
||||||
wait for them
|
wait for them
|
||||||
|
|
|
@ -280,7 +280,7 @@ class CdistObject:
|
||||||
'{}: {}').format(self, error))
|
'{}: {}').format(self, error))
|
||||||
|
|
||||||
def requirements_unfinished(self, requirements):
|
def requirements_unfinished(self, requirements):
|
||||||
"""Return state whether requirements are satisfied"""
|
"""Return unsatisfied requirements"""
|
||||||
|
|
||||||
object_list = []
|
object_list = []
|
||||||
|
|
||||||
|
@ -291,3 +291,14 @@ class CdistObject:
|
||||||
object_list.append(cdist_object)
|
object_list.append(cdist_object)
|
||||||
|
|
||||||
return object_list
|
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