remove (g|s)et_modified_*, now it's exportation/importation

This commit is contained in:
Emmanuel Garette 2018-04-04 21:51:18 +02:00
parent 19b6ad6082
commit bc4fa9d3d0
15 changed files with 97 additions and 228 deletions

View File

@ -221,21 +221,21 @@ def test_get_modified_values():
root = OptionDescription('root', '', [d1])
config = Config(root)
api = getapi(config)
assert config.cfgimpl_get_values().get_modified_values() == {}
assert api.value.exportation() == ((), (), (), ())
api.option('od.g5').value.set('yes')
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes')}
assert api.value.exportation() == (('od.g5',), (None,), ('yes',), ('user',))
api.option('od.g4').value.set(True)
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes'), 'od.g4': ('user', True)}
assert api.value.exportation() == (('od.g5', 'od.g4'), (None, None), ('yes', True), ('user', 'user'))
api.option('od.g4').value.reset()
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes')}
assert api.value.exportation() == (('od.g5',), (None,), ('yes',), ('user',))
api.option('od.g6').value.set([undefined])
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes'), 'od.g6': ('user', (None,))}
assert api.value.exportation() == (('od.g5', 'od.g6'), (None, None), ('yes', (None,)), ('user', 'user'))
api.option('od.g6').value.set([])
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes'), 'od.g6': ('user', tuple())}
assert api.value.exportation() == (('od.g5', 'od.g6'), (None, None), ('yes', tuple()), ('user', 'user'))
api.option('od.g6').value.set(['3'])
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes'), 'od.g6': ('user', ('3',))}
assert api.value.exportation() == (('od.g5', 'od.g6'), (None, None), ('yes', ('3',)), ('user', 'user'))
api.option('od.g6').value.set([])
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes'), 'od.g6': ('user', tuple())}
assert api.value.exportation() == (('od.g5', 'od.g6'), (None, None), ('yes', tuple()), ('user', 'user'))
#def test_has_value():

View File

@ -68,8 +68,9 @@ def test_duplicate_force_store_value():
conf = Config(descr)
conf2 = Config(descr)
api = getapi(conf)
assert conf.cfgimpl_get_values().get_modified_values() == {'creole.general.wantref': ('forced', False)}
assert conf2.cfgimpl_get_values().get_modified_values() == {'creole.general.wantref': ('forced', False)}
api2 = getapi(conf2)
assert api.value.exportation() == (('creole.general.wantref',), (None,), (False,), ('forced',))
assert api2.value.exportation() == (('creole.general.wantref',), (None,), (False,), ('forced',))
api.option('creole.general.wantref').value.set(True)
assert conf.cfgimpl_get_values().get_modified_values() == {'creole.general.wantref': ('user', True)}
assert conf2.cfgimpl_get_values().get_modified_values() == {'creole.general.wantref': ('forced', False)}
assert api.value.exportation() == (('creole.general.wantref',), (None,), (True,), ('user',))
assert api2.value.exportation() == (('creole.general.wantref',), (None,), (False,), ('forced',))

View File

