remove dead code
This commit is contained in:
parent
4f2bc05e74
commit
b2cc5f7913
|
@ -6,8 +6,8 @@ do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.option import IntOption, OptionDescription
|
from tiramisu.error import APIError
|
||||||
from tiramisu.config import Config
|
from tiramisu import IntOption, OptionDescription, Config, getapi
|
||||||
|
|
||||||
|
|
||||||
def a_func():
|
def a_func():
|
||||||
|
@ -97,3 +97,27 @@ def test_option_multi():
|
||||||
raises(ValueError, "IntOption('test', '', multi=True, default_multi='yes')")
|
raises(ValueError, "IntOption('test', '', multi=True, default_multi='yes')")
|
||||||
#not default_multi with callback
|
#not default_multi with callback
|
||||||
raises(ValueError, "IntOption('test', '', multi=True, default_multi=1, callback=a_func)")
|
raises(ValueError, "IntOption('test', '', multi=True, default_multi=1, callback=a_func)")
|
||||||
|
|
||||||
|
|
||||||
|
def test_unknown_option():
|
||||||
|
i = IntOption('test', '')
|
||||||
|
od1 = OptionDescription('od', '', [i])
|
||||||
|
od2 = OptionDescription('od', '', [od1])
|
||||||
|
api = getapi(Config(od2))
|
||||||
|
# test is an option, not an optiondescription
|
||||||
|
raises(AttributeError, "api.option('od.test.unknown').value.get()")
|
||||||
|
# unknown is an unknown option
|
||||||
|
raises(AttributeError, "api.option('unknown').value.get()")
|
||||||
|
# unknown is an unknown option
|
||||||
|
raises(AttributeError, "api.option('od.unknown').value.get()")
|
||||||
|
# unknown is an unknown optiondescription
|
||||||
|
raises(AttributeError, "api.option('od.unknown.suboption').value.get()")
|
||||||
|
|
||||||
|
|
||||||
|
def test_asign_optiondescription():
|
||||||
|
i = IntOption('test', '')
|
||||||
|
od1 = OptionDescription('od', '', [i])
|
||||||
|
od2 = OptionDescription('od', '', [od1])
|
||||||
|
api = getapi(Config(od2))
|
||||||
|
raises(APIError, "api.option('od').value.set('test')")
|
||||||
|
raises(APIError, "api.option('od').value.reset()")
|
||||||
|
|
|
@ -587,3 +587,20 @@ def test_groups_with_master_get_modified_value():
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1', '192.168.1.1'])
|
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1', '192.168.1.1'])
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('255.255.255.255')
|
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('255.255.255.255')
|
||||||
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0',), (None, (0, 1)), (('192.168.1.1', '192.168.1.1'), ('255.255.255.255', '255.255.255.255')), ('user', ('user', 'user')))
|
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0',), (None, (0, 1)), (('192.168.1.1', '192.168.1.1'), ('255.255.255.255', '255.255.255.255')), ('user', ('user', 'user')))
|
||||||
|
|
||||||
|
|
||||||
|
def test_wrong_index():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od1 = OptionDescription('od', '', [interface1])
|
||||||
|
maconfig = OptionDescription('toto', '', [od1])
|
||||||
|
api = getapi(Config(maconfig))
|
||||||
|
api.property.read_write()
|
||||||
|
assert api.option('od.ip_admin_eth0.ip_admin_eth0').option.get()
|
||||||
|
raises(APIError, "api.option('od.ip_admin_eth0.ip_admin_eth0', 0).option.get()")
|
||||||
|
assert api.option('od.ip_admin_eth0.netmask_admin_eth0', 0).option.get()
|
||||||
|
assert api.option('od.ip_admin_eth0').option.get()
|
||||||
|
raises(APIError, "api.option('od.ip_admin_eth0', 0).option.get()")
|
||||||
|
assert api.option('od').option.get()
|
||||||
|
raises(APIError, "api.option('od', 0).option.get()")
|
||||||
|
|
|
@ -94,8 +94,10 @@ class CommonTiramisu(object):
|
||||||
self.config_bag.config.cfgimpl_get_settings().validate_properties(self.path,
|
self.config_bag.config.cfgimpl_get_settings().validate_properties(self.path,
|
||||||
self.index,
|
self.index,
|
||||||
self.config_bag)
|
self.config_bag)
|
||||||
if self.index is not None and option.impl_is_master_slaves('slave') and \
|
if self.index is not None:
|
||||||
self.index >= self.subconfig.cfgimpl_get_length():
|
if option.impl_is_optiondescription() or not option.impl_is_master_slaves('slave'):
|
||||||
|
raise APIError('index must be set only with a slave option')
|
||||||
|
if self.index >= self.subconfig.cfgimpl_get_length():
|
||||||
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
||||||
'for option "{}"').format(self.index,
|
'for option "{}"').format(self.index,
|
||||||
self.subconfig.cfgimpl_get_length(),
|
self.subconfig.cfgimpl_get_length(),
|
||||||
|
@ -841,8 +843,6 @@ class TiramisuDispatcherConfig(TiramisuContextConfig):
|
||||||
|
|
||||||
class TiramisuDispatcherOption(TiramisuContextOption):
|
class TiramisuDispatcherOption(TiramisuContextOption):
|
||||||
def __call__(self, path, index=None):
|
def __call__(self, path, index=None):
|
||||||
if path is None:
|
|
||||||
return self
|
|
||||||
config_bag = self.config_bag.copy()
|
config_bag = self.config_bag.copy()
|
||||||
validate = not config_bag.force_unrestraint
|
validate = not config_bag.force_unrestraint
|
||||||
if not validate:
|
if not validate:
|
||||||
|
|
|
@ -183,19 +183,15 @@ def carry_out_calculation(option,
|
||||||
if opt == option:
|
if opt == option:
|
||||||
index_ = None
|
index_ = None
|
||||||
with_index = False
|
with_index = False
|
||||||
iter_slave = True
|
|
||||||
elif opt.impl_is_master_slaves('slave'):
|
elif opt.impl_is_master_slaves('slave'):
|
||||||
index_ = index
|
index_ = index
|
||||||
with_index = False
|
with_index = False
|
||||||
iter_slave = False
|
|
||||||
else:
|
else:
|
||||||
index_ = None
|
index_ = None
|
||||||
with_index = True
|
with_index = True
|
||||||
iter_slave = False
|
|
||||||
else:
|
else:
|
||||||
index_ = None
|
index_ = None
|
||||||
with_index = False
|
with_index = False
|
||||||
iter_slave = False
|
|
||||||
if opt == option and orig_value is not undefined and \
|
if opt == option and orig_value is not undefined and \
|
||||||
(not opt.impl_is_master_slaves('slave') or index is None):
|
(not opt.impl_is_master_slaves('slave') or index is None):
|
||||||
value = orig_value
|
value = orig_value
|
||||||
|
@ -206,8 +202,7 @@ def carry_out_calculation(option,
|
||||||
# get value
|
# get value
|
||||||
value = context.getattr(path,
|
value = context.getattr(path,
|
||||||
index_,
|
index_,
|
||||||
sconfig_bag,
|
sconfig_bag)
|
||||||
iter_slave=iter_slave)
|
|
||||||
if with_index:
|
if with_index:
|
||||||
value = value[index]
|
value = value[index]
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
|
|
|
@ -66,9 +66,6 @@ class SubConfig(object):
|
||||||
raise TypeError(_('descr must be an optiondescription, not {0}'
|
raise TypeError(_('descr must be an optiondescription, not {0}'
|
||||||
).format(type(descr)))
|
).format(type(descr)))
|
||||||
self._impl_descr = descr
|
self._impl_descr = descr
|
||||||
# sub option descriptions
|
|
||||||
if not isinstance(context, weakref.ReferenceType): # pragma: optional cover
|
|
||||||
raise ValueError('context must be a Weakref')
|
|
||||||
self._impl_context = context
|
self._impl_context = context
|
||||||
self._impl_path = subpath
|
self._impl_path = subpath
|
||||||
if descr is not None and \
|
if descr is not None and \
|
||||||
|
@ -122,7 +119,7 @@ class SubConfig(object):
|
||||||
if resetted_opts is None:
|
if resetted_opts is None:
|
||||||
resetted_opts = []
|
resetted_opts = []
|
||||||
|
|
||||||
context = self._cfgimpl_get_context()
|
context = self.cfgimpl_get_context()
|
||||||
values = context.cfgimpl_get_values()
|
values = context.cfgimpl_get_values()
|
||||||
settings = context.cfgimpl_get_settings()
|
settings = context.cfgimpl_get_settings()
|
||||||
|
|
||||||
|
@ -189,7 +186,7 @@ class SubConfig(object):
|
||||||
|
|
||||||
def cfgimpl_get_children(self,
|
def cfgimpl_get_children(self,
|
||||||
config_bag):
|
config_bag):
|
||||||
context = self._cfgimpl_get_context()
|
context = self.cfgimpl_get_context()
|
||||||
for opt in self.cfgimpl_get_description().impl_getchildren(config_bag):
|
for opt in self.cfgimpl_get_description().impl_getchildren(config_bag):
|
||||||
nconfig_bag = config_bag.copy('nooption')
|
nconfig_bag = config_bag.copy('nooption')
|
||||||
nconfig_bag.option = opt
|
nconfig_bag.option = opt
|
||||||
|
@ -205,23 +202,7 @@ class SubConfig(object):
|
||||||
yield name
|
yield name
|
||||||
|
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
def cfgimpl_get_context(self):
|
||||||
# def __str__(self):
|
|
||||||
# "Config's string representation"
|
|
||||||
# lines = []
|
|
||||||
# for name, grp in self.iter_groups():
|
|
||||||
# lines.append("[{0}]".format(name))
|
|
||||||
# for name, value in self:
|
|
||||||
# try:
|
|
||||||
# lines.append("{0} = {1}".format(name, value))
|
|
||||||
# except UnicodeEncodeError: # pragma: optional cover
|
|
||||||
# lines.append("{0} = {1}".format(name,
|
|
||||||
# value.encode(default_encoding)))
|
|
||||||
# return '\n'.join(lines)
|
|
||||||
#
|
|
||||||
# __repr__ = __str__
|
|
||||||
|
|
||||||
def _cfgimpl_get_context(self):
|
|
||||||
"""context could be None, we need to test it
|
"""context could be None, we need to test it
|
||||||
context is None only if all reference to `Config` object is deleted
|
context is None only if all reference to `Config` object is deleted
|
||||||
(for example we delete a `Config` and we manipulate a reference to
|
(for example we delete a `Config` and we manipulate a reference to
|
||||||
|
@ -232,9 +213,6 @@ class SubConfig(object):
|
||||||
raise ConfigError(_('the context does not exist anymore'))
|
raise ConfigError(_('the context does not exist anymore'))
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def cfgimpl_get_context(self):
|
|
||||||
return self._cfgimpl_get_context()
|
|
||||||
|
|
||||||
def cfgimpl_get_description(self):
|
def cfgimpl_get_description(self):
|
||||||
if self._impl_descr is None: # pragma: optional cover
|
if self._impl_descr is None: # pragma: optional cover
|
||||||
raise ConfigError(_('no option description found for this config'
|
raise ConfigError(_('no option description found for this config'
|
||||||
|
@ -243,10 +221,10 @@ class SubConfig(object):
|
||||||
return self._impl_descr
|
return self._impl_descr
|
||||||
|
|
||||||
def cfgimpl_get_settings(self):
|
def cfgimpl_get_settings(self):
|
||||||
return self._cfgimpl_get_context()._impl_settings
|
return self.cfgimpl_get_context()._impl_settings
|
||||||
|
|
||||||
def cfgimpl_get_values(self):
|
def cfgimpl_get_values(self):
|
||||||
return self._cfgimpl_get_context()._impl_values
|
return self.cfgimpl_get_context()._impl_values
|
||||||
|
|
||||||
def setattr(self,
|
def setattr(self,
|
||||||
name,
|
name,
|
||||||
|
@ -255,11 +233,7 @@ class SubConfig(object):
|
||||||
config_bag,
|
config_bag,
|
||||||
_commit=True):
|
_commit=True):
|
||||||
|
|
||||||
if name.startswith('_impl_'):
|
context = self.cfgimpl_get_context()
|
||||||
return object.__setattr__(self,
|
|
||||||
name,
|
|
||||||
value)
|
|
||||||
context = self._cfgimpl_get_context()
|
|
||||||
if '.' in name: # pragma: optional cover
|
if '.' in name: # pragma: optional cover
|
||||||
# when set_value
|
# when set_value
|
||||||
self, name = self.cfgimpl_get_home_by_path(name,
|
self, name = self.cfgimpl_get_home_by_path(name,
|
||||||
|
@ -268,10 +242,7 @@ class SubConfig(object):
|
||||||
config_bag.option = self.cfgimpl_get_description().impl_getchild(name,
|
config_bag.option = self.cfgimpl_get_description().impl_getchild(name,
|
||||||
config_bag,
|
config_bag,
|
||||||
self)
|
self)
|
||||||
if config_bag.option.impl_is_optiondescription() or \
|
if config_bag.option.impl_is_symlinkoption():
|
||||||
isinstance(config_bag.option, SynDynOptionDescription):
|
|
||||||
raise ConfigError(_("can't assign to an OptionDescription")) # pragma: optional cover
|
|
||||||
elif config_bag.option.impl_is_symlinkoption():
|
|
||||||
raise ConfigError(_("can't assign to a SymLinkOption"))
|
raise ConfigError(_("can't assign to a SymLinkOption"))
|
||||||
else:
|
else:
|
||||||
path = self._get_subpath(name)
|
path = self._get_subpath(name)
|
||||||
|
@ -295,14 +266,8 @@ class SubConfig(object):
|
||||||
if '.' in name: # pragma: optional cover
|
if '.' in name: # pragma: optional cover
|
||||||
self, name = self.cfgimpl_get_home_by_path(name,
|
self, name = self.cfgimpl_get_home_by_path(name,
|
||||||
config_bag)
|
config_bag)
|
||||||
if config_bag.option is None:
|
|
||||||
config_bag.option = self.cfgimpl_get_description().impl_getchild(name,
|
|
||||||
config_bag,
|
|
||||||
self)
|
|
||||||
option = config_bag.option
|
option = config_bag.option
|
||||||
if option.impl_is_optiondescription() or isinstance(option, SynDynOptionDescription):
|
if option.impl_is_symlinkoption():
|
||||||
raise TypeError(_("can't delete an OptionDescription")) # pragma: optional cover
|
|
||||||
elif option.impl_is_symlinkoption():
|
|
||||||
raise TypeError(_("can't delete a SymLinkOption"))
|
raise TypeError(_("can't delete a SymLinkOption"))
|
||||||
subpath = self._get_subpath(name)
|
subpath = self._get_subpath(name)
|
||||||
values = self.cfgimpl_get_values()
|
values = self.cfgimpl_get_values()
|
||||||
|
@ -313,17 +278,9 @@ class SubConfig(object):
|
||||||
index,
|
index,
|
||||||
config_bag)
|
config_bag)
|
||||||
elif option.impl_is_master_slaves('slave'):
|
elif option.impl_is_master_slaves('slave'):
|
||||||
length = self.cfgimpl_get_length()
|
|
||||||
if index >= length:
|
|
||||||
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
|
||||||
'for option "{}"').format(index,
|
|
||||||
length,
|
|
||||||
option.impl_get_display_name()))
|
|
||||||
values.reset_slave(subpath,
|
values.reset_slave(subpath,
|
||||||
index,
|
index,
|
||||||
config_bag)
|
config_bag)
|
||||||
else:
|
|
||||||
raise ValueError(_("can delete value with index only with a master or a slave"))
|
|
||||||
else:
|
else:
|
||||||
values.reset(subpath,
|
values.reset(subpath,
|
||||||
config_bag)
|
config_bag)
|
||||||
|
@ -338,9 +295,7 @@ class SubConfig(object):
|
||||||
def getattr(self,
|
def getattr(self,
|
||||||
name,
|
name,
|
||||||
index,
|
index,
|
||||||
config_bag,
|
config_bag):
|
||||||
returns_option=False,
|
|
||||||
iter_slave=False):
|
|
||||||
"""
|
"""
|
||||||
attribute notation mechanism for accessing the value of an option
|
attribute notation mechanism for accessing the value of an option
|
||||||
:param name: attribute name
|
:param name: attribute name
|
||||||
|
@ -351,7 +306,7 @@ class SubConfig(object):
|
||||||
self, name = self.cfgimpl_get_home_by_path(name,
|
self, name = self.cfgimpl_get_home_by_path(name,
|
||||||
config_bag)
|
config_bag)
|
||||||
|
|
||||||
context = self._cfgimpl_get_context()
|
context = self.cfgimpl_get_context()
|
||||||
option = config_bag.option
|
option = config_bag.option
|
||||||
if option is None:
|
if option is None:
|
||||||
option = self.cfgimpl_get_description().impl_getchild(name,
|
option = self.cfgimpl_get_description().impl_getchild(name,
|
||||||
|
@ -359,8 +314,6 @@ class SubConfig(object):
|
||||||
self)
|
self)
|
||||||
config_bag.option = option
|
config_bag.option = option
|
||||||
if option.impl_is_symlinkoption():
|
if option.impl_is_symlinkoption():
|
||||||
if returns_option is True:
|
|
||||||
return option
|
|
||||||
opt = option.impl_getopt()
|
opt = option.impl_getopt()
|
||||||
path = context.cfgimpl_get_description().impl_get_path_by_opt(opt)
|
path = context.cfgimpl_get_description().impl_get_path_by_opt(opt)
|
||||||
sconfig_bag = config_bag.copy('nooption')
|
sconfig_bag = config_bag.copy('nooption')
|
||||||
|
@ -376,33 +329,20 @@ class SubConfig(object):
|
||||||
index,
|
index,
|
||||||
config_bag)
|
config_bag)
|
||||||
if option.impl_is_optiondescription():
|
if option.impl_is_optiondescription():
|
||||||
if returns_option is True:
|
|
||||||
return option
|
|
||||||
return SubConfig(option,
|
return SubConfig(option,
|
||||||
self._impl_context,
|
self._impl_context,
|
||||||
config_bag,
|
config_bag,
|
||||||
subpath)
|
subpath)
|
||||||
|
|
||||||
if option.impl_is_master_slaves('slave'):
|
if option.impl_is_master_slaves('slave'):
|
||||||
if index is None and not iter_slave:
|
|
||||||
raise SlaveError(_('index is mandatory for the slave "{}"'
|
|
||||||
'').format(subpath))
|
|
||||||
length = self.cfgimpl_get_length()
|
length = self.cfgimpl_get_length()
|
||||||
if index is not None and index >= length:
|
|
||||||
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
|
||||||
'for option "{}"').format(index,
|
|
||||||
length,
|
|
||||||
option.impl_get_display_name()))
|
|
||||||
slave_len = self.cfgimpl_get_values()._p_.get_max_length(subpath)
|
slave_len = self.cfgimpl_get_values()._p_.get_max_length(subpath)
|
||||||
if slave_len > length:
|
if slave_len > length:
|
||||||
raise SlaveError(_('slave option "{}" has higher length "{}" than the master length "{}"'
|
raise SlaveError(_('slave option "{}" has higher length "{}" than the master '
|
||||||
'').format(option.impl_get_display_name(),
|
'length "{}"').format(option.impl_get_display_name(),
|
||||||
slave_len,
|
slave_len,
|
||||||
length,
|
length,
|
||||||
subpath))
|
subpath))
|
||||||
elif index:
|
|
||||||
raise SlaveError(_('index is forbidden for the not slave "{}"'
|
|
||||||
'').format(subpath))
|
|
||||||
if option.impl_is_master_slaves('slave') and index is None:
|
if option.impl_is_master_slaves('slave') and index is None:
|
||||||
value = []
|
value = []
|
||||||
length = self.cfgimpl_get_length()
|
length = self.cfgimpl_get_length()
|
||||||
|
@ -420,9 +360,6 @@ class SubConfig(object):
|
||||||
index,
|
index,
|
||||||
value,
|
value,
|
||||||
config_bag)
|
config_bag)
|
||||||
#FIXME utiliser le config_bag !
|
|
||||||
if returns_option is True:
|
|
||||||
return option
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def find(self,
|
def find(self,
|
||||||
|
@ -439,7 +376,7 @@ class SubConfig(object):
|
||||||
:param byvalue: filter by the option's value
|
:param byvalue: filter by the option's value
|
||||||
:returns: list of matching Option objects
|
:returns: list of matching Option objects
|
||||||
"""
|
"""
|
||||||
return self._cfgimpl_get_context()._find(bytype,
|
return self.cfgimpl_get_context()._find(bytype,
|
||||||
byname,
|
byname,
|
||||||
byvalue,
|
byvalue,
|
||||||
config_bag,
|
config_bag,
|
||||||
|
@ -462,7 +399,7 @@ class SubConfig(object):
|
||||||
:param byvalue: filter by the option's value
|
:param byvalue: filter by the option's value
|
||||||
:returns: list of matching Option objects
|
:returns: list of matching Option objects
|
||||||
"""
|
"""
|
||||||
return self._cfgimpl_get_context()._find(bytype,
|
return self.cfgimpl_get_context()._find(bytype,
|
||||||
byname,
|
byname,
|
||||||
byvalue,
|
byvalue,
|
||||||
config_bag,
|
config_bag,
|
||||||
|
@ -608,7 +545,7 @@ class SubConfig(object):
|
||||||
if withoption is None and withvalue is not undefined: # pragma: optional cover
|
if withoption is None and withvalue is not undefined: # pragma: optional cover
|
||||||
raise ValueError(_("make_dict can't filtering with value without "
|
raise ValueError(_("make_dict can't filtering with value without "
|
||||||
"option"))
|
"option"))
|
||||||
context = self._cfgimpl_get_context()
|
context = self.cfgimpl_get_context()
|
||||||
if withoption is not None:
|
if withoption is not None:
|
||||||
for path in context._find(bytype=None,
|
for path in context._find(bytype=None,
|
||||||
byname=withoption,
|
byname=withoption,
|
||||||
|
@ -712,7 +649,7 @@ class SubConfig(object):
|
||||||
dyn=True):
|
dyn=True):
|
||||||
descr = self.cfgimpl_get_description()
|
descr = self.cfgimpl_get_description()
|
||||||
if not dyn and descr.impl_is_dynoptiondescription():
|
if not dyn and descr.impl_is_dynoptiondescription():
|
||||||
context_descr = self._cfgimpl_get_context().cfgimpl_get_description()
|
context_descr = self.cfgimpl_get_context().cfgimpl_get_description()
|
||||||
return context_descr.impl_get_path_by_opt(descr.impl_getopt())
|
return context_descr.impl_get_path_by_opt(descr.impl_getopt())
|
||||||
return self._impl_path
|
return self._impl_path
|
||||||
|
|
||||||
|
@ -724,14 +661,12 @@ class _CommonConfig(SubConfig):
|
||||||
'_impl_meta',
|
'_impl_meta',
|
||||||
'_impl_test')
|
'_impl_test')
|
||||||
|
|
||||||
def _impl_build_all_caches(self,
|
def _impl_build_all_caches(self):
|
||||||
force_store_values):
|
|
||||||
descr = self.cfgimpl_get_description()
|
descr = self.cfgimpl_get_description()
|
||||||
if not descr.impl_already_build_caches():
|
if not descr.impl_already_build_caches():
|
||||||
descr._build_cache_option()
|
descr._build_cache_option()
|
||||||
descr._build_cache(self)
|
descr._build_cache(self)
|
||||||
descr.impl_build_force_store_values(self,
|
descr.impl_build_force_store_values(self)
|
||||||
force_store_values)
|
|
||||||
|
|
||||||
def unwrap_from_path(self,
|
def unwrap_from_path(self,
|
||||||
path,
|
path,
|
||||||
|
@ -753,8 +688,9 @@ class _CommonConfig(SubConfig):
|
||||||
else:
|
else:
|
||||||
if option.impl_is_symlinkoption():
|
if option.impl_is_symlinkoption():
|
||||||
true_option = option.impl_getopt()
|
true_option = option.impl_getopt()
|
||||||
true_path = true_option.impl_getpath(self._cfgimpl_get_context())
|
context = self.cfgimpl_get_context()
|
||||||
self, path = self.cfgimpl_get_context().cfgimpl_get_home_by_path(true_path,
|
true_path = true_option.impl_getpath(context)
|
||||||
|
self, path = context.cfgimpl_get_home_by_path(true_path,
|
||||||
config_bag)
|
config_bag)
|
||||||
config_bag.option = true_option
|
config_bag.option = true_option
|
||||||
else:
|
else:
|
||||||
|
@ -827,8 +763,7 @@ class Config(_CommonConfig):
|
||||||
persistent=False,
|
persistent=False,
|
||||||
force_values=None,
|
force_values=None,
|
||||||
force_settings=None,
|
force_settings=None,
|
||||||
_duplicate=False,
|
_duplicate=False):
|
||||||
_force_store_values=True):
|
|
||||||
""" Configuration option management master class
|
""" Configuration option management master class
|
||||||
|
|
||||||
:param descr: describes the configuration schema
|
:param descr: describes the configuration schema
|
||||||
|
@ -871,7 +806,7 @@ class Config(_CommonConfig):
|
||||||
#undocumented option used only in test script
|
#undocumented option used only in test script
|
||||||
self._impl_test = False
|
self._impl_test = False
|
||||||
if _duplicate is False and (force_settings is None or force_values is None):
|
if _duplicate is False and (force_settings is None or force_values is None):
|
||||||
self._impl_build_all_caches(_force_store_values)
|
self._impl_build_all_caches()
|
||||||
self._impl_name = session_id
|
self._impl_name = session_id
|
||||||
|
|
||||||
def impl_getname(self):
|
def impl_getname(self):
|
||||||
|
@ -901,7 +836,7 @@ class GroupConfig(_CommonConfig):
|
||||||
name_ = child._impl_name
|
name_ = child._impl_name
|
||||||
names.append(name_)
|
names.append(name_)
|
||||||
if len(names) != len(set(names)):
|
if len(names) != len(set(names)):
|
||||||
for idx in xrange(1, len(names) + 1):
|
for idx in range(1, len(names) + 1):
|
||||||
name = names.pop(0)
|
name = names.pop(0)
|
||||||
if name in names:
|
if name in names:
|
||||||
raise ConflictError(_('config name must be uniq in '
|
raise ConflictError(_('config name must be uniq in '
|
||||||
|
@ -1060,16 +995,14 @@ class MetaConfig(GroupConfig):
|
||||||
children,
|
children,
|
||||||
session_id=None,
|
session_id=None,
|
||||||
persistent=False,
|
persistent=False,
|
||||||
optiondescription=None,
|
optiondescription=None):
|
||||||
_force_store_values=True):
|
|
||||||
descr = None
|
descr = None
|
||||||
if optiondescription is not None:
|
if optiondescription is not None:
|
||||||
new_children = []
|
new_children = []
|
||||||
for child_session_id in children:
|
for child_session_id in children:
|
||||||
new_children.append(Config(optiondescription,
|
new_children.append(Config(optiondescription,
|
||||||
persistent=persistent,
|
persistent=persistent,
|
||||||
session_id=child_session_id,
|
session_id=child_session_id))
|
||||||
_force_store_values=_force_store_values))
|
|
||||||
children = new_children
|
children = new_children
|
||||||
for child in children:
|
for child in children:
|
||||||
if not isinstance(child, _CommonConfig):
|
if not isinstance(child, _CommonConfig):
|
||||||
|
|
|
@ -329,7 +329,7 @@ class Base(object):
|
||||||
callback_params = self._build_calculator_params(callback,
|
callback_params = self._build_calculator_params(callback,
|
||||||
callback_params)
|
callback_params)
|
||||||
val = getattr(self, '_val_call', (None,))[0]
|
val = getattr(self, '_val_call', (None,))[0]
|
||||||
if callback_params is None or callback_params == {}:
|
if callback_params == {}:
|
||||||
val_call = (callback,)
|
val_call = (callback,)
|
||||||
else:
|
else:
|
||||||
val_call = tuple([callback, callback_params])
|
val_call = tuple([callback, callback_params])
|
||||||
|
|
|
@ -110,7 +110,7 @@ class Option(OnlyOption):
|
||||||
validator_params = self._build_calculator_params(validator,
|
validator_params = self._build_calculator_params(validator,
|
||||||
validator_params,
|
validator_params,
|
||||||
add_value=True)
|
add_value=True)
|
||||||
if validator_params is None:
|
if validator_params == {}:
|
||||||
val_call = (validator,)
|
val_call = (validator,)
|
||||||
else:
|
else:
|
||||||
val_call = (validator, validator_params)
|
val_call = (validator, validator_params)
|
||||||
|
@ -575,8 +575,7 @@ class Option(OnlyOption):
|
||||||
try:
|
try:
|
||||||
opt_value = context.getattr(path,
|
opt_value = context.getattr(path,
|
||||||
index_,
|
index_,
|
||||||
sconfig_bag,
|
sconfig_bag)
|
||||||
iter_slave=True)
|
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
if debug: # pragma: no cover
|
if debug: # pragma: no cover
|
||||||
log.debug('propertyerror in _launch_consistency: {0}'.format(err))
|
log.debug('propertyerror in _launch_consistency: {0}'.format(err))
|
||||||
|
|
|
@ -164,8 +164,7 @@ class CacheOptionDescription(BaseOption):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def impl_build_force_store_values(self,
|
def impl_build_force_store_values(self,
|
||||||
context,
|
context):
|
||||||
force_store_values):
|
|
||||||
value_setted = False
|
value_setted = False
|
||||||
values = context.cfgimpl_get_values()
|
values = context.cfgimpl_get_values()
|
||||||
for subpath, option in self._cache_force_store_values:
|
for subpath, option in self._cache_force_store_values:
|
||||||
|
@ -176,9 +175,7 @@ class CacheOptionDescription(BaseOption):
|
||||||
if option._is_subdyn():
|
if option._is_subdyn():
|
||||||
raise ConfigError(_('a dynoption ({0}) cannot have '
|
raise ConfigError(_('a dynoption ({0}) cannot have '
|
||||||
'force_store_value property').format(subpath))
|
'force_store_value property').format(subpath))
|
||||||
if force_store_values is False:
|
if not values._p_.hasvalue(subpath):
|
||||||
raise Exception('ok ca existe ...')
|
|
||||||
if force_store_values and not values._p_.hasvalue(subpath):
|
|
||||||
config_bag = ConfigBag(config=context, option=option)
|
config_bag = ConfigBag(config=context, option=option)
|
||||||
value = values.getvalue(subpath,
|
value = values.getvalue(subpath,
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -777,9 +777,6 @@ class Settings(object):
|
||||||
def setowner(self,
|
def setowner(self,
|
||||||
owner):
|
owner):
|
||||||
":param owner: sets the default value for owner at the Config level"
|
":param owner: sets the default value for owner at the Config level"
|
||||||
if not isinstance(owner,
|
|
||||||
owners.Owner): # pragma: optional cover
|
|
||||||
raise TypeError(_("invalid generic owner {0}").format(str(owner)))
|
|
||||||
self._owner = owner
|
self._owner = owner
|
||||||
|
|
||||||
def getowner(self):
|
def getowner(self):
|
||||||
|
|
Loading…
Reference in New Issue