suppress _cfgimpl_parent and _cfgimpl_get_path() from SubConfig
This commit is contained in:
parent
88ea962d82
commit
d8b68fa1ec
|
@ -31,24 +31,20 @@ from tiramisu.value import Values
|
||||||
|
|
||||||
class SubConfig(object):
|
class SubConfig(object):
|
||||||
"sub configuration management entry"
|
"sub configuration management entry"
|
||||||
__slots__ = ('_cfgimpl_descr', '_cfgimpl_parent', '_cfgimpl_context')
|
__slots__ = ('_cfgimpl_descr', '_cfgimpl_context')
|
||||||
|
|
||||||
def __init__(self, descr, parent, context): # FIXME , slots):
|
def __init__(self, descr, context):
|
||||||
""" Configuration option management master class
|
""" Configuration option management master class
|
||||||
|
|
||||||
:param descr: describes the configuration schema
|
:param descr: describes the configuration schema
|
||||||
:type descr: an instance of ``option.OptionDescription``
|
:type descr: an instance of ``option.OptionDescription``
|
||||||
:param parent: parent's `Config`
|
|
||||||
:type parent: `Config`
|
|
||||||
:param context: the current root config
|
:param context: the current root config
|
||||||
:type context: `Config`
|
:type context: `Config`
|
||||||
"""
|
"""
|
||||||
# main option description
|
# main option description
|
||||||
self._cfgimpl_descr = descr
|
self._cfgimpl_descr = descr
|
||||||
# sub option descriptions
|
# sub option descriptions
|
||||||
self._cfgimpl_parent = parent
|
|
||||||
self._cfgimpl_context = context
|
self._cfgimpl_context = context
|
||||||
#self._cfgimpl_build(slots)
|
|
||||||
|
|
||||||
def cfgimpl_get_context(self):
|
def cfgimpl_get_context(self):
|
||||||
return self._cfgimpl_context
|
return self._cfgimpl_context
|
||||||
|
@ -133,7 +129,7 @@ class SubConfig(object):
|
||||||
"no attribute {2}".format(self.__class__,
|
"no attribute {2}".format(self.__class__,
|
||||||
opt_or_descr._name,
|
opt_or_descr._name,
|
||||||
name))
|
name))
|
||||||
return SubConfig(opt_or_descr, self, self._cfgimpl_context)
|
return SubConfig(opt_or_descr, self._cfgimpl_context)
|
||||||
# special attributes
|
# special attributes
|
||||||
if name.startswith('_cfgimpl_'):
|
if name.startswith('_cfgimpl_'):
|
||||||
# if it were in __dict__ it would have been found already
|
# if it were in __dict__ it would have been found already
|
||||||
|
@ -157,16 +153,6 @@ class SubConfig(object):
|
||||||
force_properties=force_properties)
|
force_properties=force_properties)
|
||||||
return self, path[-1]
|
return self, path[-1]
|
||||||
|
|
||||||
def _cfgimpl_get_path(self):
|
|
||||||
"the path in the attribute access meaning."
|
|
||||||
#FIXME optimisation
|
|
||||||
subpath = []
|
|
||||||
obj = self
|
|
||||||
while obj._cfgimpl_parent is not None:
|
|
||||||
subpath.insert(0, obj._cfgimpl_descr._name)
|
|
||||||
obj = obj._cfgimpl_parent
|
|
||||||
return ".".join(subpath)
|
|
||||||
|
|
||||||
def getkey(self):
|
def getkey(self):
|
||||||
return self._cfgimpl_descr.getkey(self)
|
return self._cfgimpl_descr.getkey(self)
|
||||||
|
|
||||||
|
@ -373,14 +359,12 @@ class Config(SubConfig):
|
||||||
|
|
||||||
:param descr: describes the configuration schema
|
:param descr: describes the configuration schema
|
||||||
:type descr: an instance of ``option.OptionDescription``
|
:type descr: an instance of ``option.OptionDescription``
|
||||||
:param parent: is None if the ``Config`` is root parent Config otherwise
|
|
||||||
:type parent: ``Config``
|
|
||||||
:param context: the current root config
|
:param context: the current root config
|
||||||
:type context: `Config`
|
:type context: `Config`
|
||||||
"""
|
"""
|
||||||
self._cfgimpl_settings = Setting()
|
self._cfgimpl_settings = Setting()
|
||||||
self._cfgimpl_values = Values(self)
|
self._cfgimpl_values = Values(self)
|
||||||
super(Config, self).__init__(descr, None, self) # , slots)
|
super(Config, self).__init__(descr, self) # , slots)
|
||||||
self._cfgimpl_build_all_paths()
|
self._cfgimpl_build_all_paths()
|
||||||
|
|
||||||
def _cfgimpl_build_all_paths(self):
|
def _cfgimpl_build_all_paths(self):
|
||||||
|
|
|
@ -574,10 +574,7 @@ def apply_requires(opt, config):
|
||||||
# filters the callbacks
|
# filters the callbacks
|
||||||
setting = config.cfgimpl_get_settings()
|
setting = config.cfgimpl_get_settings()
|
||||||
trigger_actions = build_actions(opt._requires)
|
trigger_actions = build_actions(opt._requires)
|
||||||
if isinstance(opt, OptionDescription):
|
optpath = config.cfgimpl_get_context().cfgimpl_get_description().get_path_by_opt(opt)
|
||||||
optpath = config._cfgimpl_get_path() + '.' + opt._name
|
|
||||||
else:
|
|
||||||
optpath = config.cfgimpl_get_context().cfgimpl_get_description().get_path_by_opt(opt)
|
|
||||||
for requires in trigger_actions.values():
|
for requires in trigger_actions.values():
|
||||||
matches = False
|
matches = False
|
||||||
for require in requires:
|
for require in requires:
|
||||||
|
|
Loading…
Reference in New Issue