@ -146,17 +146,11 @@ def test_force_store_value():
descr = make_description_freeze()
conf = Config(descr)
api = getapi(conf)
assert api.value.get_modified() == {'wantref': ('forced', False),
'wantref2': ('forced', False),
'wantref3': ('forced', (False,))}
assert api.value.exportation() == (('wantref', 'wantref2', 'wantref3'), (None, None, None), (False, False, (False,)), ('forced', 'forced', 'forced'))
api.option('wantref').value.set(True)
assert api.value.get_modified() == {'wantref': ('user', True),
'wantref2': ('forced', False),
'wantref3': ('forced', (False,))}
assert api.value.exportation() == (('wantref', 'wantref2', 'wantref3'), (None, None, None), (True, False, (False,)), ('user', 'forced', 'forced'))
api.option('wantref').value.reset()
assert api.value.get_modified() == {'wantref': ('forced', False),
'wantref2': ('forced', False),
'wantref3': ('forced', (False,))}
assert api.value.exportation() == (('wantref', 'wantref2', 'wantref3'), (None, None, None), (False, False, (False,)), ('forced', 'forced', 'forced'))
def test_force_store_value_no_requirement():
@ -189,28 +183,28 @@ def test_force_store_value_masterslaves_sub():
descr = MasterSlaves("int", "", [b, c])
odr = OptionDescription('odr', '', [descr])
api = getapi(Config(odr))
assert api.value.get_modified() == {'int.int': ('forced', ())}
assert api.value.exportation() == (('int.int',), (None,), (tuple(),), ('forced',))
def test_force_store_value_callback():
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val)
descr = OptionDescription("int", "", [b])
api = getapi(Config(descr))
assert api.value.get_modified() == {'int': ('forced', 1)}
assert api.value.exportation() == (('int',), (None,), (1,), ('forced',))
def test_force_store_value_callback_params():
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val2, callback_params={'value': (2,)})
descr = OptionDescription("int", "", [b])
api = getapi(Config(descr))
assert api.value.get_modified() == {'int': ('forced', 2)}
assert api.value.exportation() == (('int',), (None,), (2,), ('forced',))
def test_force_store_value_callback_params_2():
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val3, callback_params={'': ((None,),), 'value': (2,)})
descr = OptionDescription("int", "", [b])
api = getapi(Config(descr))
assert api.value.get_modified() == {'int': ('forced', 2)}
assert api.value.exportation() == (('int',), (None,), (2,), ('forced',))
def test_force_store_value_callback_params_with_opt():
@ -218,4 +212,4 @@ def test_force_store_value_callback_params_with_opt():
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val2, callback_params={'value': ((a, False),)})
descr = OptionDescription("int", "", [a, b])
api = getapi(Config(descr))
assert api.value.get_modified() == {'int': ('forced', 2)}
assert api.value.exportation() == (('int',), (None,), (2,), ('forced',))

View File

@ -444,45 +444,45 @@ def test_reset_properties_force_store_value():
gcgroup = OptionDescription('gc', '', [gcdummy])
descr = OptionDescription('tiramisu', '', [gcgroup])
api = getapi(Config(descr))
assert api.property.get_modified() == {}
assert api.property.exportation() == {}
api.property.add('frozen')
if TIRAMISU_VERSION == 2:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'cache', 'validator', 'warnings', 'expire'))}
else:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'cache', 'validator', 'warnings'))}
api.property.reset()
assert api.property.get_modified() == {}
assert api.property.exportation() == {}
api.option('gc.dummy').property.add('test')
assert api.property.get_modified() == {'gc.dummy': set(('test', 'force_store_value'))}
assert api.property.exportation() == {'gc.dummy': set(('test', 'force_store_value'))}
api.property.reset()
assert api.property.get_modified() == {'gc.dummy': set(('test', 'force_store_value'))}
assert api.property.exportation() == {'gc.dummy': set(('test', 'force_store_value'))}
api.property.add('frozen')
if TIRAMISU_VERSION == 2:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'validator', 'cache', 'warnings', 'expire')),
'gc.dummy': set(('test', 'force_store_value'))}
else:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'validator', 'cache', 'warnings')),
'gc.dummy': set(('test', 'force_store_value'))}
api.property.add('frozen')
if TIRAMISU_VERSION == 2:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'validator', 'cache', 'warnings', 'expire')),
'gc.dummy': set(('test', 'force_store_value'))}
else:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'validator', 'cache', 'warnings')),
'gc.dummy': set(('test', 'force_store_value'))}
api.option('gc.dummy').property.add('test')
if TIRAMISU_VERSION == 2:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'validator', 'cache', 'warnings', 'expire')),
'gc.dummy': set(('test', 'force_store_value'))}
else:
assert api.property.get_modified() == \
assert api.property.exportation() == \
{None: set(('frozen', 'validator', 'cache', 'warnings')),
'gc.dummy': set(('test', 'force_store_value'))}
@ -492,9 +492,9 @@ def test_set_modified_value():
gcgroup = OptionDescription('gc', '', [gcdummy])
descr = OptionDescription('tiramisu', '', [gcgroup])
api = getapi(Config(descr))
assert api.property.get_modified() == {}
api.property.set_modified({None: set(('frozen', 'cache', 'validator', 'warnings'))})
assert api.property.get_modified() == \
assert api.property.exportation() == {}
api.property.importation({None: set(('frozen', 'cache', 'validator', 'warnings'))})
assert api.property.exportation() == \
{None: set(('frozen', 'cache', 'validator', 'warnings'))}

View File

