better raise message if try to launch impl_get_information/impl_set_information in uncompatible class
This commit is contained in:
parent
23f6d2228f
commit
3c0629e6a9
|
@ -64,19 +64,27 @@ class BaseInformation(object):
|
||||||
:param key: information's key (ex: "help", "doc"
|
:param key: information's key (ex: "help", "doc"
|
||||||
:param value: information's value (ex: "the help string")
|
:param value: information's value (ex: "the help string")
|
||||||
"""
|
"""
|
||||||
self._impl_informations[key] = value
|
try:
|
||||||
|
self._impl_informations[key] = value
|
||||||
|
except AttributeError:
|
||||||
|
raise AttributeError(_('{0} instance has no attribute '
|
||||||
|
'impl_set_information').format(self.__class__.__name__))
|
||||||
|
|
||||||
def impl_get_information(self, key, default=None):
|
def impl_get_information(self, key, default=None):
|
||||||
"""retrieves one information's item
|
"""retrieves one information's item
|
||||||
|
|
||||||
:param key: the item string (ex: "help")
|
:param key: the item string (ex: "help")
|
||||||
"""
|
"""
|
||||||
if key in self._impl_informations:
|
try:
|
||||||
return self._impl_informations[key]
|
if key in self._impl_informations:
|
||||||
elif default is not None:
|
return self._impl_informations[key]
|
||||||
return default
|
elif default is not None:
|
||||||
else:
|
return default
|
||||||
raise ValueError(_("Information's item not found: {0}").format(key))
|
else:
|
||||||
|
raise ValueError(_("Information's item not found: {0}").format(key))
|
||||||
|
except AttributeError:
|
||||||
|
raise AttributeError(_('{0} instance has no attribute '
|
||||||
|
'impl_get_information').format(self.__class__.__name__))
|
||||||
|
|
||||||
|
|
||||||
class Option(BaseInformation):
|
class Option(BaseInformation):
|
||||||
|
|
Loading…
Reference in New Issue