pep8
This commit is contained in:
parent
acca6d5a27
commit
707a215a2c
@ -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:
|
||||
|
@ -185,12 +185,12 @@ class Settings(object):
|
||||
|
||||
def __init__(self, context, storage):
|
||||
"""
|
||||
initializer
|
||||
|
||||
initializer
|
||||
|
||||
:param context: the root config
|
||||
:param storage: the storage type
|
||||
|
||||
- dictionnary -> in memory
|
||||
:param storage: the storage type
|
||||
|
||||
- dictionnary -> in memory
|
||||
- sqlite3 -> persistent
|
||||
"""
|
||||
# generic owner
|
||||
@ -212,7 +212,7 @@ class Settings(object):
|
||||
#____________________________________________________________
|
||||
# properties methods
|
||||
def __contains__(self, propname):
|
||||
"enables the pythonic 'in' syntaxic sugar"
|
||||
"enables the pythonic 'in' syntaxic sugar"
|
||||
return propname in self._getproperties()
|
||||
|
||||
def __repr__(self):
|
||||
@ -332,7 +332,7 @@ class Settings(object):
|
||||
"").format(opt_or_descr._name,
|
||||
str(props)), props)
|
||||
|
||||
# XXX should rename it to setpermissive, but kept for retro compatibility
|
||||
# XXX should rename it to setpermissive, but kept for retro compatibility
|
||||
def set_permissive(self, permissive, opt=None):
|
||||
if not isinstance(permissive, tuple):
|
||||
raise TypeError(_('permissive must be a tuple'))
|
||||
|
Loading…
Reference in New Issue
Block a user