@ -482,57 +482,23 @@ def test_values_with_master_and_slaves_master_pop():
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ["192.168.230.145", "192.168.230.146"]
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == '255.255.0.0'
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': (
'user',
('192.168.230.145', '192.168.230.146')),
'ip_admin_eth0.netmask_admin_eth0': (
{'1': 'user'},
{'1': '255.255.0.0'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (1,)), (('192.168.230.145', '192.168.230.146'), ('255.255.0.0',)), ('user', ('user',)))
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0)
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': (
'user',
('192.168.230.146',)),
'ip_admin_eth0.netmask_admin_eth0': (
{'0': 'user'},
{'0': '255.255.0.0'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (0,)), (('192.168.230.146',), ('255.255.0.0',)), ('user', ('user',)))
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ["192.168.230.146"]
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.146', "192.168.230.145", "192.168.230.146", "192.168.230.147", "192.168.230.148", "192.168.230.149"])
api.option('ip_admin_eth0.netmask_admin_eth0', 3).value.set('255.255.0.0')
api.option('ip_admin_eth0.netmask_admin_eth0', 4).value.set('255.255.0.0')
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': (
'user',
('192.168.230.146', "192.168.230.145", "192.168.230.146", "192.168.230.147", "192.168.230.148", "192.168.230.149")),
'ip_admin_eth0.netmask_admin_eth0': (
{'0': 'user', '3': 'user', '4': 'user'},
{'0': '255.255.0.0', '3': '255.255.0.0', '4': '255.255.0.0'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (0, 3, 4)), (('192.168.230.146', "192.168.230.145", "192.168.230.146", "192.168.230.147", "192.168.230.148", "192.168.230.149"), ('255.255.0.0', '255.255.0.0', '255.255.0.0')), ('user', ('user', 'user', 'user')))
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(5)
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': (
'user',
('192.168.230.146', "192.168.230.145", "192.168.230.146", "192.168.230.147", "192.168.230.148")),
'ip_admin_eth0.netmask_admin_eth0': (
{'0': 'user', '3': 'user', '4': 'user'},
{'0': '255.255.0.0', '3': '255.255.0.0', '4': '255.255.0.0'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (0, 3, 4)), (('192.168.230.146', "192.168.230.145", "192.168.230.146", "192.168.230.147", "192.168.230.148"), ('255.255.0.0', '255.255.0.0', '255.255.0.0')), ('user', ('user', 'user', 'user')))
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(2)
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': (
'user',
('192.168.230.146', "192.168.230.145", "192.168.230.147", "192.168.230.148")),
'ip_admin_eth0.netmask_admin_eth0': (
{'0': 'user', '2': 'user', '3': 'user'},
{'0': '255.255.0.0', '2': '255.255.0.0', '3': '255.255.0.0'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (0, 2, 3)), (('192.168.230.146', "192.168.230.145", "192.168.230.147", "192.168.230.148"), ('255.255.0.0', '255.255.0.0', '255.255.0.0')), ('user', ('user', 'user', 'user')))
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(2)
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': ('user',
('192.168.230.146',
"192.168.230.145",
"192.168.230.148")),
'ip_admin_eth0.netmask_admin_eth0': ({'0': 'user', '2': 'user'},
{'0': '255.255.0.0', '2': '255.255.0.0'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (0, 2)), (('192.168.230.146', "192.168.230.145", "192.168.230.148"), ('255.255.0.0', '255.255.0.0')), ('user', ('user', 'user')))
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(2)
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': ('user',
('192.168.230.146',
"192.168.230.145")),
'ip_admin_eth0.netmask_admin_eth0': ({'0': 'user'},
{'0': '255.255.0.0'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (0,)), (('192.168.230.146', "192.168.230.145"), ('255.255.0.0',)), ('user', ('user',)))
def test_values_with_master_owner():
@ -613,11 +579,11 @@ def test_groups_with_master_get_modified_value():
maconfig = OptionDescription('toto', '', [interface1])
api = getapi(Config(maconfig))
api.property.read_write()
assert api.value.get_modified() == {}
assert api.value.exportation() == ((), (), (), ())
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': ('user', ('192.168.1.1',))}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0',), (None,), (('192.168.1.1',),), ('user',))
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.255')
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': ('user', ('192.168.1.1',)), 'ip_admin_eth0.netmask_admin_eth0': ({'0': 'user'}, {'0': '255.255.255.255'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0',), (None, (0,)), (('192.168.1.1',), ('255.255.255.255',)), ('user', ('user',)))
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1', '192.168.1.1'])
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('255.255.255.255')
assert api.value.get_modified() == {'ip_admin_eth0.ip_admin_eth0': ('user', ('192.168.1.1', '192.168.1.1')), 'ip_admin_eth0.netmask_admin_eth0': ({'0': 'user', '1': 'user'}, {'0': '255.255.255.255', '1': '255.255.255.255'})}
assert api.value.exportation() == (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0',), (None, (0, 1)), (('192.168.1.1', '192.168.1.1'), ('255.255.255.255', '255.255.255.255')), ('user', ('user', 'user')))

View File

@ -580,7 +580,9 @@ class TiramisuOption(CommonTiramisu):
return self._get_option().impl_get_group_type()
@count
def _list(self, type='all', group_type=None):
def _list(self,
type='all',
group_type=None):
if type == 'optiondescription':
return self.config_bag.config.getattr(self.path,
None,
@ -620,10 +622,6 @@ class TiramisuContextValue(TiramisuContext):
def mandatory_warnings(self):
return self.config_bag.config.cfgimpl_get_values().mandatory_warnings(self.config_bag)
@count
def get_modified(self):
return self.config_bag.config.cfgimpl_get_values().get_modified_values()
def set(self,
path,
value,
@ -647,13 +645,19 @@ class TiramisuContextValue(TiramisuContext):
self.config_bag,
**kwargs)
@count
def reset(self,
path):
self.config_bag.config.reset(path, self.config_bag)
def export(self):
@count
def exportation(self):
return self.config_bag.config.cfgimpl_get_values()._p_.exportation()
@count
def importation(self, values):
return self.config_bag.config.cfgimpl_get_values()._p_.importation(values)
class TiramisuContextOwner(TiramisuContext):
@count
@ -705,22 +709,23 @@ class TiramisuContextProperty(TiramisuContext):
def get(self):
return set(self.config_bag.setting_properties)
@count
def get_modified(self):
return self.config_bag.config.cfgimpl_get_settings().get_modified_properties()
@count
def set_modified(self, props):
return self.config_bag.config.cfgimpl_get_settings().set_modified_properties(props)
@count
def set(self, props):
self.config_bag.config.cfgimpl_get_settings().set_context_properties(props)
self.config_bag.setting_properties = self.config_bag.config.cfgimpl_get_settings().get_context_properties()
@count
def reset(self):
self.config_bag.config.cfgimpl_get_settings().reset()
@count
def exportation(self):
return self.config_bag.config.cfgimpl_get_settings()._p_.exportation()
@count
def importation(self, properties):
return self.config_bag.config.cfgimpl_get_settings()._p_.importation(properties)
class TiramisuContextPermissive(TiramisuContext):
@ -728,6 +733,15 @@ class TiramisuContextPermissive(TiramisuContext):
def set(self, permissives):
self.config_bag.config.cfgimpl_get_settings().set_context_permissive(permissives)
@count
def exportation(self):
return self.config_bag.config.cfgimpl_get_settings()._pp_.exportation()
@count
def importation(self, permissives):
return self.config_bag.config.cfgimpl_get_settings()._pp_.importation(permissives)
class TiramisuContextOption(TiramisuContext):
@count
@ -769,11 +783,15 @@ class TiramisuContextOption(TiramisuContext):
withvalue=withvalue)
@count
def list(self, type='all', group_type=None):
def list(self,
type='all',
group_type=None,
recursive=False):
if type == 'optiondescription':
return self.config_bag.config.iter_groups(self.config_bag, group_type)
elif type == 'all':
return self.config_bag.config.cfgimpl_get_children(self.config_bag)
return self.config_bag.config.cfgimpl_get_children(recursive,
self.config_bag)
else:
raise APIError(_('unknown list type {}').format(type))

View File

@ -100,7 +100,6 @@ class SubConfig(object):
for woption in opt._get_dependencies(self):
option = woption()
option_path = option.impl_getpath(self)
print(option_path, resetted_opts)
if option_path in resetted_opts:
continue
self.reset_one_option_cache(values,
@ -159,40 +158,6 @@ class SubConfig(object):
return self, path[-1]
# ______________________________________________________________________
# def __iter__(self, force_permissive=False):
# """Pythonesque way of parsing group's ordered options.
# iteration only on Options (not OptionDescriptions)"""
# setting_properties = self.cfgimpl_get_context().cfgimpl_get_settings().get_context_properties()
# for child in self.cfgimpl_get_description().impl_getchildren(context=self._cfgimpl_get_context()):
# if not child.impl_is_optiondescription():
# try:
# name = child.impl_getname()
# yield name, self.getattr(name,
# force_permissive=force_permissive,
# setting_properties=setting_properties)
# except GeneratorExit: # pragma: optional cover
# if sys.version_info[0] < 3:
# raise StopIteration
# else:
# raise GeneratorExit()
# except PropertiesOptionError: # pragma: optional cover
# pass # option with properties
#
# def iter_all(self, force_permissive=False):
# """A way of parsing options **and** groups.
# iteration on Options and OptionDescriptions."""
# for child in self.cfgimpl_get_description().impl_getchildren():
# try:
# yield child.impl_getname(), self.getattr(child.impl_getname(),
# force_permissive=force_permissive)
# except GeneratorExit: # pragma: optional cover
# if sys.version_info[0] < 3:
# raise StopIteration
# else:
# raise GeneratorExit()
# except PropertiesOptionError: # pragma: optional cover
# pass # option with properties
def iter_groups(self,
config_bag,
group_type=None):
@ -207,7 +172,6 @@ class SubConfig(object):
if group_type is not None and not isinstance(group_type,
groups.GroupType): # pragma: optional cover
raise TypeError(_("unknown group_type: {0}").format(group_type))
context = self._cfgimpl_get_context()
for child in self.cfgimpl_get_description().impl_getchildren(config_bag):
if child.impl_is_optiondescription():
nconfig_bag = config_bag.copy('nooption')
@ -223,7 +187,8 @@ class SubConfig(object):
except PropertiesOptionError: # pragma: optional cover
pass
def cfgimpl_get_children(self, config_bag):
def cfgimpl_get_children(self,
config_bag):
context = self._cfgimpl_get_context()
for opt in self.cfgimpl_get_description().impl_getchildren(config_bag):
nconfig_bag = config_bag.copy('nooption')
@ -844,10 +809,10 @@ class _CommonConfig(SubConfig):
force_values=force_values,
force_settings=force_settings)
config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation())
config.cfgimpl_get_settings()._p_.set_modified_properties(self.cfgimpl_get_settings(
)._p_.get_modified_properties())
config.cfgimpl_get_settings()._pp_.set_modified_permissives(self.cfgimpl_get_settings(
)._pp_.get_modified_permissives())
config.cfgimpl_get_settings()._p_.importation(self.cfgimpl_get_settings(
)._p_.exportation())
config.cfgimpl_get_settings()._pp_.importation(self.cfgimpl_get_settings(
)._pp_.exportation())
return config

