From 09c9fa49068f0f4f70d0311a4fa419ee2a14b58d Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 6 Sep 2018 23:16:17 +0200 Subject: [PATCH] context is not needed for impl_getpath --- tiramisu/autolib.py | 2 +- tiramisu/config.py | 18 ++++++------------ tiramisu/option/baseoption.py | 4 +--- tiramisu/option/dynoptiondescription.py | 2 +- tiramisu/option/dynsymlinkoption.py | 5 ++--- tiramisu/option/masterslaves.py | 10 ++++------ tiramisu/option/option.py | 2 +- tiramisu/option/optiondescription.py | 9 ++++----- tiramisu/option/syndynoptiondescription.py | 8 ++++---- tiramisu/setting.py | 8 ++++---- tiramisu/value.py | 4 ++-- 11 files changed, 30 insertions(+), 42 deletions(-) diff --git a/tiramisu/autolib.py b/tiramisu/autolib.py index 2fbba59..ee02fe1 100644 --- a/tiramisu/autolib.py +++ b/tiramisu/autolib.py @@ -50,7 +50,7 @@ def manager_callback(callbk: Union[ParamOption, ParamValue], if opt.issubdyn(): opt = opt.impl_get_dynoption(option._rootpath, option.impl_getsuffix()) - path = opt.impl_getpath(context) + path = opt.impl_getpath() if index is not None and opt.impl_is_master_slaves() and \ opt.impl_get_master_slaves().in_same_group(option): if opt == option: diff --git a/tiramisu/config.py b/tiramisu/config.py index f638ecb..cdeb385 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -96,12 +96,7 @@ class SubConfig(object): option_bag): if option_bag.option.impl_is_symlinkoption(): context = self.cfgimpl_get_context() - #soption_bag = OptionBag() - #soption_bag.set_option(option_bag.option.impl_getopt(), - # option_bag.option.impl_getopt().impl_getpath(context), - # None, - # option_bag.config_bag) - path = option_bag.option.impl_getopt().impl_getpath(context) + path = option_bag.option.impl_getopt().impl_getpath() subconfig, _ = context.cfgimpl_get_home_by_path(path, option_bag.config_bag) return subconfig.cfgimpl_get_length() @@ -123,7 +118,7 @@ class SubConfig(object): if option.impl_is_dynoptiondescription(): for doption in option.get_syndynoptiondescriptions(option_bag, remove_none=True): - doption_path = doption.impl_getpath(self) + doption_path = doption.impl_getpath() doption_bag = OptionBag() doption_bag.set_option(doption, doption_path, @@ -136,13 +131,13 @@ class SubConfig(object): doption_bag) elif option.issubdyn(): doption_bag = OptionBag() - doption_path = option.impl_getpath(self) + doption_path = option.impl_getpath() doption_bag.set_option(option, doption_path, option_bag.index, option_bag.config_bag) for doption in desc.build_dynoptions(doption_bag): - doption_path = doption.impl_getpath(self) + doption_path = doption.impl_getpath() doption_bag = OptionBag() doption_bag.set_option(doption, doption_path, @@ -154,7 +149,7 @@ class SubConfig(object): resetted_opts, doption_bag) else: - option_path = option.impl_getpath(self) + option_path = option.impl_getpath() doption_bag = OptionBag() doption_bag.set_option(option, option_path, @@ -625,8 +620,7 @@ class SubConfig(object): dyn=True): descr = self.cfgimpl_get_description() if not dyn and descr.impl_is_dynoptiondescription(): - context_descr = self.cfgimpl_get_context().cfgimpl_get_description() - return descr.impl_getopt().impl_getpath(context_descr) + return descr.impl_getopt().impl_getpath() return self._impl_path diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index c696fb1..82b77f8 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -415,10 +415,8 @@ class BaseOption(Base): name)) super(BaseOption, self).__setattr__(name, value) - def impl_getpath(self, - context): + def impl_getpath(self): return self._path - #return context.cfgimpl_get_description().impl_get_path_by_opt(self) def impl_has_callback(self): "to know if a callback has been defined or not" diff --git a/tiramisu/option/dynoptiondescription.py b/tiramisu/option/dynoptiondescription.py index d819045..a328425 100644 --- a/tiramisu/option/dynoptiondescription.py +++ b/tiramisu/option/dynoptiondescription.py @@ -105,7 +105,7 @@ class DynOptionDescription(OptionDescription): def get_syndynoptiondescriptions(self, option_bag, remove_none=False): - subpath = self.impl_getpath(option_bag.config_bag.context).rsplit('.', 1)[0] + subpath = self.impl_getpath().rsplit('.', 1)[0] for suffix in self.impl_get_suffixes(option_bag, remove_none=remove_none): yield SynDynOptionDescription(self, diff --git a/tiramisu/option/dynsymlinkoption.py b/tiramisu/option/dynsymlinkoption.py index 86e0c8b..e6b0066 100644 --- a/tiramisu/option/dynsymlinkoption.py +++ b/tiramisu/option/dynsymlinkoption.py @@ -57,8 +57,7 @@ class DynSymLinkOption(object): def impl_getsuffix(self): return self._suffix - def impl_getpath(self, - context): + def impl_getpath(self): return self._rootpath + '.' + self.impl_getname() def impl_validate(self, @@ -69,7 +68,7 @@ class DynSymLinkOption(object): context = option_bag.config_bag.context soption_bag = OptionBag() soption_bag.set_option(self._opt, - self.impl_getpath(context), + self.impl_getpath(), option_bag.index, option_bag.config_bag) soption_bag.ori_option = option_bag.option diff --git a/tiramisu/option/masterslaves.py b/tiramisu/option/masterslaves.py index 2d86ede..15f34f9 100644 --- a/tiramisu/option/masterslaves.py +++ b/tiramisu/option/masterslaves.py @@ -125,7 +125,7 @@ class MasterSlaves(OptionDescription): config_bag = option_bag.config_bag.copy() config_bag.remove_validation() for slave in self.getslaves(): - slave_path = slave.impl_getpath(option_bag.config_bag.context) + slave_path = slave.impl_getpath() soption_bag = OptionBag() soption_bag.set_option(slave, slave_path, @@ -140,13 +140,12 @@ class MasterSlaves(OptionDescription): option_bag, slaves=undefined): - context = option_bag.config_bag.context if slaves is undefined: slaves = self.getslaves() config_bag = option_bag.config_bag.copy() config_bag.remove_validation() for slave in slaves: - slave_path = slave.impl_getpath(context) + slave_path = slave.impl_getpath() slavelen = values._p_.get_max_length(slave_path) soption_bag = OptionBag() soption_bag.set_option(slave, @@ -191,14 +190,13 @@ class MasterSlaves(OptionDescription): values, settings, resetted_opts) - context = values.context() - mpath = master.impl_getpath(context) + mpath = master.impl_getpath() master.reset_cache(mpath, values, settings, None) for slave in slaves: - spath = slave.impl_getpath(context) + spath = slave.impl_getpath() slave.reset_cache(spath, values, settings, diff --git a/tiramisu/option/option.py b/tiramisu/option/option.py index bc79357..04a990d 100644 --- a/tiramisu/option/option.py +++ b/tiramisu/option/option.py @@ -535,7 +535,7 @@ class Option(OnlyOption): #if no context get default value return current_option.impl_getdefault() #otherwise calculate value - path = current_option.impl_getpath(context) + path = current_option.impl_getpath() coption_bag = OptionBag() coption_bag.set_option(current_option, path, diff --git a/tiramisu/option/optiondescription.py b/tiramisu/option/optiondescription.py index 9d28fb4..6f42c93 100644 --- a/tiramisu/option/optiondescription.py +++ b/tiramisu/option/optiondescription.py @@ -231,10 +231,9 @@ class OptionDescriptionWalk(CacheOptionDescription): option_bag): option = option_bag.option dynopt = option.getsubdyn() - rootpath = dynopt.impl_getpath(option_bag.config_bag.context) + rootpath = dynopt.impl_getpath() ori_index = len(rootpath) + 1 - subpaths = [rootpath] + option.impl_getpath( - option_bag.config_bag.context)[ori_index:].split('.')[:-1] + subpaths = [rootpath] + option.impl_getpath()[ori_index:].split('.')[:-1] for suffix in dynopt.impl_get_suffixes(option_bag): subpath = '.'.join([subp + suffix for subp in subpaths]) if isinstance(option, OnlyOption): @@ -268,7 +267,7 @@ class OptionDescriptionWalk(CacheOptionDescription): config_bag) for doption in self.build_dynoptions(option_bag): if byname == doption.impl_getname(): - dpath = doption.impl_getpath(config_bag.context) + dpath = doption.impl_getpath() return (dpath, doption) elif byname == name: return (path, option) @@ -327,7 +326,7 @@ class OptionDescriptionWalk(CacheOptionDescription): if config_bag.context.cfgimpl_get_description() == self: subpath = '' else: - subpath = self.impl_getpath(config_bag.context) + subpath = self.impl_getpath() option_bag = OptionBag() option_bag.set_option(child, subpath, diff --git a/tiramisu/option/syndynoptiondescription.py b/tiramisu/option/syndynoptiondescription.py index f2fda71..2082026 100644 --- a/tiramisu/option/syndynoptiondescription.py +++ b/tiramisu/option/syndynoptiondescription.py @@ -66,13 +66,13 @@ class SynDynOptionDescription(object): config_bag, dyn=True): children = [] - subpath = self.impl_getpath(config_bag.context) + subpath = self.impl_getpath() for child in self._opt.impl_getchildren(config_bag): yield(self._opt._impl_get_dynchild(child, self._suffix, subpath)) - def impl_getpath(self, context): + def impl_getpath(self): subpath = self._subpath if subpath != '': subpath += '.' @@ -80,11 +80,11 @@ class SynDynOptionDescription(object): def getmaster(self): master = self._opt.getmaster() - return master.impl_get_dynoption(self.impl_getpath(None), + return master.impl_get_dynoption(self.impl_getpath(), self._suffix) def getslaves(self): - subpath = self.impl_getpath(None) + subpath = self.impl_getpath() for slave in self._opt.getslaves(): yield slave.impl_get_dynoption(subpath, self._suffix) diff --git a/tiramisu/setting.py b/tiramisu/setting.py index e818dcb..723525a 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -138,7 +138,7 @@ class OptionBag: index, config_bag): if path is None: - path = option.impl_getpath(config_bag.context) + path = option.impl_getpath() self.path = path self.index = index self.option = option @@ -379,7 +379,7 @@ class Settings(object): index = option_bag.index if opt.impl_is_symlinkoption(): opt = opt.impl_getopt() - path = opt.impl_getpath(self._getcontext()) + path = opt.impl_getpath() if apply_requires: props = config_bag.properties @@ -415,7 +415,7 @@ class Settings(object): path): if opt and opt.impl_is_symlinkoption(): opt = opt.impl_getopt() - path = opt.impl_getpath(self._getcontext()) + path = opt.impl_getpath() return self._pp_.getpermissives(path) def apply_requires(self, @@ -485,7 +485,7 @@ class Settings(object): if option.issubdyn(): option = option.impl_get_dynoption(option_bag.option._rootpath, option_bag.option.impl_getsuffix()) - reqpath = option.impl_getpath(context) + reqpath = option.impl_getpath() #FIXME too later! if reqpath.startswith(option_bag.path + '.'): raise RequirementError(_("malformed requirements " diff --git a/tiramisu/value.py b/tiramisu/value.py index 7da12e3..bc15f24 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -338,7 +338,7 @@ class Values(object): return False if option_bag.option.impl_is_master_slaves('slave'): master = option_bag.option.impl_get_master_slaves().getmaster() - masterp = master.impl_getpath(context) + masterp = master.impl_getpath() # slave could be a "meta" only if master hasn't value if self._p_.hasvalue(masterp, index=None): @@ -378,7 +378,7 @@ class Values(object): option_bag.ori_option = opt opt = opt.impl_getopt() option_bag.option = opt - option_bag.path = opt.impl_getpath(context) + option_bag.path = opt.impl_getpath() settings = context.cfgimpl_get_settings() settings.validate_properties(option_bag) if 'frozen' in option_bag.properties and \