works on performante
This commit is contained in:
parent
4f3db9cbc6
commit
899f864f8d
3 changed files with 17 additions and 9 deletions
|
@ -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()
|
||||||
# some api members shall not be used as option's names !
|
if valid_opt_names:
|
||||||
methods = getmembers(self, ismethod)
|
# some api members shall not be used as option's names !
|
||||||
self._cfgimpl_slots = [key for key, value in methods
|
#methods = getmembers(self, ismethod)
|
||||||
if not key.startswith("_")]
|
self._cfgimpl_slots = [] #[key for key, value in methods
|
||||||
|
#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()
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -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):
|
||||||
|
|
Loading…
Reference in a new issue