does not allow services and rougail namespace

This commit is contained in:
Emmanuel Garette 2021-01-23 08:16:24 +01:00
parent b05fe25db0
commit 562ef23dd2
11 changed files with 92 additions and 9 deletions

View File

@ -141,6 +141,11 @@ class RougailObjSpace:
): ):
"""Parses a Rougail XML file and populates the RougailObjSpace """Parses a Rougail XML file and populates the RougailObjSpace
""" """
if namespace in ['services', Config['variable_namespace']]:
msg = _(f'Namespace name "{namespace}" is not allowed in "{xmlfile}"')
raise DictConsistencyError(msg, 21)
if not namespace:
namespace = Config['variable_namespace']
redefine_variables = [] redefine_variables = []
self._xml_parse(xmlfile, self._xml_parse(xmlfile,
document, document,

View File

@ -6,7 +6,8 @@ Sample usage::
>>> from rougail import Rougail >>> from rougail import Rougail
>>> rougail = Rougail('/usr/share/rougail/rougail.dtd') >>> rougail = Rougail('/usr/share/rougail/rougail.dtd')
>>> rougail.create_or_populate_from_xml('rougail', ['/usr/share/rougail/dicos']) >>> rougail.create_or_populate_from_xml(['/usr/share/rougail/dicos'])
>>> rougail.create_or_populate_from_xml(['/usr/share/rougail/extra1'], 'extra1')
>>> rougail.space_visitor('/usr/share/rougail/funcs.py') >>> rougail.space_visitor('/usr/share/rougail/funcs.py')
>>> tiramisu = rougail.save() >>> tiramisu = rougail.save()
@ -39,8 +40,8 @@ class Rougail:
self.funcs_path = None self.funcs_path = None
def create_or_populate_from_xml(self, def create_or_populate_from_xml(self,
namespace: str,
xmlfolders: List[str], xmlfolders: List[str],
namespace: str=None,
) -> List[str]: ) -> List[str]:
"""Parses a bunch of XML files and populates the RougailObjSpace """Parses a bunch of XML files and populates the RougailObjSpace
""" """

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="activer_ejabberd" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<rougail>
<variables>
<family name='ejabberd'>
<variable name="description" type="string">
<value>Exportation de la base de ejabberd</value>
</variable>
<variable name="day" type="schedule"></variable>
<variable name="mode" type="schedulemod">
<value>pre</value>
</variable>
</family>
</variables>
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>
</constraints>
</rougail>

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="activer_ejabberd" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<rougail>
<variables>
<family name='ejabberd'>
<variable name="description" type="string">
<value>Exportation de la base de ejabberd</value>
</variable>
<variable name="day" type="schedule"></variable>
<variable name="mode" type="schedulemod">
<value>pre</value>
</variable>
</family>
</variables>
<constraints>
<fill name='calc_multi_condition' target='extra.ejabberd.day'>
<param>non</param>
<param type='variable' name='condition_1' notraisepropertyerror='True'>activer_ejabberd</param>
<param name='match'>none</param>
<param name='mismatch'>daily</param>
</fill>
</constraints>
</rougail>

View File

@ -60,13 +60,14 @@ def launch_flattener(test_dir, test_ok=False):
subfolder = join(test_dir, 'subfolder') subfolder = join(test_dir, 'subfolder')
if isdir(subfolder): if isdir(subfolder):
dirs.append(subfolder) dirs.append(subfolder)
eolobj.create_or_populate_from_xml(Config['variable_namespace'], dirs) eolobj.create_or_populate_from_xml(dirs)
subfolder = join(test_dir, 'extra_dirs', 'extra') if isdir(join(test_dir, 'extra_dirs')):
extras = listdir(join(test_dir, 'extra_dirs'))
extras.sort()
for extra in extras:
subfolder = join(test_dir, 'extra_dirs', extra)
if isdir(subfolder): if isdir(subfolder):
eolobj.create_or_populate_from_xml('extra', [subfolder]) eolobj.create_or_populate_from_xml([subfolder], extra)
subfolder = join(test_dir, 'extra_dirs', 'extra1')
if isdir(subfolder):
eolobj.create_or_populate_from_xml('extra1', [subfolder])
eosfunc = join(dico_dirs, '../eosfunc/test.py') eosfunc = join(dico_dirs, '../eosfunc/test.py')
Config['patch_dir'] = join(test_dir, 'patches') Config['patch_dir'] = join(test_dir, 'patches')
eolobj.space_visitor(eosfunc) eolobj.space_visitor(eosfunc)