diff --git a/tiramisu/config.py b/tiramisu/config.py index f3701cb..7ad800a 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -50,6 +50,7 @@ class Config(object): # sub option descriptions self._cfgimpl_subconfigs = {} self._cfgimpl_parent = parent + self._cfgimpl_permissive = [] if context is None: self._cfgimpl_context = self else: @@ -168,14 +169,12 @@ class Config(object): if not isinstance(opt_or_descr, Option) and \ not isinstance(opt_or_descr, OptionDescription): raise TypeError('Unexpected object: {0}'.format(repr(opt_or_descr))) - properties = copy(opt_or_descr.properties) - for proper in copy(properties): - if not self._cfgimpl_context._cfgimpl_settings.has_property(proper): - properties.remove(proper) + properties = set(copy(opt_or_descr.properties)) + properties = properties & set(self._cfgimpl_context._cfgimpl_settings.get_properties()) if permissive: - for perm in self._cfgimpl_context._cfgimpl_settings.permissive: - if perm in properties: - properties.remove(perm) + properties = properties - set(self._cfgimpl_context._cfgimpl_settings.get_permissive()) + properties = properties - set(self._cfgimpl_permissive) + properties = list(properties) if properties != []: raise PropertiesOptionError("trying to access" " to an option named: {0} with properties" @@ -415,6 +414,11 @@ class Config(object): except: pass # ______________________________________________________________________ + def cfgimpl_set_permissive(self, permissive): + if not isinstance(permissive, list): + raise TypeError('permissive must be a list') + self._cfgimpl_permissive = permissive + # ______________________________________________________________________ def __str__(self): "Config's string representation" lines = [] diff --git a/tiramisu/setting.py b/tiramisu/setting.py index 0e989c6..6bdcb13 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -137,6 +137,10 @@ class Setting(): "has properties means the Config's properties attribute is not empty" return bool(len(self.properties)) + + def get_properties(self): + return self.properties + def has_property(self, propname): """has property propname in the Config's properties attribute :param property: string wich is the name of the property""" @@ -152,6 +156,9 @@ class Setting(): if self.has_property(propname): self.properties.remove(propname) #____________________________________________________________ + def get_permissive(self): + return self.permissive + def set_permissive(self, permissive): if not isinstance(permissive, list): raise TypeError('permissive must be a list')