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,8 +209,8 @@ 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,
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,
@ -225,19 +224,19 @@ 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,
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,
return self.cfgimpl_get_values().getitem(
opt_or_descr,
validate=validate,
force_properties=force_properties,
force_permissive=force_permissive)
@ -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):
@ -422,8 +419,7 @@ class SubConfig(BaseInformation):
type_='path',
_subpath=mypath):
path = '.'.join(path.split('.')[:-1])
opt = self.cfgimpl_get_context(
).cfgimpl_get_description(
opt = self.cfgimpl_get_context().cfgimpl_get_description(
).impl_get_opt_by_path(path)
if mypath is not None:
if mypath == path:
@ -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: