api: add function path() to get path of an option
This commit is contained in:
parent
54cb73c2cc
commit
a1bb6370ca
|
@ -162,7 +162,7 @@ class CommonTiramisu(TiramisuHelp):
|
|||
self.subconfig)
|
||||
self.config_bag.option = option
|
||||
if self.config_bag.setting_properties:
|
||||
self.config_bag.config.cfgimpl_get_settings().validate_properties(self.path,
|
||||
self.config_bag.config.cfgimpl_get_settings().validate_properties(self._path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
if self.index is not None:
|
||||
|
@ -188,7 +188,7 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
index=None,
|
||||
subconfig=None,
|
||||
config_bag=None):
|
||||
self.path = path
|
||||
self._path = path
|
||||
self.index = index
|
||||
self.config_bag = config_bag
|
||||
self._name = name
|
||||
|
@ -263,6 +263,11 @@ class TiramisuOptionOption(CommonTiramisuOption):
|
|||
self._get_option()
|
||||
return self._name
|
||||
|
||||
def path(self):
|
||||
"""get option path"""
|
||||
self._get_option()
|
||||
return self._path
|
||||
|
||||
@count
|
||||
def _default(self):
|
||||
"""get default value for an option (not for optiondescription)"""
|
||||
|
@ -335,7 +340,7 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
|||
def get(self):
|
||||
"""get owner for a specified option"""
|
||||
option = self._get_option()
|
||||
return self.values.getowner(self.path,
|
||||
return self.values.getowner(self._path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
|
||||
|
@ -343,7 +348,7 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
|||
def isdefault(self):
|
||||
"""is option has defaut value"""
|
||||
self._get_option()
|
||||
return self.values.is_default_owner(self.path,
|
||||
return self.values.is_default_owner(self._path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
|
||||
|
@ -359,7 +364,7 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
|||
except AttributeError:
|
||||
owners.addowner(owner)
|
||||
obj_owner = getattr(owners, owner)
|
||||
self.values.setowner(self.path,
|
||||
self.values.setowner(self._path,
|
||||
self.index,
|
||||
obj_owner,
|
||||
self.config_bag)
|
||||
|
@ -390,7 +395,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
self._get_option()
|
||||
if apply_requires:
|
||||
self._test_slave_index()
|
||||
properties = self.settings.getproperties(self.path,
|
||||
properties = self.settings.getproperties(self._path,
|
||||
self.index,
|
||||
self.config_bag,
|
||||
apply_requires)
|
||||
|
@ -405,11 +410,11 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
if prop in FORBIDDEN_SET_PROPERTIES:
|
||||
raise ConfigError(_('cannot add this property: "{0}"').format(
|
||||
' '.join(prop)))
|
||||
props = self.settings.getproperties(self.path,
|
||||
props = self.settings.getproperties(self._path,
|
||||
None,
|
||||
self.config_bag,
|
||||
apply_requires=False)
|
||||
self.settings.setproperties(self.path,
|
||||
self.settings.setproperties(self._path,
|
||||
props | {prop},
|
||||
self.config_bag)
|
||||
|
||||
|
@ -417,11 +422,11 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
def pop(self, prop):
|
||||
"""remove new property for an option"""
|
||||
self._get_option()
|
||||
props = self.settings.getproperties(self.path,
|
||||
props = self.settings.getproperties(self._path,
|
||||
self.index,
|
||||
self.config_bag,
|
||||
apply_requires=False)
|
||||
self.settings.setproperties(self.path,
|
||||
self.settings.setproperties(self._path,
|
||||
props - {prop},
|
||||
self.config_bag)
|
||||
|
||||
|
@ -430,7 +435,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
"""reset all personalised properties"""
|
||||
self._get_option()
|
||||
self.settings.reset(self.config_bag.option,
|
||||
self.path,
|
||||
self._path,
|
||||
self.config_bag)
|
||||
|
||||
|
||||
|
@ -459,7 +464,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
|||
if TIRAMISU_VERSION == 2:
|
||||
args = [self.setting_properties, self._path]
|
||||
else:
|
||||
args = [self._get_option(), self.path]
|
||||
args = [self._get_option(), self._path]
|
||||
return self.settings.getpermissive(*args)
|
||||
|
||||
@count
|
||||
|
@ -474,7 +479,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
|||
config_bag=self.config_bag,
|
||||
permissive=permissives)
|
||||
else:
|
||||
path = self.path
|
||||
path = self._path
|
||||
opt = self._get_option()
|
||||
self.settings.setpermissive(opt=opt,
|
||||
path=path,
|
||||
|
@ -535,12 +540,12 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
|||
if isinstance(value, list):
|
||||
while undefined in value:
|
||||
idx = value.index(undefined)
|
||||
value[idx] = values.getdefaultvalue(self.path,
|
||||
value[idx] = values.getdefaultvalue(self._path,
|
||||
idx,
|
||||
self.config_bag)
|
||||
else:
|
||||
if value == undefined:
|
||||
value = values.getdefaultvalue(self.path,
|
||||
value = values.getdefaultvalue(self._path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
self.subconfig.setattr(self._name,
|
||||
|
@ -552,7 +557,7 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
|||
def _pop(self, index):
|
||||
"""pop value for a master option (only for master option)"""
|
||||
self._get_option()
|
||||
self.config_bag.config.delattr(self.path,
|
||||
self.config_bag.config.delattr(self._path,
|
||||
index,
|
||||
self.config_bag)
|
||||
|
||||
|
@ -561,7 +566,7 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
|||
"""reset value for a value"""
|
||||
self._get_option()
|
||||
self._test_slave_index()
|
||||
self.config_bag.config.delattr(self.path,
|
||||
self.config_bag.config.delattr(self._path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
|
||||
|
@ -569,9 +574,9 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
|||
def _len(self):
|
||||
"""length of slave option (only for slave option)"""
|
||||
self._get_option()
|
||||
subconfig_path = self.path.rsplit('.', 1)[0]
|
||||
subconfig_path = self._path.rsplit('.', 1)[0]
|
||||
if self.config_bag.setting_properties is not None:
|
||||
self.config_bag.config.cfgimpl_get_settings().validate_properties(self.path,
|
||||
self.config_bag.config.cfgimpl_get_settings().validate_properties(self._path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
config_bag = self.config_bag.copy('nooption')
|
||||
|
@ -613,7 +618,7 @@ class TiramisuOption(CommonTiramisu):
|
|||
|
||||
self._name = name
|
||||
self.subconfig = subconfig
|
||||
self.path = path
|
||||
self._path = path
|
||||
self.index = index
|
||||
self.config_bag = config_bag
|
||||
self.registers = {}
|
||||
|
@ -622,7 +627,7 @@ class TiramisuOption(CommonTiramisu):
|
|||
def __getattr__(self, subfunc):
|
||||
if subfunc in self.registers:
|
||||
return self.registers[subfunc](self._name,
|
||||
self.path,
|
||||
self._path,
|
||||
self.index,
|
||||
self.subconfig,
|
||||
self.config_bag)
|
||||
|
@ -644,7 +649,7 @@ class TiramisuOption(CommonTiramisu):
|
|||
withoption=None,
|
||||
fullpath=False):
|
||||
"""return dict with path as key and value for an optiondescription (only for optiondescription)"""
|
||||
return self.config_bag.config.getattr(self.path,
|
||||
return self.config_bag.config.getattr(self._path,
|
||||
None,
|
||||
self.config_bag).make_dict(config_bag=self.config_bag,
|
||||
flatten=flatten,
|
||||
|
@ -662,7 +667,7 @@ class TiramisuOption(CommonTiramisu):
|
|||
for path in self.config_bag.config.find(byname=name,
|
||||
byvalue=value,
|
||||
bytype=None,
|
||||
_subpath=self.path,
|
||||
_subpath=self._path,
|
||||
config_bag=self.config_bag):
|
||||
config_bag = self.config_bag.copy('nooption')
|
||||
subconfig, name = config_bag.config.cfgimpl_get_home_by_path(path,
|
||||
|
@ -688,12 +693,12 @@ class TiramisuOption(CommonTiramisu):
|
|||
group_type=None):
|
||||
"""list options in an optiondescription (only for optiondescription)"""
|
||||
if type == 'optiondescription':
|
||||
return self.config_bag.config.getattr(self.path,
|
||||
return self.config_bag.config.getattr(self._path,
|
||||
None,
|
||||
self.config_bag
|
||||
).iter_groups(self.config_bag, group_type)
|
||||
elif type == 'all':
|
||||
return self.config_bag.config.getattr(self.path,
|
||||
return self.config_bag.config.getattr(self._path,
|
||||
None,
|
||||
self.config_bag
|
||||
).cfgimpl_get_children(self.config_bag)
|
||||
|
@ -899,7 +904,7 @@ class TiramisuContextOption(TiramisuContext):
|
|||
for path in self.config_bag.config.find(byname=name,
|
||||
byvalue=value,
|
||||
bytype=None,
|
||||
#_subpath=self.path,
|
||||
#_subpath=self._path,
|
||||
config_bag=self.config_bag):
|
||||
config_bag = self.config_bag.copy('nooption')
|
||||
subconfig, name = config_bag.config.cfgimpl_get_home_by_path(path,
|
||||
|
|
Loading…
Reference in New Issue