remove _cache_paths (path is now directly in option)
better TiramisuAPI support
This commit is contained in:
parent
e0cab0063e
commit
aa9aef6e78
13 changed files with 627 additions and 633 deletions
File diff suppressed because it is too large
Load diff
|
@ -47,8 +47,8 @@ def test_cache_config():
|
||||||
def test_cache():
|
def test_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
cfg = Config(od1)
|
cfg = Config(od1)
|
||||||
values = cfg._config.cfgimpl_get_values()
|
values = cfg._config_bag.context.cfgimpl_get_values()
|
||||||
settings = cfg._config.cfgimpl_get_settings()
|
settings = cfg._config_bag.context.cfgimpl_get_settings()
|
||||||
cfg.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
|
@ -98,8 +98,8 @@ def test_cache_importation_permissive():
|
||||||
def test_cache_reset():
|
def test_cache_reset():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
cfg = Config(od1)
|
cfg = Config(od1)
|
||||||
values = cfg._config.cfgimpl_get_values()
|
values = cfg._config_bag.context.cfgimpl_get_values()
|
||||||
settings = cfg._config.cfgimpl_get_settings()
|
settings = cfg._config_bag.context.cfgimpl_get_settings()
|
||||||
#when change a value
|
#when change a value
|
||||||
cfg.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
cfg.option('u2').value.get()
|
cfg.option('u2').value.get()
|
||||||
|
@ -158,8 +158,8 @@ def test_cache_reset():
|
||||||
def test_cache_reset_multi():
|
def test_cache_reset_multi():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
cfg = Config(od1)
|
cfg = Config(od1)
|
||||||
values = cfg._config.cfgimpl_get_values()
|
values = cfg._config_bag.context.cfgimpl_get_values()
|
||||||
settings = cfg._config.cfgimpl_get_settings()
|
settings = cfg._config_bag.context.cfgimpl_get_settings()
|
||||||
cfg.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
cfg.option('u3').value.get()
|
cfg.option('u3').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
|
@ -210,12 +210,12 @@ def test_cache_reset_multi():
|
||||||
def test_reset_cache():
|
def test_reset_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
cfg = Config(od1)
|
cfg = Config(od1)
|
||||||
values = cfg._config.cfgimpl_get_values()
|
values = cfg._config_bag.context.cfgimpl_get_values()
|
||||||
settings = cfg._config.cfgimpl_get_settings()
|
settings = cfg._config_bag.context.cfgimpl_get_settings()
|
||||||
cfg.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
cfg._config.cfgimpl_reset_cache(None, None)
|
cfg._config_bag.context.cfgimpl_reset_cache(None, None)
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
assert 'u1' not in settings._p_.get_cached()
|
assert 'u1' not in settings._p_.get_cached()
|
||||||
cfg.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
|
@ -227,7 +227,7 @@ def test_reset_cache():
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' in values._p_.get_cached()
|
assert 'u2' in values._p_.get_cached()
|
||||||
assert 'u2' in settings._p_.get_cached()
|
assert 'u2' in settings._p_.get_cached()
|
||||||
cfg._config.cfgimpl_reset_cache(None, None)
|
cfg._config_bag.context.cfgimpl_reset_cache(None, None)
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
assert 'u1' not in settings._p_.get_cached()
|
assert 'u1' not in settings._p_.get_cached()
|
||||||
assert 'u2' not in values._p_.get_cached()
|
assert 'u2' not in values._p_.get_cached()
|
||||||
|
@ -237,8 +237,8 @@ def test_reset_cache():
|
||||||
def test_cache_not_cache():
|
def test_cache_not_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
cfg = Config(od1)
|
cfg = Config(od1)
|
||||||
values = cfg._config.cfgimpl_get_values()
|
values = cfg._config_bag.context.cfgimpl_get_values()
|
||||||
settings = cfg._config.cfgimpl_get_settings()
|
settings = cfg._config_bag.context.cfgimpl_get_settings()
|
||||||
cfg.property.pop('cache')
|
cfg.property.pop('cache')
|
||||||
cfg.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
|
@ -253,13 +253,13 @@ def test_cache_master_slave():
|
||||||
maconfig = OptionDescription('toto', '', [interface1])
|
maconfig = OptionDescription('toto', '', [interface1])
|
||||||
cfg = Config(maconfig)
|
cfg = Config(maconfig)
|
||||||
cfg.property.read_write()
|
cfg.property.read_write()
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {}
|
||||||
#
|
#
|
||||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||||
cache = cfg._config.cfgimpl_get_values()._p_.get_cached()
|
cache = cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
||||||
else:
|
else:
|
||||||
|
@ -269,7 +269,7 @@ def test_cache_master_slave():
|
||||||
#assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([None])
|
#assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([None])
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None]
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None]
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
||||||
cache = cfg._config.cfgimpl_get_settings()._p_.get_cached()
|
cache = cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached()
|
||||||
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||||
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
||||||
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
||||||
|
@ -282,7 +282,7 @@ def test_cache_master_slave():
|
||||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()
|
||||||
cache = cfg._config.cfgimpl_get_values()._p_.get_cached()
|
cache = cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
||||||
else:
|
else:
|
||||||
|
@ -293,7 +293,7 @@ def test_cache_master_slave():
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None, None]
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None, None]
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][1][0] is None
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][1][0] is None
|
||||||
cache = cfg._config.cfgimpl_get_settings()._p_.get_cached()
|
cache = cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached()
|
||||||
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||||
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
||||||
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
||||||
|
@ -329,79 +329,79 @@ def test_cache_callback():
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
cfg.property.pop('expire')
|
cfg.property.pop('expire')
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('val', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('val', None)},
|
||||||
'val2': {None: ('val', None)},
|
'val2': {None: ('val', None)},
|
||||||
'val3': {None: ('yes', None)},
|
'val3': {None: ('yes', None)},
|
||||||
'val4': {None: ('val', None)},
|
'val4': {None: ('val', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
cfg.option('val1').value.set('new')
|
cfg.option('val1').value.set('new')
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val3': {None: ('yes', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val3': {None: ('yes', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('yes', None)},
|
'val3': {None: ('yes', None)},
|
||||||
'val4': {None: ('new', None)},
|
'val4': {None: ('new', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
cfg.option('val3').value.set('new2')
|
cfg.option('val3').value.set('new2')
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)}}
|
# 'val3': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val4': {None: ('new', None)},
|
'val4': {None: ('new', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)}}
|
# 'val3': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new', None)},
|
'val4': {None: ('new', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
cfg.option('val4').value.set('new3')
|
cfg.option('val4').value.set('new3')
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
# 'val4': {None: (set([]), None)}}
|
# 'val4': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
# 'val4': {None: (set([]), None)}}
|
# 'val4': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new3', None)},
|
'val4': {None: ('new3', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
cfg.option('val5').value.set([undefined, 'new4'])
|
cfg.option('val5').value.set([undefined, 'new4'])
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
# 'val4': {None: (set([]), None)},
|
# 'val4': {None: (set([]), None)},
|
||||||
# 'val5': {None: (set(['empty']), None)}}
|
# 'val5': {None: (set(['empty']), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new3', None)}})
|
'val4': {None: ('new3', None)}})
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
# 'val4': {None: (set([]), None)},
|
# 'val4': {None: (set([]), None)},
|
||||||
# 'val5': {None: (set(['empty']), None)}}
|
# 'val5': {None: (set(['empty']), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new3', None)},
|
'val4': {None: ('new3', None)},
|
||||||
|
@ -435,19 +435,19 @@ def test_cache_master_and_slaves_master():
|
||||||
#None because no value
|
#None because no value
|
||||||
idx_val2 = None
|
idx_val2 = None
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {}
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
else:
|
else:
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
||||||
'val1': {None: (val1_props, None)},
|
'val1': {None: (val1_props, None)},
|
||||||
'val1.val1': {None: (val1_val1_props, None)},
|
'val1.val1': {None: (val1_val1_props, None)},
|
||||||
'val1.val2': {idx_val2: (val1_val2_props, None)}})
|
'val1.val2': {idx_val2: (val1_val2_props, None)}})
|
||||||
# len is 0 so don't get any value
|
# len is 0 so don't get any value
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
||||||
#
|
#
|
||||||
cfg.option('val1.val1').value.set([undefined])
|
cfg.option('val1.val1').value.set([undefined])
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
val_val2 = [None]
|
val_val2 = [None]
|
||||||
|
@ -457,30 +457,30 @@ def test_cache_master_and_slaves_master():
|
||||||
idx_val2 = 0
|
idx_val2 = 0
|
||||||
val_val2 = None
|
val_val2 = None
|
||||||
val_val2_props = {idx_val2: (val1_val2_props, None), None: (set(), None)}
|
val_val2_props = {idx_val2: (val1_val2_props, None), None: (set(), None)}
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
||||||
'val1': {None: (val1_props, None)},
|
'val1': {None: (val1_props, None)},
|
||||||
'val1.val1': {None: (val1_val1_props, None)},
|
'val1.val1': {None: (val1_val1_props, None)},
|
||||||
'val1.val2': val_val2_props})
|
'val1.val2': val_val2_props})
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([None], None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([None], None)},
|
||||||
'val1.val2': {idx_val2: (val_val2, None)}})
|
'val1.val2': {idx_val2: (val_val2, None)}})
|
||||||
cfg.option('val1.val1').value.set([undefined, undefined])
|
cfg.option('val1.val1').value.set([undefined, undefined])
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
cfg.option('val1.val2', 1).value.set('oui')
|
cfg.option('val1.val2', 1).value.set('oui')
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
val1_val2_props = {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}
|
val1_val2_props = {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}
|
||||||
else:
|
else:
|
||||||
val1_val2_props = {0: (frozenset([]), None), 1: (frozenset([]), None)}
|
val1_val2_props = {0: (frozenset([]), None), 1: (frozenset([]), None)}
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (global_props, None)},
|
#assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (global_props, None)},
|
||||||
# 'val1': {None: (val1_props, None)},
|
# 'val1': {None: (val1_props, None)},
|
||||||
# 'val1.val1': {None: (val1_val1_props, None)},
|
# 'val1.val1': {None: (val1_val1_props, None)},
|
||||||
# 'val1.val2': val1_val2_props}
|
# 'val1.val2': val1_val2_props}
|
||||||
#if TIRAMISU_VERSION == 2:
|
#if TIRAMISU_VERSION == 2:
|
||||||
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
# assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
||||||
# 'val1.val2': {None: ([None, 'oui'], None)}}
|
# 'val1.val2': {None: ([None, 'oui'], None)}}
|
||||||
#else:
|
#else:
|
||||||
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
# assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
||||||
# 'val1.val2': {0: (None, None), 1: ('oui', None)}}
|
# 'val1.val2': {0: (None, None), 1: ('oui', None)}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -509,22 +509,22 @@ def test_cache_master_callback():
|
||||||
val1_val1_props = frozenset(val1_val1_props)
|
val1_val1_props = frozenset(val1_val1_props)
|
||||||
val1_val2_props = frozenset(val1_val2_props)
|
val1_val2_props = frozenset(val1_val2_props)
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {}
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
else:
|
else:
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
||||||
'val1': {None: (val1_props, None)},
|
'val1': {None: (val1_props, None)},
|
||||||
'val1.val1': {None: (val1_val1_props, None)},
|
'val1.val1': {None: (val1_val1_props, None)},
|
||||||
'val1.val2': {None: (val1_val2_props, None)}})
|
'val1.val2': {None: (val1_val2_props, None)}})
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
||||||
cfg.option('val1.val1').value.set([undefined])
|
cfg.option('val1.val1').value.set([undefined])
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
||||||
|
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
#FIXMEassert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#FIXMEassert cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
#FIXMEassert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
#FIXMEassert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
||||||
# 'val1.val2': {None: ([None], None)}
|
# 'val1.val2': {None: ([None], None)}
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
@ -538,46 +538,46 @@ def test_cache_requires():
|
||||||
cfg.property.read_write()
|
cfg.property.read_write()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
cfg.property.pop('expire')
|
cfg.property.pop('expire')
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
assert cfg.option('ip_address_service').value.get() == None
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
||||||
else:
|
else:
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
cfg.option('ip_address_service').value.set('1.1.1.1')
|
cfg.option('ip_address_service').value.set('1.1.1.1')
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)}})
|
'activate_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (True, None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (True, None)}})
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: ('1.1.1.1', None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: ('1.1.1.1', None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
cfg.option('activate_service').value.set(False)
|
cfg.option('activate_service').value.set(False)
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
||||||
|
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
cfg.config.dict()
|
cfg.config.dict()
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set(['disabled']), None)}})
|
'ip_address_service': {None: (set(['disabled']), None)}})
|
||||||
|
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (False, None)}})
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (False, None)}})
|
||||||
|
|
||||||
|
|
||||||
def test_cache_global_properties():
|
def test_cache_global_properties():
|
||||||
|
@ -587,25 +587,25 @@ def test_cache_global_properties():
|
||||||
od = OptionDescription('service', '', [a, b])
|
od = OptionDescription('service', '', [a, b])
|
||||||
cfg = Config(od)
|
cfg = Config(od)
|
||||||
cfg.property.read_write()
|
cfg.property.read_write()
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
assert cfg.option('ip_address_service').value.get() == None
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
assert cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
||||||
else:
|
else:
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(cfg._config_bag.context.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
cfg.property.pop('disabled')
|
cfg.property.pop('disabled')
|
||||||
assert cfg.option('ip_address_service').value.get() == None
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
cfg.property.add('test')
|
cfg.property.add('test')
|
||||||
assert cfg.option('ip_address_service').value.get() == None
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings', 'test']), None)},
|
compare(cfg._config_bag.context.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings', 'test']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
|
|
|
@ -145,17 +145,6 @@ def test_information_config():
|
||||||
raises(ValueError, "config.information.reset('noinfo')")
|
raises(ValueError, "config.information.reset('noinfo')")
|
||||||
|
|
||||||
|
|
||||||
def test_config_impl_get_path_by_opt():
|
|
||||||
descr = make_description()
|
|
||||||
config = Config(descr)
|
|
||||||
dummy = config.option('gc.dummy').option.get()
|
|
||||||
boo = config.option('bool').option.get()
|
|
||||||
unknown = IntOption('test', '')
|
|
||||||
unknown
|
|
||||||
assert config._config.cfgimpl_get_description().impl_get_path_by_opt(boo) == 'bool'
|
|
||||||
assert config._config.cfgimpl_get_description().impl_get_path_by_opt(dummy) == 'gc.dummy'
|
|
||||||
|
|
||||||
|
|
||||||
def to_tuple(val):
|
def to_tuple(val):
|
||||||
ret = []
|
ret = []
|
||||||
for v in val:
|
for v in val:
|
||||||
|
|
|
@ -19,7 +19,7 @@ def test_deref_storage():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
c = Config(o)
|
c = Config(o)
|
||||||
w = weakref.ref(c._config.cfgimpl_get_values()._p_)
|
w = weakref.ref(c._config_bag.context.cfgimpl_get_values()._p_)
|
||||||
del(c)
|
del(c)
|
||||||
assert w() is None
|
assert w() is None
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ def test_deref_value():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
c = Config(o)
|
c = Config(o)
|
||||||
w = weakref.ref(c._config.cfgimpl_get_values())
|
w = weakref.ref(c._config_bag.context.cfgimpl_get_values())
|
||||||
del(c)
|
del(c)
|
||||||
assert w() is None
|
assert w() is None
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ def test_deref_setting():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
c = Config(o)
|
c = Config(o)
|
||||||
w = weakref.ref(c._config.cfgimpl_get_settings())
|
w = weakref.ref(c._config_bag.context.cfgimpl_get_settings())
|
||||||
del(c)
|
del(c)
|
||||||
assert w() is None
|
assert w() is None
|
||||||
|
|
||||||
|
|
|
@ -199,26 +199,26 @@ def test_meta_meta_set():
|
||||||
errors2 = meta.value.set('od1.i6', 7, only_config=True)
|
errors2 = meta.value.set('od1.i6', 7, only_config=True)
|
||||||
assert len(errors1) == 0
|
assert len(errors1) == 0
|
||||||
assert len(errors2) == 2
|
assert len(errors2) == 2
|
||||||
conf1 = meta.config('meta.conf1')._config
|
conf1 = meta.config('meta.conf1')._config_bag.context
|
||||||
conf2 = meta.config('meta.conf2')._config
|
conf2 = meta.config('meta.conf2')._config_bag.context
|
||||||
assert meta.config('meta.conf1').option('od1.i1').value.get() == meta.config('meta.conf2').option('od1.i1').value.get() == 7
|
assert meta.config('meta.conf1').option('od1.i1').value.get() == meta.config('meta.conf2').option('od1.i1').value.get() == 7
|
||||||
#
|
#
|
||||||
dconfigs = []
|
dconfigs = []
|
||||||
for conf in meta.config.find('i1', value=7, first=True).config.list():
|
for conf in meta.config.find('i1', value=7, first=True).config.list():
|
||||||
dconfigs.append(conf._config)
|
dconfigs.append(conf._config_bag.context)
|
||||||
assert [conf1, conf2] == dconfigs
|
assert [conf1, conf2] == dconfigs
|
||||||
meta.config('meta.conf1').option('od1.i1').value.set(8)
|
meta.config('meta.conf1').option('od1.i1').value.set(8)
|
||||||
#
|
#
|
||||||
dconfigs = []
|
dconfigs = []
|
||||||
for conf in meta.config.find('i1', first=True).config.list():
|
for conf in meta.config.find('i1', first=True).config.list():
|
||||||
dconfigs.append(conf._config)
|
dconfigs.append(conf._config_bag.context)
|
||||||
assert [conf1, conf2] == dconfigs
|
assert [conf1, conf2] == dconfigs
|
||||||
assert conf2 == list(meta.config.find('i1', value=7, first=True).config.list())[0]._config
|
assert conf2 == list(meta.config.find('i1', value=7, first=True).config.list())[0]._config_bag.context
|
||||||
assert conf1 == list(meta.config.find('i1', value=8, first=True).config.list())[0]._config
|
assert conf1 == list(meta.config.find('i1', value=8, first=True).config.list())[0]._config_bag.context
|
||||||
#
|
#
|
||||||
dconfigs = []
|
dconfigs = []
|
||||||
for conf in meta.config.find('i5', value=2, first=True).config.list():
|
for conf in meta.config.find('i5', value=2, first=True).config.list():
|
||||||
dconfigs.append(conf._config)
|
dconfigs.append(conf._config_bag.context)
|
||||||
assert [conf1, conf2] == dconfigs
|
assert [conf1, conf2] == dconfigs
|
||||||
#
|
#
|
||||||
raises(AttributeError, "meta.config.find('i1', value=10, first=True)")
|
raises(AttributeError, "meta.config.find('i1', value=10, first=True)")
|
||||||
|
@ -258,8 +258,8 @@ def test_group_find_firsts():
|
||||||
conf2 = Config(od2, session_id='conf2')
|
conf2 = Config(od2, session_id='conf2')
|
||||||
grp = GroupConfig([conf1, conf2])
|
grp = GroupConfig([conf1, conf2])
|
||||||
itr = grp.config.find('i1', first=True).config.list()
|
itr = grp.config.find('i1', first=True).config.list()
|
||||||
conf1._config == next(itr)._config
|
conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
conf2._config == next(itr)._config
|
conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
|
|
||||||
|
|
||||||
def test_group_group():
|
def test_group_group():
|
||||||
|
@ -307,20 +307,20 @@ def test_meta_master_slaves():
|
||||||
meta = MetaConfig([conf1, conf2])
|
meta = MetaConfig([conf1, conf2])
|
||||||
meta.property.read_only()
|
meta.property.read_only()
|
||||||
itr = meta.config.find('ip_admin_eth0', first=True).config.list()
|
itr = meta.config.find('ip_admin_eth0', first=True).config.list()
|
||||||
assert conf1._config == next(itr)._config
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
assert conf2._config == next(itr)._config
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
itr = meta.config.find('netmask_admin_eth0', first=True).config.list()
|
itr = meta.config.find('netmask_admin_eth0', first=True).config.list()
|
||||||
assert conf1._config == next(itr)._config
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
assert conf2._config == next(itr)._config
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
meta.property.read_write()
|
meta.property.read_write()
|
||||||
raises(AttributeError, "meta.config.find('netmask_admin_eth0', first=True)")
|
raises(AttributeError, "meta.config.find('netmask_admin_eth0', first=True)")
|
||||||
itr = meta.unrestraint.config.find('netmask_admin_eth0', first=True).config.list()
|
itr = meta.unrestraint.config.find('netmask_admin_eth0', first=True).config.list()
|
||||||
assert conf1._config == next(itr)._config
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
assert conf2._config == next(itr)._config
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
meta.property.read_only()
|
meta.property.read_only()
|
||||||
itr = meta.config.find('netmask_admin_eth0', first=True).config.list()
|
itr = meta.config.find('netmask_admin_eth0', first=True).config.list()
|
||||||
assert conf1._config == next(itr)._config
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
assert conf2._config == next(itr)._config
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
|
|
||||||
|
|
||||||
def test_meta_master_slaves_value2():
|
def test_meta_master_slaves_value2():
|
||||||
|
|
|
@ -79,6 +79,7 @@ def test_permissive_frozen():
|
||||||
api.property.read_write()
|
api.property.read_write()
|
||||||
api.unrestraint.permissive.set(frozenset(['frozen', 'disabled']))
|
api.unrestraint.permissive.set(frozenset(['frozen', 'disabled']))
|
||||||
assert api.unrestraint.permissive.get() == frozenset(['frozen', 'disabled'])
|
assert api.unrestraint.permissive.get() == frozenset(['frozen', 'disabled'])
|
||||||
|
assert api.permissive.get() == frozenset(['frozen', 'disabled'])
|
||||||
try:
|
try:
|
||||||
api.option('u1').value.set(1)
|
api.option('u1').value.set(1)
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
|
|
|
@ -150,14 +150,14 @@ def test_slots_config():
|
||||||
od1 = OptionDescription('a', '', [])
|
od1 = OptionDescription('a', '', [])
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
raises(AttributeError, "c._config.x = 1")
|
raises(AttributeError, "c._config_bag.context.x = 1")
|
||||||
raises(AttributeError, "c._config.cfgimpl_x = 1")
|
raises(AttributeError, "c._config_bag.context.cfgimpl_x = 1")
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(od2,
|
option_bag.set_option(od2,
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
ConfigBag(c._config))
|
ConfigBag(c._config_bag.context))
|
||||||
sc = c._config.get_subconfig('a', option_bag)
|
sc = c._config_bag.context.get_subconfig('a', option_bag)
|
||||||
assert isinstance(sc, SubConfig)
|
assert isinstance(sc, SubConfig)
|
||||||
raises(AttributeError, "sc.x = 1")
|
raises(AttributeError, "sc.x = 1")
|
||||||
raises(AttributeError, "sc.cfgimpl_x = 1")
|
raises(AttributeError, "sc.cfgimpl_x = 1")
|
||||||
|
@ -167,7 +167,7 @@ def test_slots_setting():
|
||||||
od1 = OptionDescription('a', '', [])
|
od1 = OptionDescription('a', '', [])
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
s = c._config.cfgimpl_get_settings()
|
s = c._config_bag.context.cfgimpl_get_settings()
|
||||||
s
|
s
|
||||||
raises(AttributeError, "s.x = 1")
|
raises(AttributeError, "s.x = 1")
|
||||||
|
|
||||||
|
@ -176,6 +176,6 @@ def test_slots_value():
|
||||||
od1 = OptionDescription('a', '', [])
|
od1 = OptionDescription('a', '', [])
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
v = c._config.cfgimpl_get_values()
|
v = c._config_bag.context.cfgimpl_get_values()
|
||||||
v
|
v
|
||||||
raises(AttributeError, "v.x = 1")
|
raises(AttributeError, "v.x = 1")
|
||||||
|
|
|
@ -223,7 +223,7 @@ def test_diff_information_config():
|
||||||
b.impl_set_information('info2', 'oh')
|
b.impl_set_information('info2', 'oh')
|
||||||
o = OptionDescription('o', '', [b])
|
o = OptionDescription('o', '', [b])
|
||||||
o1 = OptionDescription('o1', '', [o])
|
o1 = OptionDescription('o1', '', [o])
|
||||||
c = Config(o1)._config
|
c = Config(o1)._config_bag.context
|
||||||
raises(NotImplementedError, "dumps(c)")
|
raises(NotImplementedError, "dumps(c)")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class CommonTiramisu(TiramisuHelp):
|
||||||
if option is None:
|
if option is None:
|
||||||
option = self.subconfig.cfgimpl_get_description().impl_getchild(self._name,
|
option = self.subconfig.cfgimpl_get_description().impl_getchild(self._name,
|
||||||
self.option_bag.config_bag,
|
self.option_bag.config_bag,
|
||||||
self.subconfig)
|
self.subconfig.cfgimpl_get_path())
|
||||||
self.option_bag.set_option(option,
|
self.option_bag.set_option(option,
|
||||||
self.option_bag.path,
|
self.option_bag.path,
|
||||||
self.option_bag.index,
|
self.option_bag.index,
|
||||||
|
@ -145,8 +145,8 @@ class CommonTiramisuOption(CommonTiramisu):
|
||||||
self.option_bag = option_bag
|
self.option_bag = option_bag
|
||||||
self._name = name
|
self._name = name
|
||||||
self.subconfig = subconfig
|
self.subconfig = subconfig
|
||||||
|
# for help()
|
||||||
if option_bag is not None:
|
if option_bag is not None:
|
||||||
# for help()
|
|
||||||
self._get_option()
|
self._get_option()
|
||||||
if option_bag.config_bag is not None and self.slave_need_index:
|
if option_bag.config_bag is not None and self.slave_need_index:
|
||||||
self._test_slave_index()
|
self._test_slave_index()
|
||||||
|
@ -548,11 +548,21 @@ class TiramisuOption(CommonTiramisu):
|
||||||
"""find an option by name (only for optiondescription)"""
|
"""find an option by name (only for optiondescription)"""
|
||||||
if not first:
|
if not first:
|
||||||
ret = []
|
ret = []
|
||||||
for path in self.config_bag.context.find(byname=name,
|
option = self._get_option()
|
||||||
byvalue=value,
|
oname = option.impl_getname()
|
||||||
bytype=type,
|
path = self.subconfig._get_subpath(oname)
|
||||||
_subpath=self._path,
|
option_bag = OptionBag()
|
||||||
config_bag=self.config_bag):
|
option_bag.set_option(option,
|
||||||
|
path,
|
||||||
|
None,
|
||||||
|
self.config_bag)
|
||||||
|
subconfig = self.subconfig.get_subconfig(oname,
|
||||||
|
option_bag)
|
||||||
|
for path in subconfig.find(byname=name,
|
||||||
|
byvalue=value,
|
||||||
|
bytype=type,
|
||||||
|
_subpath=self._path,
|
||||||
|
config_bag=self.config_bag):
|
||||||
subconfig, name = self.config_bag.context.cfgimpl_get_home_by_path(path,
|
subconfig, name = self.config_bag.context.cfgimpl_get_home_by_path(path,
|
||||||
self.config_bag)
|
self.config_bag)
|
||||||
t_option = TiramisuOption(name,
|
t_option = TiramisuOption(name,
|
||||||
|
@ -569,7 +579,7 @@ class TiramisuOption(CommonTiramisu):
|
||||||
self._get_option()
|
self._get_option()
|
||||||
current_option = self.option_bag.option.impl_getchild(name,
|
current_option = self.option_bag.option.impl_getchild(name,
|
||||||
self.config_bag,
|
self.config_bag,
|
||||||
self.subconfig)
|
self.subconfig.cfgimpl_get_path)
|
||||||
path = self.option_bag.path + '.' + name
|
path = self.option_bag.path + '.' + name
|
||||||
option_bag= OptionBag()
|
option_bag= OptionBag()
|
||||||
option_bag.set_option(current_option,
|
option_bag.set_option(current_option,
|
||||||
|
@ -614,8 +624,8 @@ class TiramisuOption(CommonTiramisu):
|
||||||
self.subconfig.get_subconfig(name,
|
self.subconfig.get_subconfig(name,
|
||||||
option_bag)
|
option_bag)
|
||||||
else:
|
else:
|
||||||
self.subconfig.getattr(name,
|
subconfig.getattr(name,
|
||||||
option_bag)
|
option_bag)
|
||||||
|
|
||||||
option = self._get_option()
|
option = self._get_option()
|
||||||
name = option.impl_getname()
|
name = option.impl_getname()
|
||||||
|
@ -738,10 +748,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
"""set configuration to read only mode"""
|
"""set configuration to read only mode"""
|
||||||
settings = self.config_bag.context.cfgimpl_get_settings()
|
settings = self.config_bag.context.cfgimpl_get_settings()
|
||||||
settings.read_only(self.config_bag.context)
|
settings.read_only(self.config_bag.context)
|
||||||
try:
|
del self.config_bag.properties
|
||||||
del self.config_bag.properties
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def read_write(self):
|
def read_write(self):
|
||||||
"""set configuration to read and write mode"""
|
"""set configuration to read and write mode"""
|
||||||
|
@ -750,17 +757,15 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
# #FIXME ?
|
# #FIXME ?
|
||||||
permissives = frozenset(settings.get_context_permissives() | frozenset(['hidden']))
|
permissives = frozenset(settings.get_context_permissives() | frozenset(['hidden']))
|
||||||
settings.set_context_permissives(permissives)
|
settings.set_context_permissives(permissives)
|
||||||
try:
|
|
||||||
del self.config_bag.properties
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
#/FIXME ?
|
#/FIXME ?
|
||||||
|
del self.config_bag.properties
|
||||||
|
|
||||||
def add(self, prop):
|
def add(self, prop):
|
||||||
"""add a configuration property"""
|
"""add a configuration property"""
|
||||||
props = self.get()
|
props = self.get()
|
||||||
props.add(prop)
|
props.add(prop)
|
||||||
self.set(frozenset(props))
|
self.set(frozenset(props))
|
||||||
|
del self.config_bag.properties
|
||||||
|
|
||||||
def pop(self, prop):
|
def pop(self, prop):
|
||||||
"""remove a configuration property"""
|
"""remove a configuration property"""
|
||||||
|
@ -768,6 +773,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
if prop in props:
|
if prop in props:
|
||||||
props.remove(prop)
|
props.remove(prop)
|
||||||
self.set(frozenset(props))
|
self.set(frozenset(props))
|
||||||
|
del self.config_bag.properties
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
"""get all configuration properties"""
|
"""get all configuration properties"""
|
||||||
|
@ -778,12 +784,14 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
context = self.config_bag.context
|
context = self.config_bag.context
|
||||||
context.cfgimpl_get_settings().set_context_properties(props,
|
context.cfgimpl_get_settings().set_context_properties(props,
|
||||||
context)
|
context)
|
||||||
|
del self.config_bag.properties
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""remove configuration properties"""
|
"""remove configuration properties"""
|
||||||
context = self.config_bag.context
|
context = self.config_bag.context
|
||||||
context.cfgimpl_get_settings().reset(None,
|
context.cfgimpl_get_settings().reset(None,
|
||||||
context)
|
context)
|
||||||
|
del self.config_bag.properties
|
||||||
|
|
||||||
def exportation(self):
|
def exportation(self):
|
||||||
"""export configuration properties"""
|
"""export configuration properties"""
|
||||||
|
@ -794,6 +802,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
self.config_bag.context.cfgimpl_get_settings()._p_.importation(properties)
|
self.config_bag.context.cfgimpl_get_settings()._p_.importation(properties)
|
||||||
self.config_bag.context.cfgimpl_reset_cache(None,
|
self.config_bag.context.cfgimpl_reset_cache(None,
|
||||||
None)
|
None)
|
||||||
|
del self.config_bag.properties
|
||||||
|
|
||||||
|
|
||||||
class TiramisuContextPermissive(TiramisuContext):
|
class TiramisuContextPermissive(TiramisuContext):
|
||||||
|
@ -806,6 +815,7 @@ class TiramisuContextPermissive(TiramisuContext):
|
||||||
def set(self, permissives):
|
def set(self, permissives):
|
||||||
"""set configuration permissives"""
|
"""set configuration permissives"""
|
||||||
self.config_bag.context.cfgimpl_get_settings().set_context_permissives(permissives)
|
self.config_bag.context.cfgimpl_get_settings().set_context_permissives(permissives)
|
||||||
|
del self.config_bag.permissives
|
||||||
|
|
||||||
def exportation(self):
|
def exportation(self):
|
||||||
"""export configuration permissives"""
|
"""export configuration permissives"""
|
||||||
|
@ -816,6 +826,7 @@ class TiramisuContextPermissive(TiramisuContext):
|
||||||
self.config_bag.context.cfgimpl_get_settings()._pp_.importation(permissives)
|
self.config_bag.context.cfgimpl_get_settings()._pp_.importation(permissives)
|
||||||
self.config_bag.context.cfgimpl_reset_cache(None,
|
self.config_bag.context.cfgimpl_reset_cache(None,
|
||||||
None)
|
None)
|
||||||
|
del self.config_bag.permissives
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -918,9 +929,9 @@ class TiramisuContextConfig(TiramisuContext):
|
||||||
first: bool=False):
|
first: bool=False):
|
||||||
"""find a path from option name and optionnaly a value to MetaConfig or GroupConfig"""
|
"""find a path from option name and optionnaly a value to MetaConfig or GroupConfig"""
|
||||||
if first:
|
if first:
|
||||||
return TiramisuAPI(self.config_bag.context.find_firsts(byname=name,
|
return Config(self.config_bag.context.find_firsts(byname=name,
|
||||||
byvalue=value,
|
byvalue=value,
|
||||||
config_bag=self.config_bag))
|
config_bag=self.config_bag))
|
||||||
else:
|
else:
|
||||||
raise APIError('not implemented yet')
|
raise APIError('not implemented yet')
|
||||||
|
|
||||||
|
@ -929,25 +940,25 @@ class TiramisuContextConfig(TiramisuContext):
|
||||||
|
|
||||||
def _c_copy(self,
|
def _c_copy(self,
|
||||||
session_id=None):
|
session_id=None):
|
||||||
return TiramisuAPI(self.config_bag.context.duplicate(session_id))
|
return Config(self.config_bag.context.duplicate(session_id))
|
||||||
|
|
||||||
def _c_deepcopy(self,
|
def _c_deepcopy(self,
|
||||||
session_id=None):
|
session_id=None):
|
||||||
return TiramisuAPI(self.config_bag.context.duplicate(session_id,
|
return Config(self.config_bag.context.duplicate(session_id,
|
||||||
deep=True))
|
deep=True))
|
||||||
|
|
||||||
def _c_meta(self):
|
def _c_meta(self):
|
||||||
return TiramisuAPI(self.config_bag.context.cfgimpl_get_meta())
|
return Config(self.config_bag.context.cfgimpl_get_meta())
|
||||||
|
|
||||||
def _m_new(self, name):
|
def _m_new(self, name):
|
||||||
return TiramisuAPI(self.config_bag.context.new_config(name))
|
return Config(self.config_bag.context.new_config(name))
|
||||||
|
|
||||||
def _m_list(self):
|
def _m_list(self):
|
||||||
return self._g_list()
|
return self._g_list()
|
||||||
|
|
||||||
def _g_list(self):
|
def _g_list(self):
|
||||||
for child in self.config_bag.context.cfgimpl_get_children():
|
for child in self.config_bag.context.cfgimpl_get_children():
|
||||||
yield TiramisuAPI(child)
|
yield Config(child)
|
||||||
|
|
||||||
def __getattr__(self,
|
def __getattr__(self,
|
||||||
name: str) -> Callable:
|
name: str) -> Callable:
|
||||||
|
@ -990,32 +1001,25 @@ class TiramisuAPI(TiramisuHelp):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
config) -> None:
|
config) -> None:
|
||||||
self._config = config
|
if not isinstance(config, ConfigBag):
|
||||||
|
config = ConfigBag(context=config)
|
||||||
|
self._config_bag = config
|
||||||
if not self.registers:
|
if not self.registers:
|
||||||
registers(self.registers, 'TiramisuContext')
|
registers(self.registers, 'TiramisuContext')
|
||||||
registers(self.registers, 'TiramisuDispatcher')
|
registers(self.registers, 'TiramisuDispatcher')
|
||||||
|
|
||||||
def __getattr__(self, subfunc: str) -> Any:
|
def __getattr__(self, subfunc: str) -> Any:
|
||||||
if subfunc == 'forcepermissive':
|
if subfunc == 'forcepermissive':
|
||||||
if isinstance(self._config, ConfigBag):
|
config_bag = self._config_bag.copy()
|
||||||
config_bag = self._config.copy()
|
|
||||||
del config_bag.properties
|
|
||||||
else:
|
|
||||||
config_bag = ConfigBag(context=self._config)
|
|
||||||
config_bag.set_permissive()
|
config_bag.set_permissive()
|
||||||
return TiramisuAPI(config_bag)
|
return TiramisuAPI(config_bag)
|
||||||
elif subfunc == 'unrestraint':
|
elif subfunc == 'unrestraint':
|
||||||
if isinstance(self._config, ConfigBag):
|
config_bag = self._config_bag.copy()
|
||||||
config_bag = self._config.copy()
|
|
||||||
else:
|
|
||||||
config_bag = ConfigBag(context=self._config)
|
|
||||||
config_bag.properties = frozenset()
|
config_bag.properties = frozenset()
|
||||||
return TiramisuAPI(config_bag)
|
return TiramisuAPI(config_bag)
|
||||||
elif subfunc in self.registers:
|
elif subfunc in self.registers:
|
||||||
if not isinstance(self._config, ConfigBag):
|
config_bag = self._config_bag
|
||||||
config_bag = ConfigBag(context=self._config)
|
del config_bag.permissives
|
||||||
else:
|
|
||||||
config_bag = self._config
|
|
||||||
return self.registers[subfunc](config_bag)
|
return self.registers[subfunc](config_bag)
|
||||||
else:
|
else:
|
||||||
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
||||||
|
@ -1055,7 +1059,7 @@ class Config(TiramisuAPI):
|
||||||
session_id: str=None,
|
session_id: str=None,
|
||||||
persistent: bool=False,
|
persistent: bool=False,
|
||||||
storage=None) -> None:
|
storage=None) -> None:
|
||||||
if not isinstance(descr, (KernelConfig, KernelMetaConfig)):
|
if isinstance(descr, OptionDescription):
|
||||||
config = KernelConfig(descr,
|
config = KernelConfig(descr,
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
persistent=persistent,
|
persistent=persistent,
|
||||||
|
@ -1075,7 +1079,7 @@ class MetaConfig(TiramisuAPI):
|
||||||
_children = []
|
_children = []
|
||||||
for child in children:
|
for child in children:
|
||||||
if isinstance(child, TiramisuAPI):
|
if isinstance(child, TiramisuAPI):
|
||||||
_children.append(child._config)
|
_children.append(child._config_bag.context)
|
||||||
else:
|
else:
|
||||||
_children.append(child)
|
_children.append(child)
|
||||||
|
|
||||||
|
@ -1095,7 +1099,7 @@ class GroupConfig(TiramisuAPI):
|
||||||
storage=None) -> None:
|
storage=None) -> None:
|
||||||
_children = []
|
_children = []
|
||||||
for child in children:
|
for child in children:
|
||||||
_children.append(child._config)
|
_children.append(child._config_bag.context)
|
||||||
|
|
||||||
config = KernelGroupConfig(_children,
|
config = KernelGroupConfig(_children,
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
|
|
|
@ -199,7 +199,7 @@ class SubConfig(object):
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option = self.cfgimpl_get_description().impl_getchild(step,
|
option = self.cfgimpl_get_description().impl_getchild(step,
|
||||||
config_bag,
|
config_bag,
|
||||||
self)
|
self.cfgimpl_get_path())
|
||||||
subpath = self._get_subpath(step)
|
subpath = self._get_subpath(step)
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
subpath,
|
subpath,
|
||||||
|
@ -371,7 +371,7 @@ class SubConfig(object):
|
||||||
"""
|
"""
|
||||||
def _filter_by_value(soption_bag):
|
def _filter_by_value(soption_bag):
|
||||||
try:
|
try:
|
||||||
value = self.getattr(path,
|
value = context.getattr(path,
|
||||||
soption_bag)
|
soption_bag)
|
||||||
except PropertiesOptionError:
|
except PropertiesOptionError:
|
||||||
return False
|
return False
|
||||||
|
@ -386,8 +386,10 @@ class SubConfig(object):
|
||||||
else:
|
else:
|
||||||
options = self.cfgimpl_get_description().impl_get_options_paths(bytype,
|
options = self.cfgimpl_get_description().impl_get_options_paths(bytype,
|
||||||
byname,
|
byname,
|
||||||
_subpath,
|
self.cfgimpl_get_path(),
|
||||||
config_bag)
|
config_bag)
|
||||||
|
options = list(options)
|
||||||
|
context = self.cfgimpl_get_context()
|
||||||
for path, option in options:
|
for path, option in options:
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
|
@ -400,14 +402,14 @@ class SubConfig(object):
|
||||||
#remove option with propertyerror, ...
|
#remove option with propertyerror, ...
|
||||||
try:
|
try:
|
||||||
if '.' in path:
|
if '.' in path:
|
||||||
subconfig, subpath = self.cfgimpl_get_home_by_path(path,
|
subconfig, subpath = context.cfgimpl_get_home_by_path(path,
|
||||||
config_bag)
|
config_bag)
|
||||||
else:
|
else:
|
||||||
subconfig = self
|
subconfig = self
|
||||||
subpath = path
|
subpath = path
|
||||||
subconfig.cfgimpl_get_description().impl_getchild(subpath,
|
subconfig.cfgimpl_get_description().impl_getchild(subpath,
|
||||||
config_bag,
|
config_bag,
|
||||||
subconfig)
|
subconfig.cfgimpl_get_path())
|
||||||
self.cfgimpl_get_settings().validate_properties(option_bag)
|
self.cfgimpl_get_settings().validate_properties(option_bag)
|
||||||
except PropertiesOptionError:
|
except PropertiesOptionError:
|
||||||
continue
|
continue
|
||||||
|
@ -508,7 +510,7 @@ class SubConfig(object):
|
||||||
subpath = path
|
subpath = path
|
||||||
opt = subconfig.cfgimpl_get_description().impl_getchild(subpath,
|
opt = subconfig.cfgimpl_get_description().impl_getchild(subpath,
|
||||||
config_bag,
|
config_bag,
|
||||||
subconfig)
|
subconfig.cfgimpl_get_path())
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(opt,
|
soption_bag.set_option(opt,
|
||||||
path,
|
path,
|
||||||
|
@ -874,7 +876,7 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
cconfig_bag)
|
cconfig_bag)
|
||||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
cconfig_bag,
|
cconfig_bag,
|
||||||
child)
|
child.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
path,
|
||||||
|
@ -919,7 +921,8 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
config_bag=config_bag,
|
config_bag=config_bag,
|
||||||
raise_if_not_found=raise_if_not_found))
|
raise_if_not_found=raise_if_not_found))
|
||||||
byname = None
|
byname = None
|
||||||
byoption = self.cfgimpl_get_description().impl_get_opt_by_path(bypath)
|
byoption = self.cfgimpl_get_description().impl_get_opt_by_path(bypath,
|
||||||
|
config_bag)
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
|
@ -1040,7 +1043,8 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||||
if force_default and force_dont_change_value:
|
if force_default and force_dont_change_value:
|
||||||
raise ValueError(_('force_default and force_dont_change_value'
|
raise ValueError(_('force_default and force_dont_change_value'
|
||||||
' cannot be set together'))
|
' cannot be set together'))
|
||||||
opt = self.cfgimpl_get_description().impl_get_opt_by_path(path)
|
opt = self.cfgimpl_get_description().impl_get_opt_by_path(path,
|
||||||
|
config_bag)
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
cconfig_bag = config_bag.copy()
|
cconfig_bag = config_bag.copy()
|
||||||
cconfig_bag.context = child
|
cconfig_bag.context = child
|
||||||
|
@ -1048,7 +1052,7 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||||
cconfig_bag)
|
cconfig_bag)
|
||||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
cconfig_bag,
|
cconfig_bag,
|
||||||
child)
|
child.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
path,
|
||||||
|
@ -1080,7 +1084,7 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||||
config_bag)
|
config_bag)
|
||||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
config_bag,
|
config_bag,
|
||||||
self)
|
self.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
path,
|
||||||
|
@ -1102,7 +1106,7 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||||
config_bag)
|
config_bag)
|
||||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
config_bag,
|
config_bag,
|
||||||
self)
|
self.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
path,
|
||||||
|
|
|
@ -30,7 +30,7 @@ from ..error import ConfigError, ConflictError
|
||||||
|
|
||||||
|
|
||||||
class CacheOptionDescription(BaseOption):
|
class CacheOptionDescription(BaseOption):
|
||||||
__slots__ = ('_cache_paths', '_cache_consistencies', '_cache_force_store_values')
|
__slots__ = ('_cache_consistencies', '_cache_force_store_values')
|
||||||
|
|
||||||
def _build_cache(self,
|
def _build_cache(self,
|
||||||
config,
|
config,
|
||||||
|
@ -154,7 +154,7 @@ class CacheOptionDescription(BaseOption):
|
||||||
self._set_readonly()
|
self._set_readonly()
|
||||||
|
|
||||||
def impl_already_build_caches(self):
|
def impl_already_build_caches(self):
|
||||||
if hasattr(self, '_cache_paths'):
|
if hasattr(self, '_cache_consistencies'):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -192,11 +192,10 @@ class CacheOptionDescription(BaseOption):
|
||||||
values._p_.commit()
|
values._p_.commit()
|
||||||
|
|
||||||
def _build_cache_option(self,
|
def _build_cache_option(self,
|
||||||
_currpath=None,
|
_currpath=None):
|
||||||
cache_path=None,
|
|
||||||
cache_option=None):
|
|
||||||
|
|
||||||
if self.impl_is_readonly() or (_currpath is None and getattr(self, '_cache_paths', None) is not None):
|
if self.impl_is_readonly() or \
|
||||||
|
(_currpath is None and getattr(self, '_cache_consistencies', None) is not None):
|
||||||
# cache already set
|
# cache already set
|
||||||
return
|
return
|
||||||
if _currpath is None:
|
if _currpath is None:
|
||||||
|
@ -204,24 +203,17 @@ class CacheOptionDescription(BaseOption):
|
||||||
_currpath = []
|
_currpath = []
|
||||||
else:
|
else:
|
||||||
save = False
|
save = False
|
||||||
if cache_path is None:
|
|
||||||
cache_path = []
|
|
||||||
cache_option = []
|
|
||||||
for option in self.impl_getchildren(config_bag=undefined,
|
for option in self.impl_getchildren(config_bag=undefined,
|
||||||
dyn=False):
|
dyn=False):
|
||||||
attr = option.impl_getname()
|
attr = option.impl_getname()
|
||||||
path = str('.'.join(_currpath + [attr]))
|
path = str('.'.join(_currpath + [attr]))
|
||||||
cache_option.append(option)
|
|
||||||
cache_path.append(path)
|
|
||||||
option._path = path
|
option._path = path
|
||||||
if option.impl_is_optiondescription():
|
if option.impl_is_optiondescription():
|
||||||
_currpath.append(attr)
|
_currpath.append(attr)
|
||||||
option._build_cache_option(_currpath,
|
option._build_cache_option(_currpath)
|
||||||
cache_path,
|
|
||||||
cache_option)
|
|
||||||
_currpath.pop()
|
_currpath.pop()
|
||||||
if save:
|
if save and not hasattr(self, '_cache_consistencies'):
|
||||||
self._cache_paths = (tuple(cache_option), tuple(cache_path))
|
self._cache_consistencies = None
|
||||||
|
|
||||||
|
|
||||||
class OptionDescriptionWalk(CacheOptionDescription):
|
class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
|
@ -248,57 +240,43 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
bytype,
|
bytype,
|
||||||
byname,
|
byname,
|
||||||
_subpath,
|
_subpath,
|
||||||
config_bag):
|
config_bag,
|
||||||
def _filter_by_type(path,
|
self_opt=None):
|
||||||
option):
|
if self_opt is None:
|
||||||
if isinstance(option,
|
self_opt = self
|
||||||
bytype):
|
def _filter_by_name(option):
|
||||||
return _filter_by_name(path, option)
|
return byname is None or option.impl_getname() == byname
|
||||||
|
|
||||||
def _filter_by_name(path,
|
for option in self_opt.impl_getchildren(config_bag):
|
||||||
option):
|
if _subpath is None:
|
||||||
name = option.impl_getname()
|
path = option.impl_getname()
|
||||||
if option.issubdyn():
|
else:
|
||||||
if byname.startswith(name):
|
path = _subpath + '.' + option.impl_getname()
|
||||||
option_bag = OptionBag()
|
|
||||||
option_bag.set_option(option,
|
|
||||||
path,
|
|
||||||
None,
|
|
||||||
config_bag)
|
|
||||||
for doption in self.build_dynoptions(option_bag):
|
|
||||||
if byname == doption.impl_getname():
|
|
||||||
dpath = doption.impl_getpath()
|
|
||||||
return (dpath, doption)
|
|
||||||
elif byname == name:
|
|
||||||
return (path, option)
|
|
||||||
|
|
||||||
def _filter(path, option):
|
|
||||||
if bytype is not None:
|
|
||||||
return _filter_by_type(path, option)
|
|
||||||
return _filter_by_name(path, option)
|
|
||||||
|
|
||||||
opts, paths = self._cache_paths
|
|
||||||
for index, option in enumerate(opts):
|
|
||||||
if option.impl_is_optiondescription():
|
if option.impl_is_optiondescription():
|
||||||
continue
|
for subopt in option.impl_get_options_paths(bytype,
|
||||||
path = paths[index]
|
byname,
|
||||||
if _subpath is not None and not path.startswith(_subpath + '.'):
|
path,
|
||||||
continue
|
config_bag):
|
||||||
ret = _filter(path, option)
|
yield subopt
|
||||||
if ret:
|
else:
|
||||||
yield ret
|
if bytype is not None:
|
||||||
|
if isinstance(option, bytype) and \
|
||||||
|
_filter_by_name(option):
|
||||||
|
yield (path, option)
|
||||||
|
elif _filter_by_name(option):
|
||||||
|
yield (path, option)
|
||||||
|
|
||||||
def impl_getchild(self,
|
def impl_getchild(self,
|
||||||
name,
|
name,
|
||||||
config_bag,
|
config_bag,
|
||||||
subconfig):
|
subpath):
|
||||||
if name in self._children[0]:
|
if name in self._children[0]:
|
||||||
child = self._children[1][self._children[0].index(name)]
|
child = self._children[1][self._children[0].index(name)]
|
||||||
if not child.impl_is_dynoptiondescription():
|
if not child.impl_is_dynoptiondescription():
|
||||||
return child
|
return child
|
||||||
else:
|
else:
|
||||||
child = self._impl_search_dynchild(name,
|
child = self._impl_search_dynchild(name,
|
||||||
subconfig,
|
subpath,
|
||||||
config_bag)
|
config_bag)
|
||||||
if child:
|
if child:
|
||||||
return child
|
return child
|
||||||
|
@ -307,12 +285,19 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
'').format(name, self.impl_getname()))
|
'').format(name, self.impl_getname()))
|
||||||
|
|
||||||
def impl_get_opt_by_path(self,
|
def impl_get_opt_by_path(self,
|
||||||
path):
|
path,
|
||||||
return self._cache_paths[0][self._cache_paths[1].index(path)]
|
config_bag):
|
||||||
|
opt = self
|
||||||
def impl_get_path_by_opt(self,
|
subpath = None
|
||||||
opt):
|
for step in path.split('.'):
|
||||||
return self._cache_paths[1][self._cache_paths[0].index(opt)]
|
opt = opt.impl_getchild(step,
|
||||||
|
config_bag,
|
||||||
|
subpath)
|
||||||
|
if subpath is None:
|
||||||
|
subpath = step
|
||||||
|
else:
|
||||||
|
subpath += '.' + step
|
||||||
|
return opt
|
||||||
|
|
||||||
def impl_getchildren(self,
|
def impl_getchildren(self,
|
||||||
config_bag,
|
config_bag,
|
||||||
|
@ -347,7 +332,7 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
|
|
||||||
def _impl_search_dynchild(self,
|
def _impl_search_dynchild(self,
|
||||||
name,
|
name,
|
||||||
subconfig,
|
subpath,
|
||||||
config_bag):
|
config_bag):
|
||||||
for child in self._impl_st_getchildren(only_dyn=True):
|
for child in self._impl_st_getchildren(only_dyn=True):
|
||||||
#sconfig_bag = config_bag.copy('nooption')
|
#sconfig_bag = config_bag.copy('nooption')
|
||||||
|
@ -356,13 +341,13 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
if name.startswith(cname):
|
if name.startswith(cname):
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(child,
|
option_bag.set_option(child,
|
||||||
subconfig.cfgimpl_get_path(),
|
subpath,
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
for value in child.impl_get_suffixes(option_bag):
|
for value in child.impl_get_suffixes(option_bag):
|
||||||
if name == cname + value:
|
if name == cname + value:
|
||||||
return SynDynOptionDescription(child,
|
return SynDynOptionDescription(child,
|
||||||
subconfig.cfgimpl_get_path(),
|
subpath,
|
||||||
value)
|
value)
|
||||||
|
|
||||||
def _impl_get_dynchild(self,
|
def _impl_get_dynchild(self,
|
||||||
|
@ -424,7 +409,7 @@ class OptionDescription(OptionDescriptionWalk):
|
||||||
'the dynoptiondescription\'s name "{}"').format(child, dynopt))
|
'the dynoptiondescription\'s name "{}"').format(child, dynopt))
|
||||||
old = child
|
old = child
|
||||||
self._children = children_
|
self._children = children_
|
||||||
self._cache_consistencies = None
|
#self._cache_consistencies = None
|
||||||
# the group_type is useful for filtering OptionDescriptions in a config
|
# the group_type is useful for filtering OptionDescriptions in a config
|
||||||
self._group_type = groups.default
|
self._group_type = groups.default
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,14 @@ class SynDynOptionDescription(object):
|
||||||
def impl_getchild(self,
|
def impl_getchild(self,
|
||||||
name,
|
name,
|
||||||
config_bag,
|
config_bag,
|
||||||
subconfig):
|
subpath):
|
||||||
try:
|
try:
|
||||||
if name.endswith(self._suffix):
|
if name.endswith(self._suffix):
|
||||||
oname = name[:-len(self._suffix)]
|
oname = name[:-len(self._suffix)]
|
||||||
child = self._children[1][self._children[0].index(oname)]
|
child = self._children[1][self._children[0].index(oname)]
|
||||||
return self._impl_get_dynchild(child,
|
return self._impl_get_dynchild(child,
|
||||||
self._suffix,
|
self._suffix,
|
||||||
subconfig.cfgimpl_get_path())
|
subpath)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# when oname not in self._children
|
# when oname not in self._children
|
||||||
pass
|
pass
|
||||||
|
@ -72,6 +72,17 @@ class SynDynOptionDescription(object):
|
||||||
self._suffix,
|
self._suffix,
|
||||||
subpath))
|
subpath))
|
||||||
|
|
||||||
|
def impl_get_options_paths(self,
|
||||||
|
bytype,
|
||||||
|
byname,
|
||||||
|
_subpath,
|
||||||
|
config_bag):
|
||||||
|
return self._opt.impl_get_options_paths(bytype,
|
||||||
|
byname,
|
||||||
|
_subpath,
|
||||||
|
config_bag,
|
||||||
|
self)
|
||||||
|
|
||||||
def impl_getpath(self):
|
def impl_getpath(self):
|
||||||
subpath = self._subpath
|
subpath = self._subpath
|
||||||
if subpath != '':
|
if subpath != '':
|
||||||
|
|
|
@ -175,7 +175,6 @@ class ConfigBag:
|
||||||
'permissives', # permissives for current context
|
'permissives', # permissives for current context
|
||||||
)
|
)
|
||||||
def __init__(self, context, **kwargs):
|
def __init__(self, context, **kwargs):
|
||||||
#self.force_permissive = False
|
|
||||||
self.context = context
|
self.context = context
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
@ -196,10 +195,17 @@ class ConfigBag:
|
||||||
self.properties = frozenset(self.properties | {'permissive'})
|
self.properties = frozenset(self.properties | {'permissive'})
|
||||||
|
|
||||||
def __delattr__(self, key):
|
def __delattr__(self, key):
|
||||||
if key == 'properties':
|
if key in ['properties', 'permissives']:
|
||||||
|
try:
|
||||||
|
super().__delattr__(key)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
return
|
return
|
||||||
raise KeyError('unknown key {} for ConfigBag'.format(key))
|
raise KeyError('unknown key {} for ConfigBag'.format(key))
|
||||||
|
|
||||||
|
#def __setattr__(self, key, value):
|
||||||
|
# super().__setattr__(key, value)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
for key in self.__slots__:
|
for key in self.__slots__:
|
||||||
|
|
Loading…
Reference in a new issue