diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py
index c6d8d7fc..94f96e7b 100644
--- a/src/rougail/annotator.py
+++ b/src/rougail/annotator.py
@@ -38,7 +38,7 @@ modes = mode_factory()
# that shall not be present in the exported (flatened) XML
ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace',
'remove_condition', 'path', 'instance_mode', 'index', 'is_in_leadership',
- 'level') # , '_real_container')
+ 'level', 'remove_fill')
ERASED_CONTAINER_ATTRIBUTES = ('id', 'container', 'group_id', 'group', 'container_group')
FORCE_CHOICE = {'oui/non': ['oui', 'non'],
diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd
index fcf88e51..46f1e10a 100644
--- a/src/rougail/data/rougail.dtd
+++ b/src/rougail/data/rougail.dtd
@@ -45,7 +45,7 @@
-
+
@@ -75,14 +75,6 @@
-
-
-
-
-
-
-
-
@@ -110,6 +102,7 @@
+
diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py
index cc205a3e..37b82308 100644
--- a/src/rougail/objspace.py
+++ b/src/rougail/objspace.py
@@ -92,6 +92,7 @@ class CreoleObjSpace:
self.xmlreflector = XMLReflector()
self.xmlreflector.parse_dtd(dtdfilename)
self.redefine_variables = None
+ self.fill_removed = None
self.check_removed = None
self.condition_removed = None
@@ -153,6 +154,7 @@ class CreoleObjSpace:
"""
for xmlfile, document in self.xmlreflector.load_xml_from_folders(xmlfolders):
self.redefine_variables = []
+ self.fill_removed = []
self.check_removed = []
self.condition_removed = []
self.xml_parse_document(document,
@@ -383,6 +385,18 @@ class CreoleObjSpace:
)
return variable_obj
+ def remove_fill(self, name): # pylint: disable=C0111
+ if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'fill'):
+ remove_fills= []
+ for idx, fill in enumerate(self.space.constraints.fill): # pylint: disable=E1101
+ if hasattr(fill, 'target') and fill.target == name:
+ remove_fills.append(idx)
+
+ remove_fills = list(set(remove_fills))
+ remove_fills.sort(reverse=True)
+ for idx in remove_fills:
+ self.space.constraints.fill.pop(idx) # pylint: disable=E1101
+
def remove_check(self, name): # pylint: disable=C0111
if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'check'):
remove_checks = []
@@ -468,16 +482,21 @@ class CreoleObjSpace:
self.remove_check(variableobj.name)
if child.attrib.get('remove_condition', False):
self.remove_condition(variableobj.name)
+ if child.attrib.get('remove_fill', False):
+ self.remove_fill(variableobj.name)
if child.tag == 'fill':
# if variable is a redefine in current dictionary
# XXX not working with variable not in variable and in leader/followers
variableobj.redefine = child.attrib['target'] in self.redefine_variables
+ if child.attrib['target'] in self.redefine_variables and child.attrib['target'] not in self.fill_removed:
+ self.remove_fill(child.attrib['target'])
+ self.fill_removed.append(child.attrib['target'])
if not hasattr(variableobj, 'index'):
variableobj.index = self.index
if child.tag == 'check' and child.attrib['target'] in self.redefine_variables and child.attrib['target'] not in self.check_removed:
self.remove_check(child.attrib['target'])
self.check_removed.append(child.attrib['target'])
- if child.tag == 'condition' and child.attrib['source'] in self.redefine_variables and child.attrib['source'] not in self.check_removed:
+ if child.tag == 'condition' and child.attrib['source'] in self.redefine_variables and child.attrib['source'] not in self.condition_removed:
self.remove_condition(child.attrib['source'])
self.condition_removed.append(child.attrib['source'])
variableobj.namespace = namespace
diff --git a/tests/dictionaries/51remove_fill/00-base.xml b/tests/dictionaries/51remove_fill/00-base.xml
new file mode 100644
index 00000000..5bc01db8
--- /dev/null
+++ b/tests/dictionaries/51remove_fill/00-base.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+ non
+
+
+
+
+
+
+
+ mode_conteneur_actif1
+
+
+
+
+
+
+
diff --git a/tests/dictionaries/51remove_fill/01-base.xml b/tests/dictionaries/51remove_fill/01-base.xml
new file mode 100644
index 00000000..a2413e16
--- /dev/null
+++ b/tests/dictionaries/51remove_fill/01-base.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/dictionaries/51remove_fill/__init__.py b/tests/dictionaries/51remove_fill/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/dictionaries/51remove_fill/makedict/base.json b/tests/dictionaries/51remove_fill/makedict/base.json
new file mode 100644
index 00000000..bf7550e6
--- /dev/null
+++ b/tests/dictionaries/51remove_fill/makedict/base.json
@@ -0,0 +1 @@
+{"rougail.general.mode_conteneur_actif": "oui", "rougail.general.mode_conteneur_actif1": "non"}
diff --git a/tests/dictionaries/51remove_fill/tiramisu/__init__.py b/tests/dictionaries/51remove_fill/tiramisu/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/dictionaries/51remove_fill/tiramisu/base.py b/tests/dictionaries/51remove_fill/tiramisu/base.py
new file mode 100644
index 00000000..0fbc07a3
--- /dev/null
+++ b/tests/dictionaries/51remove_fill/tiramisu/base.py
@@ -0,0 +1,15 @@
+import imp
+func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py')
+for key, value in dict(locals()).items():
+ if key != ['imp', 'func']:
+ setattr(func, key, value)
+try:
+ from tiramisu3 import *
+except:
+ from tiramisu import *
+from rougail.tiramisu import ConvertDynOptionDescription
+option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='oui', values=('oui', 'non'))
+option_4 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif1', doc='No change', multi=False, default='non', values=('oui', 'non'))
+option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4])
+option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
+option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])