From 8a7c64f86afba67dace9c56f0bdd2526496ba29f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 30 Apr 2013 11:04:01 +0200 Subject: [PATCH] cleanups + indent errors Signed-off-by: Nico Schottelius --- cdist/config_install.py | 4 ++-- cdist/core/cdist_object.py | 48 ++------------------------------------ 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/cdist/config_install.py b/cdist/config_install.py index 841a19df..b458ad56 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -127,11 +127,11 @@ class ConfigInstall(object): unfinished_object_names = [] for cdist_object in self.object_list(): if not cdist_object.state == cdist_object.STATE_DONE: - unfinished_object_names.append(cdist_object.name) + unfinished_object_names.append(cdist_object.name) if unfinished_object_names: raise cdist.Error("The following objects could not be resolved: %s" % - (" ".join(unfinished_object_names)) + (" ".join(unfinished_object_names))) ###################################################################### # Stages based code diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 30d002f6..566cde21 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -224,13 +224,12 @@ class CdistObject(object): except EnvironmentError as error: raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error)) - @property - def requirements_satisfied(self): + def requirements_satisfied(self, requirements): """Return state whether normal depedencies are satisfied""" satisfied = True - for requirement in self.requirements: + for requirement in requirements: cdist_object = self.object_from_name(requirement) if not cdist_object.state == self.STATE_DONE: @@ -241,49 +240,6 @@ class CdistObject(object): return satisfied - @property - def satisfied_requirements(self): - """Return state whether all of our dependencies have been resolved already""" - - satisfied = True - - for requirement in self.all_requirements: - log.debug("%s: Checking requirement %s (%s) .." % (self.name, requirement.name, requirement.state)) - if not requirement.state == self.STATE_DONE: - satisfied = False - break - log.debug("%s is satisfied: %s" % (self.name, satisfied)) - - return satisfied - - - def find_requirements_by_name(self, requirements): - """Takes a list of requirement patterns and returns a list of matching object instances. - - Patterns are expected to be Unix shell-style wildcards for use with fnmatch.filter. - - find_requirements_by_name(['__type/object_id', '__other_type/*']) -> - [, , ] - """ - - - # FIXME: think about where/when to store this - probably not here - self.objects = dict((o.name, o) for o in self.list_objects(self.base_path, self.cdist_type.base_path)) - object_names = self.objects.keys() - - for pattern in requirements: - found = False - for requirement in fnmatch.filter(object_names, pattern): - found = True - yield self.objects[requirement] - if not found: - # FIXME: get rid of the singleton object_id, it should be invisible to the code -> hide it in Object - singleton = os.path.join(pattern, 'singleton') - if singleton in self.objects: - yield self.objects[singleton] - else: - raise RequirementNotFoundError(pattern) - @property def all_requirements(self): """