From d8b68fa1ec37b12f23ccfe3b67f1919ad5beb566 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 5 Apr 2013 16:59:48 +0200 Subject: [PATCH] suppress _cfgimpl_parent and _cfgimpl_get_path() from SubConfig --- tiramisu/config.py | 24 ++++-------------------- tiramisu/option.py | 5 +---- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/tiramisu/config.py b/tiramisu/config.py index d255bf3..d0b870c 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -31,24 +31,20 @@ from tiramisu.value import Values class SubConfig(object): "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 :param descr: describes the configuration schema :type descr: an instance of ``option.OptionDescription`` - :param parent: parent's `Config` - :type parent: `Config` :param context: the current root config :type context: `Config` """ # main option description self._cfgimpl_descr = descr # sub option descriptions - self._cfgimpl_parent = parent self._cfgimpl_context = context - #self._cfgimpl_build(slots) def cfgimpl_get_context(self): return self._cfgimpl_context @@ -133,7 +129,7 @@ class SubConfig(object): "no attribute {2}".format(self.__class__, opt_or_descr._name, name)) - return SubConfig(opt_or_descr, self, self._cfgimpl_context) + return SubConfig(opt_or_descr, self._cfgimpl_context) # special attributes if name.startswith('_cfgimpl_'): # if it were in __dict__ it would have been found already @@ -157,16 +153,6 @@ class SubConfig(object): force_properties=force_properties) 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): return self._cfgimpl_descr.getkey(self) @@ -373,14 +359,12 @@ class Config(SubConfig): :param descr: describes the configuration schema :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 :type context: `Config` """ self._cfgimpl_settings = Setting() 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() def _cfgimpl_build_all_paths(self): diff --git a/tiramisu/option.py b/tiramisu/option.py index 5b9b222..04f0c10 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -574,10 +574,7 @@ def apply_requires(opt, config): # filters the callbacks setting = config.cfgimpl_get_settings() trigger_actions = build_actions(opt._requires) - if isinstance(opt, OptionDescription): - optpath = config._cfgimpl_get_path() + '.' + opt._name - else: - optpath = config.cfgimpl_get_context().cfgimpl_get_description().get_path_by_opt(opt) + optpath = config.cfgimpl_get_context().cfgimpl_get_description().get_path_by_opt(opt) for requires in trigger_actions.values(): matches = False for require in requires: