permissives are for a specified option not config

This commit is contained in:
Emmanuel Garette 2013-04-04 15:14:16 +02:00
parent 9006dca09f
commit c918191d21
2 changed files with 9 additions and 15 deletions

View File

@ -95,7 +95,7 @@ class SubConfig(object):
properties = properties & set_properties
if force_permissive is True or self.cfgimpl_get_settings().has_property('permissive'):
properties = properties - set(self.cfgimpl_get_settings().get_permissive())
properties = properties - set(self.cfgimpl_get_settings().get_permissive(self.cfgimpl_get_description()))
properties = properties - set(self.cfgimpl_get_settings().get_permissive(opt_or_descr))
properties = list(properties)
if properties != []:
raise PropertiesOptionError("trying to access"
@ -117,8 +117,8 @@ class SubConfig(object):
# for instance getattr(self, "creole.general.family.adresse_ip_eth0")
if '.' in name:
homeconfig, name = self.cfgimpl_get_home_by_path(name,
force_permissive=force_permissive,
force_properties=force_properties)
force_permissive=force_permissive,
force_properties=force_properties)
return homeconfig._getattr(name, force_permissive=force_permissive,
force_properties=force_properties)
opt_or_descr = getattr(self._cfgimpl_descr, name)
@ -155,8 +155,8 @@ class SubConfig(object):
path = path.split('.')
for step in path[:-1]:
self = self._getattr(step,
force_permissive=force_permissive,
force_properties=force_properties)
force_permissive=force_permissive,
force_properties=force_properties)
return self, path[-1]
def _cfgimpl_get_path(self):
@ -236,12 +236,6 @@ class SubConfig(object):
pass
# ______________________________________________________________________
def cfgimpl_set_permissive(self, permissive):
if not isinstance(permissive, list):
raise TypeError('permissive must be a list')
self.cfgimpl_get_settings().set_permissive(permissive, self.cfgimpl_get_description())
# ______________________________________________________________________
def __str__(self):
"Config's string representation"
lines = []

View File

@ -205,13 +205,13 @@ class Setting(object):
self.set_properties(properties, opt)
#____________________________________________________________
def get_permissive(self, config=None):
return self.permissives.get(config, [])
def get_permissive(self, opt=None):
return self.permissives.get(opt, [])
def set_permissive(self, permissive, config=None):
def set_permissive(self, permissive, opt=None):
if not isinstance(permissive, list):
raise TypeError('permissive must be a list')
self.permissives[config] = permissive
self.permissives[opt] = permissive
#____________________________________________________________
def setowner(self, owner):