some optimisations

This commit is contained in:
Emmanuel Garette 2015-12-18 23:35:45 +01:00
parent a97c3c682a
commit 93ce93e529
3 changed files with 16 additions and 11 deletions

View File

@ -54,8 +54,9 @@ class ChoiceOption(Option):
if not isinstance(values, tuple): # pragma: optional cover
raise TypeError(_('values must be a tuple or a function for {0}'
).format(name))
self._choice_values = values
self._choice_values_params = values_params
_setattr = object.__setattr__
_setattr(self, '_choice_values', values)
_setattr(self, '_choice_values_params', values_params)
super(ChoiceOption, self).__init__(name, doc, default=default,
default_multi=default_multi,
callback=callback,

View File

@ -74,10 +74,11 @@ class OptionDescription(BaseOption, StorageOptionDescription):
'dynoptiondescription'))
old = child
self._add_children(child_names, children)
self._cache_consistencies = None
_setattr = object.__setattr__
_setattr(self, '_cache_consistencies', None)
# the group_type is useful for filtering OptionDescriptions in a config
self._group_type = groups.default
self._is_build_cache = False
_setattr(self, '_group_type', groups.default)
_setattr(self, '_is_build_cache', False)
def impl_getdoc(self):
return self.impl_get_information('doc')

View File

@ -242,16 +242,17 @@ class StorageBase(object):
def _set_readonly(self):
if not self.impl_is_readonly():
dico = self._informations
_setattr = object.__setattr__
if not (dico is None or isinstance(dico, str) or isinstance(dico, unicode)):
keys = tuple(dico.keys())
if keys == ('doc',):
dico = dico['doc']
else:
dico = tuple([tuple(dico.keys()), tuple(dico.values())])
self._informations = dico
_setattr(self, '_informations', dico)
try:
extra = self._extra
self._extra = tuple([tuple(extra.keys()), tuple(extra.values())])
_setattr(self, '_extra', tuple([tuple(extra.keys()), tuple(extra.values())]))
except AttributeError:
pass
@ -370,7 +371,8 @@ class StorageOptionDescription(StorageBase):
self._cache_paths = None
def _add_children(self, child_names, children):
self._children = (tuple(child_names), tuple(children))
_setattr = object.__setattr__
_setattr(self, '_children', (tuple(child_names), tuple(children)))
def impl_already_build_caches(self):
return self._is_build_cache
@ -394,10 +396,11 @@ class StorageOptionDescription(StorageBase):
def impl_build_cache_option(self, _currpath=None, cache_path=None,
cache_option=None):
_setattr = object.__setattr__
try:
self._cache_paths
except AttributeError:
self._cache_paths = None
_setattr(self, '_cache_paths', None)
if _currpath is None and self._cache_paths is not None: # pragma: optional cover
# cache already set
return
@ -420,8 +423,8 @@ class StorageOptionDescription(StorageBase):
cache_option)
_currpath.pop()
if save:
self._cache_paths = (tuple(cache_option), tuple(cache_path))
self._is_build_cache = True
_setattr(self, '_cache_paths', (tuple(cache_option), tuple(cache_path)))
_setattr(self, '_is_build_cache', True)
def impl_get_options_paths(self, bytype, byname, _subpath, only_first, context):
find_results = []