View File

@ -771,18 +771,6 @@ class Settings(object):
self._read(rw_remove,
rw_append)
#____________________________________________________________
# get modified properties/permissives
def get_modified_properties(self):
return self._p_.get_modified_properties()
def set_modified_properties(self, props):
return self._p_.set_modified_properties(props)
def get_modified_permissives(self):
return self._pp_.get_modified_permissives()
#____________________________________________________________
# default owner methods

View File

@ -55,13 +55,13 @@ class Properties(Cache):
if path in self._properties:
del(self._properties[path])
def get_modified_properties(self):
def exportation(self):
"""return all modified settings in a dictionary
example: {'path1': set(['prop1', 'prop2'])}
"""
return copy(self._properties)
def set_modified_properties(self, properties):
def importation(self, properties):
self._properties = properties
@ -88,12 +88,12 @@ class Permissives(Cache):
print('getpermissive', path, ret)
return ret
def get_modified_permissives(self):
def exportation(self):
"""return all modified permissives in a dictionary
example: {'path1': set(['perm1', 'perm2'])}
"""
return copy(self._permissives)
def set_modified_permissives(self, permissives):
def importation(self, permissives):
self._permissives = permissives

View File

@ -176,26 +176,6 @@ class Values(Cache):
_resetvalue(3)
self._values = tuple(values)
def get_modified_values(self):
"""return all values in a dictionary
example: {'path1': (owner, 'value1'), 'path2': (owner, 'value2')}
"""
values = {}
for idx, path in enumerate(self._values[0]):
indexes = self._values[1][idx]
value = self._values[2][idx]
owner = self._values[3][idx]
if indexes is not None:
val = {}
own = {}
for cpt, index in enumerate(indexes):
val[str(index)] = value[cpt]
own[str(index)] = owner[cpt]
value = val
owner = own
values[path] = (owner, value)
return values
# owner
def setowner(self, path, owner, index=None):
"""change owner for a path

View File

@ -117,13 +117,13 @@ class Settings(Cache, SqlAlchemyBase):
#replace None by a frozenset()
return {None: frozenset()}.get(ret, ret)
def get_modified_properties(self):
def exportation(self):
"""return all modified settings in a dictionary
example: {'path1': set(['prop1', 'prop2'])}
"""
return self._properties
def get_modified_permissives(self):
def importation(self):
"""return all modified permissives in a dictionary
example: {'path1': set(['perm1', 'perm2'])}
"""

View File

@ -111,21 +111,6 @@ class Values(Cache):
session.delete(val)
session.commit()
def get_modified_values(self):
"""return all values in a dictionary
example: {'path1': (owner, 'value1'), 'path2': (owner, 'value2')}
"""
session = self.getsession()
ret = {}
for val in session.query(Value).filter_by(
session_id=self._storage.session_id).all():
value = val.value
if isinstance(val.value, list):
value = tuple(val.value)
ret[val.path] = (val.owner, value)
del(session)
return ret
# owner
def setowner(self, path, owner, session, index=None):
"""change owner for a path

