works on performante

This commit is contained in:
Emmanuel Garette 2013-03-26 10:29:49 +01:00
parent 4f3db9cbc6
commit 899f864f8d
3 changed files with 17 additions and 9 deletions

View File

@ -33,9 +33,12 @@ from tiramisu.value import Values
# ____________________________________________________________ # ____________________________________________________________
class Config(object): class Config(object):
"main configuration management entry" "main configuration management entry"
# __slots__ = ('__dict__', '_cfgimpl_toplevel', '_cfgimpl_descr', '_cfgimpl_subconfigs',
# '_cfgimpl_parent', '_cfgimpl_all_paths', '_cfgimpl_warnings',
# '_cfgimpl_toplevel', '_cfgimpl_slots', '_cfgimpl_build_all_paths')
_cfgimpl_toplevel = None _cfgimpl_toplevel = None
def __init__(self, descr, parent=None, context=None): def __init__(self, descr, parent=None, context=None, valid_opt_names=True):
""" Configuration option management master class """ Configuration option management master class
:param descr: describes the configuration schema :param descr: describes the configuration schema
@ -57,21 +60,23 @@ class Config(object):
self._cfgimpl_context = context self._cfgimpl_context = context
if parent is None: if parent is None:
self._cfgimpl_settings = Setting() self._cfgimpl_settings = Setting()
self._cfgimpl_settings.valid_opt_names = valid_opt_names
self._cfgimpl_values = Values(self._cfgimpl_context) self._cfgimpl_values = Values(self._cfgimpl_context)
self._cfgimpl_all_paths = {} self._cfgimpl_all_paths = {}
else: else:
if context is None: if context is None:
raise ConfigError("cannot find a value for this config") raise ConfigError("cannot find a value for this config")
self._cfgimpl_settings = None valid_opt_names = context._cfgimpl_settings.valid_opt_names
self._cfgimpl_values = None
self._cfgimpl_all_paths = None
"warnings are a great idea, let's make up a better use of it" "warnings are a great idea, let's make up a better use of it"
self._cfgimpl_warnings = [] self._cfgimpl_warnings = []
self._cfgimpl_toplevel = self._cfgimpl_get_toplevel() self._cfgimpl_toplevel = self._cfgimpl_get_toplevel()
if valid_opt_names:
# some api members shall not be used as option's names ! # some api members shall not be used as option's names !
methods = getmembers(self, ismethod) #methods = getmembers(self, ismethod)
self._cfgimpl_slots = [key for key, value in methods self._cfgimpl_slots = [] #[key for key, value in methods
if not key.startswith("_")] #if not key.startswith("_")]
else:
self._cfgimpl_slots = []
self._cfgimpl_build() self._cfgimpl_build()
if parent is None: if parent is None:
self._cfgimpl_build_all_paths() self._cfgimpl_build_all_paths()

View File

@ -486,7 +486,7 @@ class OptionDescription(BaseType, BaseInformation):
option.build_cache(paths, currpath=currpath) option.build_cache(paths, currpath=currpath)
currpath.pop() currpath.pop()
else: else:
paths[option] = '.'.join(currpath + [attr]) paths[option] = str('.'.join(currpath + [attr]))
# ____________________________________________________________ # ____________________________________________________________
def set_group_type(self, group_type): def set_group_type(self, group_type):

View File

@ -131,6 +131,9 @@ class Setting():
owner = owners.user owner = owners.user
# in order to freeze everything, not **only** the frozen options # in order to freeze everything, not **only** the frozen options
everything_frozen = False everything_frozen = False
# enables at build time to raise an exception if the option's name
# has the name of a config's method
valid_opt_names = True
#____________________________________________________________ #____________________________________________________________
# properties methods # properties methods
def has_properties(self): def has_properties(self):