pep8
This commit is contained in:
parent
acca6d5a27
commit
707a215a2c
|
@ -187,9 +187,8 @@ class SubConfig(BaseInformation):
|
||||||
force_permissive=force_permissive)
|
force_permissive=force_permissive)
|
||||||
else:
|
else:
|
||||||
context = self.cfgimpl_get_context()
|
context = self.cfgimpl_get_context()
|
||||||
path = context.\
|
path = context.cfgimpl_get_description().impl_get_path_by_opt(
|
||||||
cfgimpl_get_description().\
|
child._opt)
|
||||||
impl_get_path_by_opt(child._opt)
|
|
||||||
context._setattr(path, value, force_permissive=force_permissive)
|
context._setattr(path, value, force_permissive=force_permissive)
|
||||||
|
|
||||||
def __delattr__(self, name):
|
def __delattr__(self, name):
|
||||||
|
@ -210,9 +209,9 @@ class SubConfig(BaseInformation):
|
||||||
# attribute access by passing a path,
|
# attribute access by passing a path,
|
||||||
# for instance getattr(self, "creole.general.family.adresse_ip_eth0")
|
# for instance getattr(self, "creole.general.family.adresse_ip_eth0")
|
||||||
if '.' in name:
|
if '.' in name:
|
||||||
homeconfig, name = self.cfgimpl_get_home_by_path(name,
|
homeconfig, name = self.cfgimpl_get_home_by_path(
|
||||||
force_permissive=force_permissive,
|
name, force_permissive=force_permissive,
|
||||||
force_properties=force_properties)
|
force_properties=force_properties)
|
||||||
return homeconfig._getattr(name, force_permissive=force_permissive,
|
return homeconfig._getattr(name, force_permissive=force_permissive,
|
||||||
force_properties=force_properties,
|
force_properties=force_properties,
|
||||||
validate=validate)
|
validate=validate)
|
||||||
|
@ -225,22 +224,22 @@ class SubConfig(BaseInformation):
|
||||||
# symlink options
|
# symlink options
|
||||||
if isinstance(opt_or_descr, SymLinkOption):
|
if isinstance(opt_or_descr, SymLinkOption):
|
||||||
context = self.cfgimpl_get_context()
|
context = self.cfgimpl_get_context()
|
||||||
path = context.cfgimpl_get_description(
|
path = context.cfgimpl_get_description().impl_get_path_by_opt(
|
||||||
).impl_get_path_by_opt(opt_or_descr._opt)
|
opt_or_descr._opt)
|
||||||
return context._getattr(path, validate=validate,
|
return context._getattr(path, validate=validate,
|
||||||
force_properties=force_properties,
|
force_properties=force_properties,
|
||||||
force_permissive=force_permissive)
|
force_permissive=force_permissive)
|
||||||
elif isinstance(opt_or_descr, OptionDescription):
|
elif isinstance(opt_or_descr, OptionDescription):
|
||||||
self.cfgimpl_get_settings().validate_properties(opt_or_descr,
|
self.cfgimpl_get_settings().validate_properties(
|
||||||
True, False,
|
opt_or_descr, True, False, force_permissive=force_permissive,
|
||||||
force_permissive=force_permissive,
|
force_properties=force_properties)
|
||||||
force_properties=force_properties)
|
|
||||||
return SubConfig(opt_or_descr, self.cfgimpl_get_context())
|
return SubConfig(opt_or_descr, self.cfgimpl_get_context())
|
||||||
else:
|
else:
|
||||||
return self.cfgimpl_get_values().getitem(opt_or_descr,
|
return self.cfgimpl_get_values().getitem(
|
||||||
validate=validate,
|
opt_or_descr,
|
||||||
force_properties=force_properties,
|
validate=validate,
|
||||||
force_permissive=force_permissive)
|
force_properties=force_properties,
|
||||||
|
force_permissive=force_permissive)
|
||||||
|
|
||||||
def find(self, bytype=None, byname=None, byvalue=None, type_='option'):
|
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
|
: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, byname, byvalue,
|
return self.cfgimpl_get_context()._find(
|
||||||
first=True,
|
bytype, byname, byvalue, first=True, type_=type_,
|
||||||
type_=type_,
|
_subpath=self.cfgimpl_get_path(), display_error=display_error)
|
||||||
_subpath=self.cfgimpl_get_path(),
|
|
||||||
display_error=display_error)
|
|
||||||
|
|
||||||
def _find(self, bytype, byname, byvalue, first, type_='option',
|
def _find(self, bytype, byname, byvalue, first, type_='option',
|
||||||
_subpath=None, check_properties=True, display_error=True):
|
_subpath=None, check_properties=True, display_error=True):
|
||||||
|
@ -284,7 +281,7 @@ class SubConfig(BaseInformation):
|
||||||
def _filter_by_name():
|
def _filter_by_name():
|
||||||
try:
|
try:
|
||||||
if byname is None or path == byname or \
|
if byname is None or path == byname or \
|
||||||
path.endswith('.' + byname):
|
path.endswith('.' + byname):
|
||||||
return True
|
return True
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
@ -422,9 +419,8 @@ class SubConfig(BaseInformation):
|
||||||
type_='path',
|
type_='path',
|
||||||
_subpath=mypath):
|
_subpath=mypath):
|
||||||
path = '.'.join(path.split('.')[:-1])
|
path = '.'.join(path.split('.')[:-1])
|
||||||
opt = self.cfgimpl_get_context(
|
opt = self.cfgimpl_get_context().cfgimpl_get_description(
|
||||||
).cfgimpl_get_description(
|
).impl_get_opt_by_path(path)
|
||||||
).impl_get_opt_by_path(path)
|
|
||||||
if mypath is not None:
|
if mypath is not None:
|
||||||
if mypath == path:
|
if mypath == path:
|
||||||
withoption = None
|
withoption = None
|
||||||
|
@ -482,7 +478,7 @@ class CommonConfig(SubConfig):
|
||||||
config_id = gen_id(self)
|
config_id = gen_id(self)
|
||||||
import_lib = 'tiramisu.storage.{0}.storage'.format(storage_type)
|
import_lib = 'tiramisu.storage.{0}.storage'.format(storage_type)
|
||||||
return __import__(import_lib, globals(), locals(), ['Storage'],
|
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):
|
def _impl_build_all_paths(self):
|
||||||
self.cfgimpl_get_description().impl_build_cache()
|
self.cfgimpl_get_description().impl_build_cache()
|
||||||
|
@ -511,8 +507,7 @@ class CommonConfig(SubConfig):
|
||||||
"""
|
"""
|
||||||
if '.' in path:
|
if '.' in path:
|
||||||
homeconfig, path = self.cfgimpl_get_home_by_path(
|
homeconfig, path = self.cfgimpl_get_home_by_path(
|
||||||
path,
|
path, force_permissive=force_permissive)
|
||||||
force_permissive=force_permissive)
|
|
||||||
return getattr(homeconfig.cfgimpl_get_description(), path)
|
return getattr(homeconfig.cfgimpl_get_description(), path)
|
||||||
return getattr(self.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
|
#if value in cache, properties are not calculated
|
||||||
config.cfgimpl_reset_cache(only=('values',))
|
config.cfgimpl_reset_cache(only=('values',))
|
||||||
for path in config.cfgimpl_get_description(
|
for path in config.cfgimpl_get_description().impl_getpaths(
|
||||||
).impl_getpaths(include_groups=True):
|
include_groups=True):
|
||||||
try:
|
try:
|
||||||
config._getattr(path, force_properties=frozenset(('mandatory',)))
|
config._getattr(path, force_properties=frozenset(('mandatory',)))
|
||||||
except PropertiesOptionError, err:
|
except PropertiesOptionError, err:
|
||||||
|
|
|
@ -185,12 +185,12 @@ class Settings(object):
|
||||||
|
|
||||||
def __init__(self, context, storage):
|
def __init__(self, context, storage):
|
||||||
"""
|
"""
|
||||||
initializer
|
initializer
|
||||||
|
|
||||||
:param context: the root config
|
:param context: the root config
|
||||||
:param storage: the storage type
|
:param storage: the storage type
|
||||||
|
|
||||||
- dictionnary -> in memory
|
- dictionnary -> in memory
|
||||||
- sqlite3 -> persistent
|
- sqlite3 -> persistent
|
||||||
"""
|
"""
|
||||||
# generic owner
|
# generic owner
|
||||||
|
@ -212,7 +212,7 @@ class Settings(object):
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
# properties methods
|
# properties methods
|
||||||
def __contains__(self, propname):
|
def __contains__(self, propname):
|
||||||
"enables the pythonic 'in' syntaxic sugar"
|
"enables the pythonic 'in' syntaxic sugar"
|
||||||
return propname in self._getproperties()
|
return propname in self._getproperties()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -332,7 +332,7 @@ class Settings(object):
|
||||||
"").format(opt_or_descr._name,
|
"").format(opt_or_descr._name,
|
||||||
str(props)), props)
|
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):
|
def set_permissive(self, permissive, opt=None):
|
||||||
if not isinstance(permissive, tuple):
|
if not isinstance(permissive, tuple):
|
||||||
raise TypeError(_('permissive must be a tuple'))
|
raise TypeError(_('permissive must be a tuple'))
|
||||||
|
|
Loading…
Reference in New Issue