remove _cache_paths (path is now directly in option)
better TiramisuAPI support
This commit is contained in:
@ -113,7 +113,7 @@ class CommonTiramisu(TiramisuHelp):
|
||||
if option is None:
|
||||
option = self.subconfig.cfgimpl_get_description().impl_getchild(self._name,
|
||||
self.option_bag.config_bag,
|
||||
self.subconfig)
|
||||
self.subconfig.cfgimpl_get_path())
|
||||
self.option_bag.set_option(option,
|
||||
self.option_bag.path,
|
||||
self.option_bag.index,
|
||||
@ -145,8 +145,8 @@ class CommonTiramisuOption(CommonTiramisu):
|
||||
self.option_bag = option_bag
|
||||
self._name = name
|
||||
self.subconfig = subconfig
|
||||
# for help()
|
||||
if option_bag is not None:
|
||||
# for help()
|
||||
self._get_option()
|
||||
if option_bag.config_bag is not None and self.slave_need_index:
|
||||
self._test_slave_index()
|
||||
@ -548,11 +548,21 @@ class TiramisuOption(CommonTiramisu):
|
||||
"""find an option by name (only for optiondescription)"""
|
||||
if not first:
|
||||
ret = []
|
||||
for path in self.config_bag.context.find(byname=name,
|
||||
byvalue=value,
|
||||
bytype=type,
|
||||
_subpath=self._path,
|
||||
config_bag=self.config_bag):
|
||||
option = self._get_option()
|
||||
oname = option.impl_getname()
|
||||
path = self.subconfig._get_subpath(oname)
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
None,
|
||||
self.config_bag)
|
||||
subconfig = self.subconfig.get_subconfig(oname,
|
||||
option_bag)
|
||||
for path in subconfig.find(byname=name,
|
||||
byvalue=value,
|
||||
bytype=type,
|
||||
_subpath=self._path,
|
||||
config_bag=self.config_bag):
|
||||
subconfig, name = self.config_bag.context.cfgimpl_get_home_by_path(path,
|
||||
self.config_bag)
|
||||
t_option = TiramisuOption(name,
|
||||
@ -569,7 +579,7 @@ class TiramisuOption(CommonTiramisu):
|
||||
self._get_option()
|
||||
current_option = self.option_bag.option.impl_getchild(name,
|
||||
self.config_bag,
|
||||
self.subconfig)
|
||||
self.subconfig.cfgimpl_get_path)
|
||||
path = self.option_bag.path + '.' + name
|
||||
option_bag= OptionBag()
|
||||
option_bag.set_option(current_option,
|
||||
@ -614,8 +624,8 @@ class TiramisuOption(CommonTiramisu):
|
||||
self.subconfig.get_subconfig(name,
|
||||
option_bag)
|
||||
else:
|
||||
self.subconfig.getattr(name,
|
||||
option_bag)
|
||||
subconfig.getattr(name,
|
||||
option_bag)
|
||||
|
||||
option = self._get_option()
|
||||
name = option.impl_getname()
|
||||
@ -738,10 +748,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
"""set configuration to read only mode"""
|
||||
settings = self.config_bag.context.cfgimpl_get_settings()
|
||||
settings.read_only(self.config_bag.context)
|
||||
try:
|
||||
del self.config_bag.properties
|
||||
except AttributeError:
|
||||
pass
|
||||
del self.config_bag.properties
|
||||
|
||||
def read_write(self):
|
||||
"""set configuration to read and write mode"""
|
||||
@ -750,17 +757,15 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
# #FIXME ?
|
||||
permissives = frozenset(settings.get_context_permissives() | frozenset(['hidden']))
|
||||
settings.set_context_permissives(permissives)
|
||||
try:
|
||||
del self.config_bag.properties
|
||||
except AttributeError:
|
||||
pass
|
||||
#/FIXME ?
|
||||
del self.config_bag.properties
|
||||
|
||||
def add(self, prop):
|
||||
"""add a configuration property"""
|
||||
props = self.get()
|
||||
props.add(prop)
|
||||
self.set(frozenset(props))
|
||||
del self.config_bag.properties
|
||||
|
||||
def pop(self, prop):
|
||||
"""remove a configuration property"""
|
||||
@ -768,6 +773,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
if prop in props:
|
||||
props.remove(prop)
|
||||
self.set(frozenset(props))
|
||||
del self.config_bag.properties
|
||||
|
||||
def get(self):
|
||||
"""get all configuration properties"""
|
||||
@ -778,12 +784,14 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
context = self.config_bag.context
|
||||
context.cfgimpl_get_settings().set_context_properties(props,
|
||||
context)
|
||||
del self.config_bag.properties
|
||||
|
||||
def reset(self):
|
||||
"""remove configuration properties"""
|
||||
context = self.config_bag.context
|
||||
context.cfgimpl_get_settings().reset(None,
|
||||
context)
|
||||
del self.config_bag.properties
|
||||
|
||||
def exportation(self):
|
||||
"""export configuration properties"""
|
||||
@ -794,6 +802,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
self.config_bag.context.cfgimpl_get_settings()._p_.importation(properties)
|
||||
self.config_bag.context.cfgimpl_reset_cache(None,
|
||||
None)
|
||||
del self.config_bag.properties
|
||||
|
||||
|
||||
class TiramisuContextPermissive(TiramisuContext):
|
||||
@ -806,6 +815,7 @@ class TiramisuContextPermissive(TiramisuContext):
|
||||
def set(self, permissives):
|
||||
"""set configuration permissives"""
|
||||
self.config_bag.context.cfgimpl_get_settings().set_context_permissives(permissives)
|
||||
del self.config_bag.permissives
|
||||
|
||||
def exportation(self):
|
||||
"""export configuration permissives"""
|
||||
@ -816,6 +826,7 @@ class TiramisuContextPermissive(TiramisuContext):
|
||||
self.config_bag.context.cfgimpl_get_settings()._pp_.importation(permissives)
|
||||
self.config_bag.context.cfgimpl_reset_cache(None,
|
||||
None)
|
||||
del self.config_bag.permissives
|
||||
|
||||
|
||||
|
||||
@ -918,9 +929,9 @@ class TiramisuContextConfig(TiramisuContext):
|
||||
first: bool=False):
|
||||
"""find a path from option name and optionnaly a value to MetaConfig or GroupConfig"""
|
||||
if first:
|
||||
return TiramisuAPI(self.config_bag.context.find_firsts(byname=name,
|
||||
byvalue=value,
|
||||
config_bag=self.config_bag))
|
||||
return Config(self.config_bag.context.find_firsts(byname=name,
|
||||
byvalue=value,
|
||||
config_bag=self.config_bag))
|
||||
else:
|
||||
raise APIError('not implemented yet')
|
||||
|
||||
@ -929,25 +940,25 @@ class TiramisuContextConfig(TiramisuContext):
|
||||
|
||||
def _c_copy(self,
|
||||
session_id=None):
|
||||
return TiramisuAPI(self.config_bag.context.duplicate(session_id))
|
||||
return Config(self.config_bag.context.duplicate(session_id))
|
||||
|
||||
def _c_deepcopy(self,
|
||||
session_id=None):
|
||||
return TiramisuAPI(self.config_bag.context.duplicate(session_id,
|
||||
deep=True))
|
||||
return Config(self.config_bag.context.duplicate(session_id,
|
||||
deep=True))
|
||||
|
||||
def _c_meta(self):
|
||||
return TiramisuAPI(self.config_bag.context.cfgimpl_get_meta())
|
||||
return Config(self.config_bag.context.cfgimpl_get_meta())
|
||||
|
||||
def _m_new(self, name):
|
||||
return TiramisuAPI(self.config_bag.context.new_config(name))
|
||||
return Config(self.config_bag.context.new_config(name))
|
||||
|
||||
def _m_list(self):
|
||||
return self._g_list()
|
||||
|
||||
def _g_list(self):
|
||||
for child in self.config_bag.context.cfgimpl_get_children():
|
||||
yield TiramisuAPI(child)
|
||||
yield Config(child)
|
||||
|
||||
def __getattr__(self,
|
||||
name: str) -> Callable:
|
||||
@ -990,32 +1001,25 @@ class TiramisuAPI(TiramisuHelp):
|
||||
|
||||
def __init__(self,
|
||||
config) -> None:
|
||||
self._config = config
|
||||
if not isinstance(config, ConfigBag):
|
||||
config = ConfigBag(context=config)
|
||||
self._config_bag = config
|
||||
if not self.registers:
|
||||
registers(self.registers, 'TiramisuContext')
|
||||
registers(self.registers, 'TiramisuDispatcher')
|
||||
|
||||
def __getattr__(self, subfunc: str) -> Any:
|
||||
if subfunc == 'forcepermissive':
|
||||
if isinstance(self._config, ConfigBag):
|
||||
config_bag = self._config.copy()
|
||||
del config_bag.properties
|
||||
else:
|
||||
config_bag = ConfigBag(context=self._config)
|
||||
config_bag = self._config_bag.copy()
|
||||
config_bag.set_permissive()
|
||||
return TiramisuAPI(config_bag)
|
||||
elif subfunc == 'unrestraint':
|
||||
if isinstance(self._config, ConfigBag):
|
||||
config_bag = self._config.copy()
|
||||
else:
|
||||
config_bag = ConfigBag(context=self._config)
|
||||
config_bag = self._config_bag.copy()
|
||||
config_bag.properties = frozenset()
|
||||
return TiramisuAPI(config_bag)
|
||||
elif subfunc in self.registers:
|
||||
if not isinstance(self._config, ConfigBag):
|
||||
config_bag = ConfigBag(context=self._config)
|
||||
else:
|
||||
config_bag = self._config
|
||||
config_bag = self._config_bag
|
||||
del config_bag.permissives
|
||||
return self.registers[subfunc](config_bag)
|
||||
else:
|
||||
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
||||
@ -1055,7 +1059,7 @@ class Config(TiramisuAPI):
|
||||
session_id: str=None,
|
||||
persistent: bool=False,
|
||||
storage=None) -> None:
|
||||
if not isinstance(descr, (KernelConfig, KernelMetaConfig)):
|
||||
if isinstance(descr, OptionDescription):
|
||||
config = KernelConfig(descr,
|
||||
session_id=session_id,
|
||||
persistent=persistent,
|
||||
@ -1075,7 +1079,7 @@ class MetaConfig(TiramisuAPI):
|
||||
_children = []
|
||||
for child in children:
|
||||
if isinstance(child, TiramisuAPI):
|
||||
_children.append(child._config)
|
||||
_children.append(child._config_bag.context)
|
||||
else:
|
||||
_children.append(child)
|
||||
|
||||
@ -1095,7 +1099,7 @@ class GroupConfig(TiramisuAPI):
|
||||
storage=None) -> None:
|
||||
_children = []
|
||||
for child in children:
|
||||
_children.append(child._config)
|
||||
_children.append(child._config_bag.context)
|
||||
|
||||
config = KernelGroupConfig(_children,
|
||||
session_id=session_id,
|
||||
|
@ -199,7 +199,7 @@ class SubConfig(object):
|
||||
option_bag = OptionBag()
|
||||
option = self.cfgimpl_get_description().impl_getchild(step,
|
||||
config_bag,
|
||||
self)
|
||||
self.cfgimpl_get_path())
|
||||
subpath = self._get_subpath(step)
|
||||
option_bag.set_option(option,
|
||||
subpath,
|
||||
@ -371,7 +371,7 @@ class SubConfig(object):
|
||||
"""
|
||||
def _filter_by_value(soption_bag):
|
||||
try:
|
||||
value = self.getattr(path,
|
||||
value = context.getattr(path,
|
||||
soption_bag)
|
||||
except PropertiesOptionError:
|
||||
return False
|
||||
@ -386,8 +386,10 @@ class SubConfig(object):
|
||||
else:
|
||||
options = self.cfgimpl_get_description().impl_get_options_paths(bytype,
|
||||
byname,
|
||||
_subpath,
|
||||
self.cfgimpl_get_path(),
|
||||
config_bag)
|
||||
options = list(options)
|
||||
context = self.cfgimpl_get_context()
|
||||
for path, option in options:
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
@ -400,14 +402,14 @@ class SubConfig(object):
|
||||
#remove option with propertyerror, ...
|
||||
try:
|
||||
if '.' in path:
|
||||
subconfig, subpath = self.cfgimpl_get_home_by_path(path,
|
||||
subconfig, subpath = context.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
else:
|
||||
subconfig = self
|
||||
subpath = path
|
||||
subconfig.cfgimpl_get_description().impl_getchild(subpath,
|
||||
config_bag,
|
||||
subconfig)
|
||||
subconfig.cfgimpl_get_path())
|
||||
self.cfgimpl_get_settings().validate_properties(option_bag)
|
||||
except PropertiesOptionError:
|
||||
continue
|
||||
@ -508,7 +510,7 @@ class SubConfig(object):
|
||||
subpath = path
|
||||
opt = subconfig.cfgimpl_get_description().impl_getchild(subpath,
|
||||
config_bag,
|
||||
subconfig)
|
||||
subconfig.cfgimpl_get_path())
|
||||
soption_bag = OptionBag()
|
||||
soption_bag.set_option(opt,
|
||||
path,
|
||||
@ -874,7 +876,7 @@ class KernelGroupConfig(_CommonConfig):
|
||||
cconfig_bag)
|
||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||
cconfig_bag,
|
||||
child)
|
||||
child.cfgimpl_get_path())
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
@ -919,7 +921,8 @@ class KernelGroupConfig(_CommonConfig):
|
||||
config_bag=config_bag,
|
||||
raise_if_not_found=raise_if_not_found))
|
||||
byname = None
|
||||
byoption = self.cfgimpl_get_description().impl_get_opt_by_path(bypath)
|
||||
byoption = self.cfgimpl_get_description().impl_get_opt_by_path(bypath,
|
||||
config_bag)
|
||||
|
||||
ret = []
|
||||
for child in self._impl_children:
|
||||
@ -1040,7 +1043,8 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||
if force_default and force_dont_change_value:
|
||||
raise ValueError(_('force_default and force_dont_change_value'
|
||||
' cannot be set together'))
|
||||
opt = self.cfgimpl_get_description().impl_get_opt_by_path(path)
|
||||
opt = self.cfgimpl_get_description().impl_get_opt_by_path(path,
|
||||
config_bag)
|
||||
for child in self._impl_children:
|
||||
cconfig_bag = config_bag.copy()
|
||||
cconfig_bag.context = child
|
||||
@ -1048,7 +1052,7 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||
cconfig_bag)
|
||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||
cconfig_bag,
|
||||
child)
|
||||
child.cfgimpl_get_path())
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
@ -1080,7 +1084,7 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||
config_bag)
|
||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||
config_bag,
|
||||
self)
|
||||
self.cfgimpl_get_path())
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
@ -1102,7 +1106,7 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||
config_bag)
|
||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||
config_bag,
|
||||
self)
|
||||
self.cfgimpl_get_path())
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
|
@ -30,7 +30,7 @@ from ..error import ConfigError, ConflictError
|
||||
|
||||
|
||||
class CacheOptionDescription(BaseOption):
|
||||
__slots__ = ('_cache_paths', '_cache_consistencies', '_cache_force_store_values')
|
||||
__slots__ = ('_cache_consistencies', '_cache_force_store_values')
|
||||
|
||||
def _build_cache(self,
|
||||
config,
|
||||
@ -154,7 +154,7 @@ class CacheOptionDescription(BaseOption):
|
||||
self._set_readonly()
|
||||
|
||||
def impl_already_build_caches(self):
|
||||
if hasattr(self, '_cache_paths'):
|
||||
if hasattr(self, '_cache_consistencies'):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -192,11 +192,10 @@ class CacheOptionDescription(BaseOption):
|
||||
values._p_.commit()
|
||||
|
||||
def _build_cache_option(self,
|
||||
_currpath=None,
|
||||
cache_path=None,
|
||||
cache_option=None):
|
||||
_currpath=None):
|
||||
|
||||
if self.impl_is_readonly() or (_currpath is None and getattr(self, '_cache_paths', None) is not None):
|
||||
if self.impl_is_readonly() or \
|
||||
(_currpath is None and getattr(self, '_cache_consistencies', None) is not None):
|
||||
# cache already set
|
||||
return
|
||||
if _currpath is None:
|
||||
@ -204,24 +203,17 @@ class CacheOptionDescription(BaseOption):
|
||||
_currpath = []
|
||||
else:
|
||||
save = False
|
||||
if cache_path is None:
|
||||
cache_path = []
|
||||
cache_option = []
|
||||
for option in self.impl_getchildren(config_bag=undefined,
|
||||
dyn=False):
|
||||
attr = option.impl_getname()
|
||||
path = str('.'.join(_currpath + [attr]))
|
||||
cache_option.append(option)
|
||||
cache_path.append(path)
|
||||
option._path = path
|
||||
if option.impl_is_optiondescription():
|
||||
_currpath.append(attr)
|
||||
option._build_cache_option(_currpath,
|
||||
cache_path,
|
||||
cache_option)
|
||||
option._build_cache_option(_currpath)
|
||||
_currpath.pop()
|
||||
if save:
|
||||
self._cache_paths = (tuple(cache_option), tuple(cache_path))
|
||||
if save and not hasattr(self, '_cache_consistencies'):
|
||||
self._cache_consistencies = None
|
||||
|
||||
|
||||
class OptionDescriptionWalk(CacheOptionDescription):
|
||||
@ -248,57 +240,43 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||
bytype,
|
||||
byname,
|
||||
_subpath,
|
||||
config_bag):
|
||||
def _filter_by_type(path,
|
||||
option):
|
||||
if isinstance(option,
|
||||
bytype):
|
||||
return _filter_by_name(path, option)
|
||||
config_bag,
|
||||
self_opt=None):
|
||||
if self_opt is None:
|
||||
self_opt = self
|
||||
def _filter_by_name(option):
|
||||
return byname is None or option.impl_getname() == byname
|
||||
|
||||
def _filter_by_name(path,
|
||||
option):
|
||||
name = option.impl_getname()
|
||||
if option.issubdyn():
|
||||
if byname.startswith(name):
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
None,
|
||||
config_bag)
|
||||
for doption in self.build_dynoptions(option_bag):
|
||||
if byname == doption.impl_getname():
|
||||
dpath = doption.impl_getpath()
|
||||
return (dpath, doption)
|
||||
elif byname == name:
|
||||
return (path, option)
|
||||
|
||||
def _filter(path, option):
|
||||
if bytype is not None:
|
||||
return _filter_by_type(path, option)
|
||||
return _filter_by_name(path, option)
|
||||
|
||||
opts, paths = self._cache_paths
|
||||
for index, option in enumerate(opts):
|
||||
for option in self_opt.impl_getchildren(config_bag):
|
||||
if _subpath is None:
|
||||
path = option.impl_getname()
|
||||
else:
|
||||
path = _subpath + '.' + option.impl_getname()
|
||||
if option.impl_is_optiondescription():
|
||||
continue
|
||||
path = paths[index]
|
||||
if _subpath is not None and not path.startswith(_subpath + '.'):
|
||||
continue
|
||||
ret = _filter(path, option)
|
||||
if ret:
|
||||
yield ret
|
||||
for subopt in option.impl_get_options_paths(bytype,
|
||||
byname,
|
||||
path,
|
||||
config_bag):
|
||||
yield subopt
|
||||
else:
|
||||
if bytype is not None:
|
||||
if isinstance(option, bytype) and \
|
||||
_filter_by_name(option):
|
||||
yield (path, option)
|
||||
elif _filter_by_name(option):
|
||||
yield (path, option)
|
||||
|
||||
def impl_getchild(self,
|
||||
name,
|
||||
config_bag,
|
||||
subconfig):
|
||||
subpath):
|
||||
if name in self._children[0]:
|
||||
child = self._children[1][self._children[0].index(name)]
|
||||
if not child.impl_is_dynoptiondescription():
|
||||
return child
|
||||
else:
|
||||
child = self._impl_search_dynchild(name,
|
||||
subconfig,
|
||||
subpath,
|
||||
config_bag)
|
||||
if child:
|
||||
return child
|
||||
@ -307,12 +285,19 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||
'').format(name, self.impl_getname()))
|
||||
|
||||
def impl_get_opt_by_path(self,
|
||||
path):
|
||||
return self._cache_paths[0][self._cache_paths[1].index(path)]
|
||||
|
||||
def impl_get_path_by_opt(self,
|
||||
opt):
|
||||
return self._cache_paths[1][self._cache_paths[0].index(opt)]
|
||||
path,
|
||||
config_bag):
|
||||
opt = self
|
||||
subpath = None
|
||||
for step in path.split('.'):
|
||||
opt = opt.impl_getchild(step,
|
||||
config_bag,
|
||||
subpath)
|
||||
if subpath is None:
|
||||
subpath = step
|
||||
else:
|
||||
subpath += '.' + step
|
||||
return opt
|
||||
|
||||
def impl_getchildren(self,
|
||||
config_bag,
|
||||
@ -347,7 +332,7 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||
|
||||
def _impl_search_dynchild(self,
|
||||
name,
|
||||
subconfig,
|
||||
subpath,
|
||||
config_bag):
|
||||
for child in self._impl_st_getchildren(only_dyn=True):
|
||||
#sconfig_bag = config_bag.copy('nooption')
|
||||
@ -356,13 +341,13 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||
if name.startswith(cname):
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(child,
|
||||
subconfig.cfgimpl_get_path(),
|
||||
subpath,
|
||||
None,
|
||||
config_bag)
|
||||
for value in child.impl_get_suffixes(option_bag):
|
||||
if name == cname + value:
|
||||
return SynDynOptionDescription(child,
|
||||
subconfig.cfgimpl_get_path(),
|
||||
subpath,
|
||||
value)
|
||||
|
||||
def _impl_get_dynchild(self,
|
||||
@ -424,7 +409,7 @@ class OptionDescription(OptionDescriptionWalk):
|
||||
'the dynoptiondescription\'s name "{}"').format(child, dynopt))
|
||||
old = child
|
||||
self._children = children_
|
||||
self._cache_consistencies = None
|
||||
#self._cache_consistencies = None
|
||||
# the group_type is useful for filtering OptionDescriptions in a config
|
||||
self._group_type = groups.default
|
||||
|
||||
|
@ -44,14 +44,14 @@ class SynDynOptionDescription(object):
|
||||
def impl_getchild(self,
|
||||
name,
|
||||
config_bag,
|
||||
subconfig):
|
||||
subpath):
|
||||
try:
|
||||
if name.endswith(self._suffix):
|
||||
oname = name[:-len(self._suffix)]
|
||||
child = self._children[1][self._children[0].index(oname)]
|
||||
return self._impl_get_dynchild(child,
|
||||
self._suffix,
|
||||
subconfig.cfgimpl_get_path())
|
||||
subpath)
|
||||
except ValueError:
|
||||
# when oname not in self._children
|
||||
pass
|
||||
@ -72,6 +72,17 @@ class SynDynOptionDescription(object):
|
||||
self._suffix,
|
||||
subpath))
|
||||
|
||||
def impl_get_options_paths(self,
|
||||
bytype,
|
||||
byname,
|
||||
_subpath,
|
||||
config_bag):
|
||||
return self._opt.impl_get_options_paths(bytype,
|
||||
byname,
|
||||
_subpath,
|
||||
config_bag,
|
||||
self)
|
||||
|
||||
def impl_getpath(self):
|
||||
subpath = self._subpath
|
||||
if subpath != '':
|
||||
|
@ -175,7 +175,6 @@ class ConfigBag:
|
||||
'permissives', # permissives for current context
|
||||
)
|
||||
def __init__(self, context, **kwargs):
|
||||
#self.force_permissive = False
|
||||
self.context = context
|
||||
for key, value in kwargs.items():
|
||||
setattr(self, key, value)
|
||||
@ -196,10 +195,17 @@ class ConfigBag:
|
||||
self.properties = frozenset(self.properties | {'permissive'})
|
||||
|
||||
def __delattr__(self, key):
|
||||
if key == 'properties':
|
||||
if key in ['properties', 'permissives']:
|
||||
try:
|
||||
super().__delattr__(key)
|
||||
except AttributeError:
|
||||
pass
|
||||
return
|
||||
raise KeyError('unknown key {} for ConfigBag'.format(key))
|
||||
|
||||
#def __setattr__(self, key, value):
|
||||
# super().__setattr__(key, value)
|
||||
|
||||
def copy(self):
|
||||
kwargs = {}
|
||||
for key in self.__slots__:
|
||||
|
Reference in New Issue
Block a user