simplify __getattr__
This commit is contained in:
parent
ebeaee620b
commit
c46480a7eb
|
@ -314,13 +314,8 @@ class TiramisuOptionOption(CommonTiramisuOption):
|
||||||
return option.impl_getrequires()
|
return option.impl_getrequires()
|
||||||
|
|
||||||
def __getattr__(self, name: str) -> Callable:
|
def __getattr__(self, name: str) -> Callable:
|
||||||
#if not self._get_option().impl_is_optiondescription() and name != 'get_option':
|
|
||||||
if not self._get_option().impl_is_optiondescription():
|
if not self._get_option().impl_is_optiondescription():
|
||||||
subkey = '_' + name
|
return getattr(self, '_' + name)
|
||||||
if subkey in dir(self):
|
|
||||||
func = getattr(self, subkey)
|
|
||||||
if callable(func):
|
|
||||||
return func
|
|
||||||
raise APIError(_('{} is unknown').format(name))
|
raise APIError(_('{} is unknown').format(name))
|
||||||
|
|
||||||
def isoptiondescription(self):
|
def isoptiondescription(self):
|
||||||
|
@ -631,17 +626,8 @@ class TiramisuOption(CommonTiramisu):
|
||||||
self.subconfig,
|
self.subconfig,
|
||||||
self.config_bag,
|
self.config_bag,
|
||||||
self.option_bag)
|
self.option_bag)
|
||||||
elif subfunc == 'make_dict' and self._get_option().impl_is_optiondescription():
|
elif self._get_option().impl_is_optiondescription():
|
||||||
return self._make_dict
|
return getattr(self, '_' + subfunc)
|
||||||
elif subfunc == 'find' and self._get_option().impl_is_optiondescription():
|
|
||||||
return self._find
|
|
||||||
elif subfunc == 'get' and self._get_option().impl_is_optiondescription():
|
|
||||||
return self._get
|
|
||||||
elif subfunc == 'list' and self._get_option().impl_is_optiondescription():
|
|
||||||
return self._list
|
|
||||||
elif subfunc == 'group_type' and self._get_option().impl_is_optiondescription():
|
|
||||||
return self._group_type
|
|
||||||
else:
|
|
||||||
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
||||||
|
|
||||||
@count
|
@count
|
||||||
|
|
|
@ -735,7 +735,6 @@ class Config(_CommonConfig):
|
||||||
weakref.ref(self),
|
weakref.ref(self),
|
||||||
ConfigBag(self),
|
ConfigBag(self),
|
||||||
None)
|
None)
|
||||||
#undocumented option used only in test script
|
|
||||||
if _duplicate is False and (force_settings is None or force_values is None):
|
if _duplicate is False and (force_settings is None or force_values is None):
|
||||||
self._impl_build_all_caches()
|
self._impl_build_all_caches()
|
||||||
self._impl_name = session_id
|
self._impl_name = session_id
|
||||||
|
|
Loading…
Reference in New Issue