improvemnt information
This commit is contained in:
@ -107,6 +107,13 @@ class StorageBase(object):
|
||||
:param key: information's key (ex: "help", "doc"
|
||||
:param value: information's value (ex: "the help string")
|
||||
"""
|
||||
if self.impl_is_readonly():
|
||||
raise AttributeError(_("'{0}' ({1}) object attribute '{2}' is"
|
||||
" read-only").format(
|
||||
self.__class__.__name__,
|
||||
self,
|
||||
#self.impl_getname(),
|
||||
key))
|
||||
self._informations[key] = value
|
||||
|
||||
def impl_get_information(self, key, default=undefined):
|
||||
@ -119,15 +126,18 @@ class StorageBase(object):
|
||||
if dico is None or isinstance(dico, str) or isinstance(dico, unicode):
|
||||
if key == 'doc':
|
||||
return dico
|
||||
if default is not undefined:
|
||||
return default
|
||||
error = True
|
||||
elif isinstance(dico, tuple):
|
||||
try:
|
||||
return dico[1][dico[0].index(key)]
|
||||
except AttributeError:
|
||||
except ValueError:
|
||||
if default is not undefined:
|
||||
return default
|
||||
error = True
|
||||
else:
|
||||
# dict
|
||||
if default is not undefined:
|
||||
return self._informations.get(key, default)
|
||||
try:
|
||||
@ -236,7 +246,7 @@ class StorageBase(object):
|
||||
dico = dico['doc']
|
||||
else:
|
||||
dico = tuple([tuple(dico.keys()), tuple(dico.values())])
|
||||
self._informations = dico
|
||||
self._informations = dico
|
||||
try:
|
||||
extra = self._extra
|
||||
self._extra = tuple([tuple(extra.keys()), tuple(extra.values())])
|
||||
|
@ -162,9 +162,9 @@ class Values(Cache):
|
||||
else:
|
||||
if isinstance(self._values[1][idx], list):
|
||||
if index is None:
|
||||
raise ValueError('list but no index')
|
||||
raise ValueError('index is mandatory')
|
||||
elif index is not None:
|
||||
raise ValueError('index set but not a list')
|
||||
raise ValueError('index is forbidden')
|
||||
|
||||
if self._values[1][idx] is None:
|
||||
if index is None:
|
||||
|
Reference in New Issue
Block a user