summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-06-22 16:28:26 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-06-22 16:28:26 +0200
commit78a34dbbec19e205bfbb3c84888e4de6375c325a (patch)
tree2a5e6b3d2cf1ed6587ab19cb1904a6e426e5e1f9
parent326489e326110ff79dfdb28bf9af474832afd6ce (diff)
downloadlogilab-common-78a34dbbec19e205bfbb3c84888e4de6375c325a.tar.gz
added new 'typechanged' action fo lgc's configurations
-rw-r--r--configuration.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/configuration.py b/configuration.py
index 744eae6..279c3c4 100644
--- a/configuration.py
+++ b/configuration.py
@@ -812,12 +812,11 @@ def read_old_config(newconfig, changes, configfile):
possible changes:
* ('renamed', oldname, newname)
* ('moved', option, oldgroup, newgroup)
+ * ('typechanged', option, oldtype, newvalue)
"""
# build an index of changes
changesindex = {}
for action in changes:
- if action[0] not in ('moved', 'renamed'):
- raise Exception('unknown change %s' % action[0])
if action[0] == 'moved':
option, oldgroup, newgroup = action[1:]
changesindex.setdefault(option, []).append((action[0], oldgroup, newgroup))
@@ -826,6 +825,10 @@ def read_old_config(newconfig, changes, configfile):
oldname, newname = action[1:]
changesindex.setdefault(newname, []).append((action[0], oldname))
continue
+ if action[0] == 'typechanged':
+ option, oldtype, newvalue = action[1:]
+ changesindex.setdefault(option, []).append((action[0], oldtype, newvalue))
+ continue
if action[1] in ('added', 'removed'):
continue # nothing to do here
raise Exception('unknown change %s' % action[0])
@@ -839,6 +842,10 @@ def read_old_config(newconfig, changes, configfile):
optdef['group'] = oldgroup
elif action[0] == 'renamed':
optname = action[1]
+ elif action[0] == 'typechanged':
+ oldtype = action[1]
+ optdef = optdef.copy()
+ optdef['type'] = oldtype
options.append((optname, optdef))
if changesindex:
raise Exception('unapplied changes: %s' % changesindex)
@@ -853,11 +860,13 @@ def read_old_config(newconfig, changes, configfile):
oldname, newname = action[1:]
newconfig[newname] = oldconfig[oldname]
done.add(newname)
- continue
+ elif action[0] == 'typechanged':
+ optname, oldtype, newvalue = action[1:]
+ newconfig[optname] = newvalue
+ done.add(optname)
for optname, optdef in newconfig.options:
- if optname in done:
- continue
- newconfig.set_option(optname, oldconfig[optname], opt_dict=optdef)
+ if not optname in done:
+ newconfig.set_option(optname, oldconfig[optname], opt_dict=optdef)
def merge_options(options):