diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 3673c991..6f6ff350 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -141,6 +141,11 @@ class 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 = [] self._xml_parse(xmlfile, document, diff --git a/src/rougail/rougail.py b/src/rougail/rougail.py index ebd24e55..04189a92 100644 --- a/src/rougail/rougail.py +++ b/src/rougail/rougail.py @@ -6,7 +6,8 @@ Sample usage:: >>> from rougail import Rougail >>> 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') >>> tiramisu = rougail.save() @@ -39,8 +40,8 @@ class Rougail: self.funcs_path = None def create_or_populate_from_xml(self, - namespace: str, xmlfolders: List[str], + namespace: str=None, ) -> List[str]: """Parses a bunch of XML files and populates the RougailObjSpace """ diff --git a/tests/dictionaries/80extra_rougail/00-base.xml b/tests/dictionaries/80extra_rougail/00-base.xml new file mode 100644 index 00000000..4eb9d373 --- /dev/null +++ b/tests/dictionaries/80extra_rougail/00-base.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/tests/dictionaries/80extra_rougail/__init__.py b/tests/dictionaries/80extra_rougail/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80extra_rougail/errno_21 b/tests/dictionaries/80extra_rougail/errno_21 new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80extra_rougail/extra_dirs/rougail/00-base.xml b/tests/dictionaries/80extra_rougail/extra_dirs/rougail/00-base.xml new file mode 100644 index 00000000..651c2125 --- /dev/null +++ b/tests/dictionaries/80extra_rougail/extra_dirs/rougail/00-base.xml @@ -0,0 +1,23 @@ + + + + + + + Exportation de la base de ejabberd + + + + pre + + + + + + non + activer_ejabberd + none + daily + + + diff --git a/tests/dictionaries/80extra_services/00-base.xml b/tests/dictionaries/80extra_services/00-base.xml new file mode 100644 index 00000000..4eb9d373 --- /dev/null +++ b/tests/dictionaries/80extra_services/00-base.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/tests/dictionaries/80extra_services/__init__.py b/tests/dictionaries/80extra_services/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80extra_services/errno_21 b/tests/dictionaries/80extra_services/errno_21 new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80extra_services/extra_dirs/services/00-base.xml b/tests/dictionaries/80extra_services/extra_dirs/services/00-base.xml new file mode 100644 index 00000000..651c2125 --- /dev/null +++ b/tests/dictionaries/80extra_services/extra_dirs/services/00-base.xml @@ -0,0 +1,23 @@ + + + + + + + Exportation de la base de ejabberd + + + + pre + + + + + + non + activer_ejabberd + none + daily + + + diff --git a/tests/test_1_flattener.py b/tests/test_1_flattener.py index 51209a2d..a01307e3 100644 --- a/tests/test_1_flattener.py +++ b/tests/test_1_flattener.py @@ -60,13 +60,14 @@ def launch_flattener(test_dir, test_ok=False): subfolder = join(test_dir, 'subfolder') if isdir(subfolder): dirs.append(subfolder) - eolobj.create_or_populate_from_xml(Config['variable_namespace'], dirs) - subfolder = join(test_dir, 'extra_dirs', 'extra') - if isdir(subfolder): - eolobj.create_or_populate_from_xml('extra', [subfolder]) - subfolder = join(test_dir, 'extra_dirs', 'extra1') - if isdir(subfolder): - eolobj.create_or_populate_from_xml('extra1', [subfolder]) + eolobj.create_or_populate_from_xml(dirs) + 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): + eolobj.create_or_populate_from_xml([subfolder], extra) eosfunc = join(dico_dirs, '../eosfunc/test.py') Config['patch_dir'] = join(test_dir, 'patches') eolobj.space_visitor(eosfunc)