add metaconfig
This commit is contained in:
parent
abbb7a274e
commit
7165f73292
|
@ -1,172 +1,172 @@
|
||||||
#import autopath
|
import autopath
|
||||||
|
|
||||||
#from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
#from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
#from tiramisu.config import Config, MetaConfig
|
from tiramisu.config import Config, MetaConfig
|
||||||
#from tiramisu.option import IntOption, OptionDescription
|
from tiramisu.option import IntOption, OptionDescription
|
||||||
#from tiramisu.error import ConfigError
|
from tiramisu.error import ConfigError
|
||||||
|
|
||||||
#owners.addowner('meta')
|
owners.addowner('meta')
|
||||||
|
|
||||||
|
|
||||||
#def make_description():
|
def make_description():
|
||||||
# i1 = IntOption('i1', '')
|
i1 = IntOption('i1', '')
|
||||||
# i2 = IntOption('i2', '', default=1)
|
i2 = IntOption('i2', '', default=1)
|
||||||
# i3 = IntOption('i3', '')
|
i3 = IntOption('i3', '')
|
||||||
# i4 = IntOption('i4', '', default=2)
|
i4 = IntOption('i4', '', default=2)
|
||||||
# od1 = OptionDescription('od1', '', [i1, i2, i3, i4])
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4])
|
||||||
# od2 = OptionDescription('od2', '', [od1])
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
# conf1 = Config(od2)
|
conf1 = Config(od2)
|
||||||
# conf2 = Config(od2)
|
conf2 = Config(od2)
|
||||||
# meta = MetaConfig([conf1, conf2])
|
meta = MetaConfig([conf1, conf2])
|
||||||
# meta.cfgimpl_get_settings().setowner(owners.meta)
|
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||||
# return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
##FIXME ne pas mettre 2 meta dans une config
|
#FIXME ne pas mettre 2 meta dans une config
|
||||||
##FIXME ne pas mettre 2 OD differents dans un meta
|
#FIXME ne pas mettre 2 OD differents dans un meta
|
||||||
#def test_none():
|
def test_none():
|
||||||
# meta = make_description()
|
meta = make_description()
|
||||||
# conf1, conf2 = meta._impl_children
|
conf1, conf2 = meta._impl_children
|
||||||
# assert conf1.od1.i3 is conf2.od1.i3 is None
|
assert conf1.od1.i3 is conf2.od1.i3 is None
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
||||||
# meta.od1.i3 = 3
|
meta.od1.i3 = 3
|
||||||
# assert conf1.od1.i3 == conf2.od1.i3 == 3
|
assert conf1.od1.i3 == conf2.od1.i3 == 3
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.meta
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.meta
|
||||||
# meta.od1.i3 = 3
|
meta.od1.i3 = 3
|
||||||
# conf1.od1.i3 = 2
|
conf1.od1.i3 = 2
|
||||||
# assert conf1.od1.i3 == 2
|
assert conf1.od1.i3 == 2
|
||||||
# assert conf2.od1.i3 == 3
|
assert conf2.od1.i3 == 3
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.meta
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.meta
|
||||||
# meta.od1.i3 = 4
|
meta.od1.i3 = 4
|
||||||
# assert conf1.od1.i3 == 2
|
assert conf1.od1.i3 == 2
|
||||||
# assert conf2.od1.i3 == 4
|
assert conf2.od1.i3 == 4
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.meta
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.meta
|
||||||
# del(meta.od1.i3)
|
del(meta.od1.i3)
|
||||||
# assert conf1.od1.i3 == 2
|
assert conf1.od1.i3 == 2
|
||||||
# assert conf2.od1.i3 is None
|
assert conf2.od1.i3 is None
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
||||||
# del(conf1.od1.i3)
|
del(conf1.od1.i3)
|
||||||
# assert conf1.od1.i3 is conf2.od1.i3 is None
|
assert conf1.od1.i3 is conf2.od1.i3 is None
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
||||||
|
|
||||||
|
|
||||||
#def test_default():
|
def test_default():
|
||||||
# meta = make_description()
|
meta = make_description()
|
||||||
# conf1, conf2 = meta._impl_children
|
conf1, conf2 = meta._impl_children
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 1
|
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||||
# meta.od1.i2 = 3
|
meta.od1.i2 = 3
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 3
|
assert conf1.od1.i2 == conf2.od1.i2 == 3
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||||
# meta.od1.i2 = 3
|
meta.od1.i2 = 3
|
||||||
# conf1.od1.i2 = 2
|
conf1.od1.i2 = 2
|
||||||
# assert conf1.od1.i2 == 2
|
assert conf1.od1.i2 == 2
|
||||||
# assert conf2.od1.i2 == 3
|
assert conf2.od1.i2 == 3
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||||
# meta.od1.i2 = 4
|
meta.od1.i2 = 4
|
||||||
# assert conf1.od1.i2 == 2
|
assert conf1.od1.i2 == 2
|
||||||
# assert conf2.od1.i2 == 4
|
assert conf2.od1.i2 == 4
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||||
# del(meta.od1.i2)
|
del(meta.od1.i2)
|
||||||
# assert conf1.od1.i2 == 2
|
assert conf1.od1.i2 == 2
|
||||||
# assert conf2.od1.i2 == 1
|
assert conf2.od1.i2 == 1
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||||
# del(conf1.od1.i2)
|
del(conf1.od1.i2)
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 1
|
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||||
|
|
||||||
|
|
||||||
#def test_contexts():
|
def test_contexts():
|
||||||
# meta = make_description()
|
meta = make_description()
|
||||||
# conf1, conf2 = meta._impl_children
|
conf1, conf2 = meta._impl_children
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 1
|
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||||
# meta.set_contexts('od1.i2', 6)
|
meta.set_contexts('od1.i2', 6)
|
||||||
# assert meta.od1.i2 == 1
|
assert meta.od1.i2 == 1
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 6
|
assert conf1.od1.i2 == conf2.od1.i2 == 6
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.user
|
||||||
|
|
||||||
|
|
||||||
#def test_find():
|
def test_find():
|
||||||
# meta = make_description()
|
meta = make_description()
|
||||||
# i2 = meta.unwrap_from_path('od1.i2')
|
i2 = meta.unwrap_from_path('od1.i2')
|
||||||
# assert [i2] == meta.find(byname='i2')
|
assert [i2] == meta.find(byname='i2')
|
||||||
# assert i2 == meta.find_first(byname='i2')
|
assert i2 == meta.find_first(byname='i2')
|
||||||
# assert meta.make_dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None, 'od1.i2': 1}
|
assert meta.make_dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None, 'od1.i2': 1}
|
||||||
|
|
||||||
|
|
||||||
#def test_meta_meta():
|
def test_meta_meta():
|
||||||
# meta1 = make_description()
|
meta1 = make_description()
|
||||||
# meta2 = MetaConfig([meta1])
|
meta2 = MetaConfig([meta1])
|
||||||
# meta2.cfgimpl_get_settings().setowner(owners.meta)
|
meta2.cfgimpl_get_settings().setowner(owners.meta)
|
||||||
# conf1, conf2 = meta1._impl_children
|
conf1, conf2 = meta1._impl_children
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 1
|
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||||
# meta2.od1.i2 = 3
|
meta2.od1.i2 = 3
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 3
|
assert conf1.od1.i2 == conf2.od1.i2 == 3
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||||
# meta2.od1.i2 = 3
|
meta2.od1.i2 = 3
|
||||||
# conf1.od1.i2 = 2
|
conf1.od1.i2 = 2
|
||||||
# assert conf1.od1.i2 == 2
|
assert conf1.od1.i2 == 2
|
||||||
# assert conf2.od1.i2 == 3
|
assert conf2.od1.i2 == 3
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||||
# meta2.od1.i2 = 4
|
meta2.od1.i2 = 4
|
||||||
# assert conf1.od1.i2 == 2
|
assert conf1.od1.i2 == 2
|
||||||
# assert conf2.od1.i2 == 4
|
assert conf2.od1.i2 == 4
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||||
# del(meta2.od1.i2)
|
del(meta2.od1.i2)
|
||||||
# assert conf1.od1.i2 == 2
|
assert conf1.od1.i2 == 2
|
||||||
# assert conf2.od1.i2 == 1
|
assert conf2.od1.i2 == 1
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is owners.user
|
||||||
# assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
assert conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||||
# del(conf1.od1.i2)
|
del(conf1.od1.i2)
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 1
|
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||||
# meta1.od1.i2 = 6
|
meta1.od1.i2 = 6
|
||||||
# assert conf1.od1.i2 == conf2.od1.i2 == 6
|
assert conf1.od1.i2 == conf2.od1.i2 == 6
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||||
|
|
||||||
|
|
||||||
#def test_meta_meta_set():
|
def test_meta_meta_set():
|
||||||
# meta1 = make_description()
|
meta1 = make_description()
|
||||||
# meta2 = MetaConfig([meta1])
|
meta2 = MetaConfig([meta1])
|
||||||
# meta2.cfgimpl_get_settings().setowner(owners.meta)
|
meta2.cfgimpl_get_settings().setowner(owners.meta)
|
||||||
# conf1, conf2 = meta1._impl_children
|
conf1, conf2 = meta1._impl_children
|
||||||
# meta2.set_contexts('od1.i1', 7)
|
meta2.set_contexts('od1.i1', 7)
|
||||||
# assert conf1.od1.i1 == conf2.od1.i1 == 7
|
assert conf1.od1.i1 == conf2.od1.i1 == 7
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i1')) is conf2.getowner(conf2.unwrap_from_path('od1.i1')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i1')) is conf2.getowner(conf2.unwrap_from_path('od1.i1')) is owners.user
|
||||||
# assert [conf1, conf2] == meta2.find_first_contexts(byname='i1', byvalue=7)
|
assert [conf1, conf2] == meta2.find_first_contexts(byname='i1', byvalue=7)
|
||||||
# conf1.od1.i1 = 8
|
conf1.od1.i1 = 8
|
||||||
# assert [conf2] == meta2.find_first_contexts(byname='i1', byvalue=7)
|
assert [conf2] == meta2.find_first_contexts(byname='i1', byvalue=7)
|
||||||
# assert [conf1] == meta2.find_first_contexts(byname='i1', byvalue=8)
|
assert [conf1] == meta2.find_first_contexts(byname='i1', byvalue=8)
|
||||||
# raises(AttributeError, "meta2.find_first_contexts(byname='i1', byvalue=10)")
|
raises(AttributeError, "meta2.find_first_contexts(byname='i1', byvalue=10)")
|
||||||
|
|
||||||
|
|
||||||
#def test_not_meta():
|
def test_not_meta():
|
||||||
# i1 = IntOption('i1', '')
|
i1 = IntOption('i1', '')
|
||||||
# od1 = OptionDescription('od1', '', [i1])
|
od1 = OptionDescription('od1', '', [i1])
|
||||||
# od2 = OptionDescription('od2', '', [od1])
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
# conf1 = Config(od2)
|
conf1 = Config(od2)
|
||||||
# conf2 = Config(od2)
|
conf2 = Config(od2)
|
||||||
# meta = MetaConfig([conf1, conf2], False)
|
meta = MetaConfig([conf1, conf2], False)
|
||||||
# raises(ConfigError, 'meta.od1.i1')
|
raises(ConfigError, 'meta.od1.i1')
|
||||||
# conf1, conf2 = meta._impl_children
|
conf1, conf2 = meta._impl_children
|
||||||
# meta.set_contexts('od1.i1', 7)
|
meta.set_contexts('od1.i1', 7)
|
||||||
# assert conf1.od1.i1 == conf2.od1.i1 == 7
|
assert conf1.od1.i1 == conf2.od1.i1 == 7
|
||||||
# assert conf1.getowner(conf1.unwrap_from_path('od1.i1')) is conf2.getowner(conf2.unwrap_from_path('od1.i1')) is owners.user
|
assert conf1.getowner(conf1.unwrap_from_path('od1.i1')) is conf2.getowner(conf2.unwrap_from_path('od1.i1')) is owners.user
|
||||||
|
|
||||||
|
|
||||||
#def test_meta_path():
|
def test_meta_path():
|
||||||
# meta = make_description()
|
meta = make_description()
|
||||||
# assert meta._impl_path is None
|
assert meta._impl_path is None
|
||||||
# assert meta.od1._impl_path == 'od1'
|
assert meta.od1._impl_path == 'od1'
|
||||||
|
|
|
@ -43,7 +43,7 @@ class SubConfig(object):
|
||||||
:type subpath: `str` with the path name
|
:type subpath: `str` with the path name
|
||||||
"""
|
"""
|
||||||
# main option description
|
# main option description
|
||||||
if not isinstance(descr, OptionDescription):
|
if descr is not None and not isinstance(descr, OptionDescription):
|
||||||
raise TypeError(_('descr must be an optiondescription, not {0}'
|
raise TypeError(_('descr must be an optiondescription, not {0}'
|
||||||
).format(type(descr)))
|
).format(type(descr)))
|
||||||
self._impl_descr = descr
|
self._impl_descr = descr
|
||||||
|
@ -552,99 +552,99 @@ class Config(CommonConfig):
|
||||||
self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
|
self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
|
||||||
|
|
||||||
|
|
||||||
#class MetaConfig(CommonConfig):
|
class MetaConfig(CommonConfig):
|
||||||
# __slots__ = ('_impl_children',)
|
__slots__ = ('_impl_children', '__weakref__')
|
||||||
|
|
||||||
# def __init__(self, children, meta=True, session_id=None, persistent=False):
|
def __init__(self, children, meta=True, session_id=None, persistent=False):
|
||||||
# if not isinstance(children, list):
|
if not isinstance(children, list):
|
||||||
# raise ValueError(_("metaconfig's children must be a list"))
|
raise ValueError(_("metaconfig's children must be a list"))
|
||||||
# self._impl_descr = None
|
descr = None
|
||||||
# self._impl_path = None
|
if meta:
|
||||||
# if meta:
|
for child in children:
|
||||||
# for child in children:
|
if not isinstance(child, CommonConfig):
|
||||||
# if not isinstance(child, CommonConfig):
|
raise TypeError(_("metaconfig's children "
|
||||||
# raise TypeError(_("metaconfig's children "
|
"must be config, not {0}"
|
||||||
# "must be config, not {0}"
|
).format(type(child)))
|
||||||
# ).format(type(child)))
|
if descr is None:
|
||||||
# if self._impl_descr is None:
|
descr = child.cfgimpl_get_description()
|
||||||
# self._impl_descr = child.cfgimpl_get_description()
|
elif not descr is child.cfgimpl_get_description():
|
||||||
# elif not self._impl_descr is child.cfgimpl_get_description():
|
raise ValueError(_('all config in metaconfig must '
|
||||||
# raise ValueError(_('all config in metaconfig must '
|
'have the same optiondescription'))
|
||||||
# 'have the same optiondescription'))
|
if child.cfgimpl_get_meta() is not None:
|
||||||
# if child.cfgimpl_get_meta() is not None:
|
raise ValueError(_("child has already a metaconfig's"))
|
||||||
# raise ValueError(_("child has already a metaconfig's"))
|
child._impl_meta = self
|
||||||
# child._impl_meta = self
|
|
||||||
|
|
||||||
# self._impl_children = children
|
self._impl_children = children
|
||||||
# settings, values = get_storages(self, session_id, persistent)
|
settings, values = get_storages(self, session_id, persistent)
|
||||||
# self._impl_settings = Settings(self, settings)
|
self._impl_settings = Settings(self, settings)
|
||||||
# self._impl_values = Values(self, values)
|
self._impl_values = Values(self, values)
|
||||||
# self._impl_meta = None
|
super(MetaConfig, self).__init__(descr, weakref.ref(self))
|
||||||
|
self._impl_meta = None
|
||||||
|
|
||||||
# def cfgimpl_get_children(self):
|
def cfgimpl_get_children(self):
|
||||||
# return self._impl_children
|
return self._impl_children
|
||||||
|
|
||||||
# def cfgimpl_get_context(self):
|
def cfgimpl_get_context(self):
|
||||||
# "a meta config is a config wich has a setting, that is itself"
|
"a meta config is a config wich has a setting, that is itself"
|
||||||
# return self
|
return self
|
||||||
|
|
||||||
# def cfgimpl_reset_cache(self,
|
def cfgimpl_reset_cache(self,
|
||||||
# only_expired=False,
|
only_expired=False,
|
||||||
# only=('values', 'settings')):
|
only=('values', 'settings')):
|
||||||
# if 'values' in only:
|
if 'values' in only:
|
||||||
# self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
|
self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
|
||||||
# if 'settings' in only:
|
if 'settings' in only:
|
||||||
# self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
|
self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
|
||||||
# for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
# child.cfgimpl_reset_cache(only_expired=only_expired, only=only)
|
child.cfgimpl_reset_cache(only_expired=only_expired, only=only)
|
||||||
|
|
||||||
# def set_contexts(self, path, value):
|
def set_contexts(self, path, value):
|
||||||
# for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
# try:
|
try:
|
||||||
# if not isinstance(child, MetaConfig):
|
if not isinstance(child, MetaConfig):
|
||||||
# setattr(child, path, value)
|
setattr(child, path, value)
|
||||||
# else:
|
else:
|
||||||
# child.set_contexts(path, value)
|
child.set_contexts(path, value)
|
||||||
# except PropertiesOptionError:
|
except PropertiesOptionError:
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# def find_first_contexts(self, byname=None, bypath=None, byvalue=None,
|
def find_first_contexts(self, byname=None, bypath=None, byvalue=None,
|
||||||
# type_='path', display_error=True):
|
type_='path', display_error=True):
|
||||||
# ret = []
|
ret = []
|
||||||
# try:
|
try:
|
||||||
# if bypath is None and byname is not None and \
|
if bypath is None and byname is not None and \
|
||||||
# self.cfgimpl_get_description() is not None:
|
self.cfgimpl_get_description() is not None:
|
||||||
# bypath = self._find(bytype=None, byvalue=None, byname=byname,
|
bypath = self._find(bytype=None, byvalue=None, byname=byname,
|
||||||
# first=True, type_='path',
|
first=True, type_='path',
|
||||||
# check_properties=False,
|
check_properties=False,
|
||||||
# display_error=display_error)
|
display_error=display_error)
|
||||||
# except ConfigError:
|
except ConfigError:
|
||||||
# pass
|
pass
|
||||||
# for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
# try:
|
try:
|
||||||
# if not isinstance(child, MetaConfig):
|
if not isinstance(child, MetaConfig):
|
||||||
# if bypath is not None:
|
if bypath is not None:
|
||||||
# if byvalue is not None:
|
if byvalue is not None:
|
||||||
# if getattr(child, bypath) == byvalue:
|
if getattr(child, bypath) == byvalue:
|
||||||
# ret.append(child)
|
ret.append(child)
|
||||||
# else:
|
else:
|
||||||
# #not raise
|
#not raise
|
||||||
# getattr(child, bypath)
|
getattr(child, bypath)
|
||||||
# ret.append(child)
|
ret.append(child)
|
||||||
# else:
|
else:
|
||||||
# ret.append(child.find_first(byname=byname,
|
ret.append(child.find_first(byname=byname,
|
||||||
# byvalue=byvalue,
|
byvalue=byvalue,
|
||||||
# type_=type_,
|
type_=type_,
|
||||||
# display_error=False))
|
display_error=False))
|
||||||
# else:
|
else:
|
||||||
# ret.extend(child.find_first_contexts(byname=byname,
|
ret.extend(child.find_first_contexts(byname=byname,
|
||||||
# bypath=bypath,
|
bypath=bypath,
|
||||||
# byvalue=byvalue,
|
byvalue=byvalue,
|
||||||
# type_=type_,
|
type_=type_,
|
||||||
# display_error=False))
|
display_error=False))
|
||||||
# except AttributeError:
|
except AttributeError:
|
||||||
# pass
|
pass
|
||||||
# return self._find_return_results(ret, display_error)
|
return self._find_return_results(ret, display_error)
|
||||||
|
|
||||||
|
|
||||||
def mandatory_warnings(config):
|
def mandatory_warnings(config):
|
||||||
|
|
Loading…
Reference in New Issue