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