View File

@ -57,7 +57,7 @@ class Properties(Sqlite3DB):
self._storage.execute("DELETE FROM property WHERE path = ? AND session_id = ?",
(path, self._session_id))
def get_modified_properties(self):
def exportation(self):
"""return all modified settings in a dictionary
example: {'path1': set(['prop1', 'prop2'])}
"""
@ -70,7 +70,7 @@ class Properties(Sqlite3DB):
ret[path] = self._sqlite_decode(properties)
return ret
def set_modified_properties(self, properties):
def importation(self, properties):
self._storage.execute("DELETE FROM property", commit=False)
for path, property_ in properties.items():
self._storage.execute("INSERT INTO property(path, properties, session_id) "
@ -104,7 +104,7 @@ class Permissives(Sqlite3DB):
else:
return frozenset(self._sqlite_decode(permissives[0]))
def get_modified_permissives(self):
def exportation(self):
"""return all modified permissives in a dictionary
example: {'path1': set(['perm1', 'perm2'])}
"""
@ -117,7 +117,7 @@ class Permissives(Sqlite3DB):
ret[path] = self._sqlite_decode(permissives)
return ret
def set_modified_permissives(self, permissives):
def importation(self, permissives):
self._storage.execute("DELETE FROM permissive", commit=False)
for path, permissive in permissives.items():
self._storage.execute("INSERT INTO permissive(path, permissives, session_id) "

View File

@ -86,31 +86,6 @@ class Values(Sqlite3DB):
self._storage.execute("DELETE FROM value WHERE path = ? AND session_id = ?", (path, self._session_id),
commit=_commit)
def get_modified_values(self):
"""return all values in a dictionary
example: {option1: (owner, 'value1'), option2: (owner, 'value2')}
"""
ret = {}
for path, value, owner, index, _ in self._storage.select("SELECT * FROM value WHERE "
"session_id = ?",
(self._session_id,),
only_one=False):
path = self._sqlite_decode_path(path)
owner = getattr(owners, owner)
value = self._sqlite_decode(value)
if isinstance(value, list):
value = tuple(value)
if index is None:
ret[path] = (owner, value)
else:
if path in ret:
ret[path][0][str(index)] = owner
ret[path][1][str(index)] = value
else:
ret[path] = ({str(index): owner}, {str(index): value})
return ret
# owner
def setowner(self, path, owner, session, index=None):
"""change owner for an option

View File

@ -315,9 +315,6 @@ class Values(object):
isempty = value is None or value == empty
return isempty
def get_modified_values(self):
return self._p_.get_modified_values()
#______________________________________________________________________
# set value