This commit is contained in:
Emmanuel Garette 2013-08-21 18:34:32 +02:00
parent acca6d5a27
commit 707a215a2c
2 changed files with 32 additions and 37 deletions

View File

@ -187,9 +187,8 @@ class SubConfig(BaseInformation):
force_permissive=force_permissive)
else:
context = self.cfgimpl_get_context()
path = context.\
cfgimpl_get_description().\
impl_get_path_by_opt(child._opt)
path = context.cfgimpl_get_description().impl_get_path_by_opt(
child._opt)
context._setattr(path, value, force_permissive=force_permissive)
def __delattr__(self, name):
@ -210,9 +209,9 @@ class SubConfig(BaseInformation):
# attribute access by passing a path,
# 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)
homeconfig, name = self.cfgimpl_get_home_by_path(
name, force_permissive=force_permissive,
force_properties=force_properties)
return homeconfig._getattr(name, force_permissive=force_permissive,
force_properties=force_properties,
validate=validate)
@ -225,22 +224,22 @@ class SubConfig(BaseInformation):
# symlink options
if isinstance(opt_or_descr, SymLinkOption):
context = self.cfgimpl_get_context()
path = context.cfgimpl_get_description(
).impl_get_path_by_opt(opt_or_descr._opt)
path = context.cfgimpl_get_description().impl_get_path_by_opt(
opt_or_descr._opt)
return context._getattr(path, validate=validate,
force_properties=force_properties,
force_permissive=force_permissive)
elif isinstance(opt_or_descr, OptionDescription):
self.cfgimpl_get_settings().validate_properties(opt_or_descr,
True, False,
force_permissive=force_permissive,
force_properties=force_properties)
self.cfgimpl_get_settings().validate_properties(
opt_or_descr, True, False, force_permissive=force_permissive,
force_properties=force_properties)
return SubConfig(opt_or_descr, self.cfgimpl_get_context())
else:
return self.cfgimpl_get_values().getitem(opt_or_descr,
validate=validate,
force_properties=force_properties,
force_permissive=force_permissive)
return self.cfgimpl_get_values().getitem(
opt_or_descr,
validate=validate,
force_properties=force_properties,
force_permissive=force_permissive)
def find(self, bytype=None, byname=None, byvalue=None, type_='option'):
"""
@ -267,11 +266,9 @@ class SubConfig(BaseInformation):
:param byvalue: filter by the option's value
:returns: list of matching Option objects
"""
return self.cfgimpl_get_context()._find(bytype, byname, byvalue,
first=True,
type_=type_,
_subpath=self.cfgimpl_get_path(),
display_error=display_error)
return self.cfgimpl_get_context()._find(
bytype, byname, byvalue, first=True, type_=type_,
_subpath=self.cfgimpl_get_path(), display_error=display_error)
def _find(self, bytype, byname, byvalue, first, type_='option',
_subpath=None, check_properties=True, display_error=True):
@ -284,7 +281,7 @@ class SubConfig(BaseInformation):
def _filter_by_name():
try:
if byname is None or path == byname or \
path.endswith('.' + byname):
path.endswith('.' + byname):
return True
except IndexError:
pass
@ -422,9 +419,8 @@ class SubConfig(BaseInformation):
type_='path',
_subpath=mypath):
path = '.'.join(path.split('.')[:-1])
opt = self.cfgimpl_get_context(
).cfgimpl_get_description(
).impl_get_opt_by_path(path)
opt = self.cfgimpl_get_context().cfgimpl_get_description(
).impl_get_opt_by_path(path)
if mypath is not None:
if mypath == path:
withoption = None
@ -482,7 +478,7 @@ class CommonConfig(SubConfig):
config_id = gen_id(self)
import_lib = 'tiramisu.storage.{0}.storage'.format(storage_type)
return __import__(import_lib, globals(), locals(), ['Storage'],
-1).Storage(config_id, is_persistent)
-1).Storage(config_id, is_persistent)
def _impl_build_all_paths(self):
self.cfgimpl_get_description().impl_build_cache()
@ -511,8 +507,7 @@ class CommonConfig(SubConfig):
"""
if '.' in path:
homeconfig, path = self.cfgimpl_get_home_by_path(
path,
force_permissive=force_permissive)
path, force_permissive=force_permissive)
return getattr(homeconfig.cfgimpl_get_description(), path)
return getattr(self.cfgimpl_get_description(), path)
@ -658,8 +653,8 @@ def mandatory_warnings(config):
"""
#if value in cache, properties are not calculated
config.cfgimpl_reset_cache(only=('values',))
for path in config.cfgimpl_get_description(
).impl_getpaths(include_groups=True):
for path in config.cfgimpl_get_description().impl_getpaths(
include_groups=True):
try:
config._getattr(path, force_properties=frozenset(('mandatory',)))
except PropertiesOptionError, err: