add remove_fill attribute
This commit is contained in:
parent
8f01d2c1d8
commit
f7db6b0289
9 changed files with 75 additions and 11 deletions
|
@ -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'],
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
<!ELEMENT services (service*)>
|
||||
|
||||
<!ELEMENT service ((port* | tcpwrapper* | ip* | interface* | package* | file* | digitalcertificate* | override*)*) >
|
||||
<!ELEMENT service ((port* | tcpwrapper* | ip* | interface* | package* | file* | override*)*) >
|
||||
<!ATTLIST service name CDATA #REQUIRED>
|
||||
<!ATTLIST service manage (True|False) "True">
|
||||
|
||||
|
@ -75,14 +75,6 @@
|
|||
<!ATTLIST file redefine (True|False) "False">
|
||||
<!ATTLIST file templating (True|False) "True">
|
||||
|
||||
<!ELEMENT digitalcertificate EMPTY>
|
||||
<!ATTLIST digitalcertificate name CDATA #REQUIRED >
|
||||
<!ATTLIST digitalcertificate digitalcertificate_type (variable) "variable">
|
||||
<!ATTLIST digitalcertificate certificate CDATA #REQUIRED >
|
||||
<!ATTLIST digitalcertificate certificate_type (variable) "variable">
|
||||
<!ATTLIST digitalcertificate type CDATA #REQUIRED >
|
||||
<!ATTLIST digitalcertificate ca CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT override EMPTY>
|
||||
<!ATTLIST override source CDATA #IMPLIED >
|
||||
<!ATTLIST override templating (True|False) "True">
|
||||
|
@ -110,6 +102,7 @@
|
|||
<!ATTLIST variable mode (basic|normal|expert) "normal">
|
||||
<!ATTLIST variable remove_check (True|False) "False">
|
||||
<!ATTLIST variable remove_condition (True|False) "False">
|
||||
<!ATTLIST variable remove_fill (True|False) "False">
|
||||
<!ATTLIST variable test CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT separators (separator*)>
|
||||
|
|
|
@ -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
|
||||
|
|
26
tests/dictionaries/51remove_fill/00-base.xml
Normal file
26
tests/dictionaries/51remove_fill/00-base.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<rougail>
|
||||
|
||||
<services/>
|
||||
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="mode_conteneur_actif" type="oui/non" description="No change"/>
|
||||
<variable name="mode_conteneur_actif1" type="oui/non" description="No change">
|
||||
<value>non</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
<fill name="calc_val" target="mode_conteneur_actif">
|
||||
<param type="variable">mode_conteneur_actif1</param>
|
||||
</fill>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
||||
</rougail>
|
||||
<!-- vim: ts=4 sw=4 expandtab
|
||||
-->
|
10
tests/dictionaries/51remove_fill/01-base.xml
Normal file
10
tests/dictionaries/51remove_fill/01-base.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<rougail>
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="mode_conteneur_actif" redefine="True" remove_fill="True"/>
|
||||
</family>
|
||||
</variables>
|
||||
</rougail>
|
||||
<!-- vim: ts=4 sw=4 expandtab
|
||||
-->
|
0
tests/dictionaries/51remove_fill/__init__.py
Normal file
0
tests/dictionaries/51remove_fill/__init__.py
Normal file
1
tests/dictionaries/51remove_fill/makedict/base.json
Normal file
1
tests/dictionaries/51remove_fill/makedict/base.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"rougail.general.mode_conteneur_actif": "oui", "rougail.general.mode_conteneur_actif1": "non"}
|
0
tests/dictionaries/51remove_fill/tiramisu/__init__.py
Normal file
0
tests/dictionaries/51remove_fill/tiramisu/__init__.py
Normal file
15
tests/dictionaries/51remove_fill/tiramisu/base.py
Normal file
15
tests/dictionaries/51remove_fill/tiramisu/base.py
Normal file
|
@ -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])
|
Loading…
Reference in a new issue