From 4eccb75c7319fb5677f99fc5a72d60911edc5fb5 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 11 May 2023 16:01:50 +0200 Subject: [PATCH] engine can be customized --- src/rougail/annotator/target.py | 2 +- src/rougail/data/rougail.dtd | 6 +++--- src/rougail/data/rougail.yml | 13 ------------- src/rougail/template/base.py | 9 ++++++--- src/rougail/template/engine/jinja.py | 2 +- src/rougail/tiramisureflector.py | 2 +- .../40family_unique_not_same_family/__init__.py | 0 .../40family_unique_not_same_family/errno_55 | 0 .../40family_unique_not_same_family/xml/00-base.xml | 10 ++++++++++ .../40family_unique_not_same_family/yml/00-base.yml | 10 ++++++++++ tests/eosfunc/test.py | 2 +- 11 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 tests/dictionaries/40family_unique_not_same_family/__init__.py create mode 100644 tests/dictionaries/40family_unique_not_same_family/errno_55 create mode 100644 tests/dictionaries/40family_unique_not_same_family/xml/00-base.xml create mode 100644 tests/dictionaries/40family_unique_not_same_family/yml/00-base.yml diff --git a/src/rougail/annotator/target.py b/src/rougail/annotator/target.py index 0f9938794..7be551712 100644 --- a/src/rougail/annotator/target.py +++ b/src/rougail/annotator/target.py @@ -50,7 +50,7 @@ class TargetAnnotator(Walk): for index, target in enumerate(obj.target): # test if it's redefined calculation if self.target_is_uniq and target.name in targets: - msg = _(f'A fill already exists for the target of "{target.name}" created') + msg = _(f'A fill already exists for the target of "{target.name.path}" created') raise DictConsistencyError(msg, 24, obj.xmlfiles) targets.append(target.name) diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 6a930cf37..5da314b0d 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -54,7 +54,7 @@ - + @@ -79,13 +79,13 @@ - + - + diff --git a/src/rougail/data/rougail.yml b/src/rougail/data/rougail.yml index 0021492e4..66476dc45 100644 --- a/src/rougail/data/rougail.yml +++ b/src/rougail/data/rougail.yml @@ -57,11 +57,6 @@ mapping: - "content" engine: type: str - enum: - - "none" - - "cheetah" - - "jinja" - - "creole_legacy" redefine: type: bool filelist: @@ -105,10 +100,6 @@ mapping: type: str engine: type: str - enum: - - "none" - - "cheetah" - - "jinja" certificate: required: false type: seq @@ -178,10 +169,6 @@ mapping: type: str engine: type: str - enum: - - "none" - - "cheetah" - - "jinja" disabled: type: bool servicelist: diff --git a/src/rougail/template/base.py b/src/rougail/template/base.py index fdb620c40..6ba0ef854 100644 --- a/src/rougail/template/base.py +++ b/src/rougail/template/base.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022 +Copyright (C) 2022-2023 distribued with GPL-2 or later license @@ -359,10 +359,13 @@ class RougailBaseTemplate: destfilenames.append(destfilename) return destfilenames - async def load_variables(self): + async def load_variables(self, with_flatten=True): for option in await self.config.option.list(type='all'): namespace = await option.option.name() - is_variable_namespace = namespace == self.rougailconfig['variable_namespace'] + if with_flatten and namespace == self.rougailconfig['variable_namespace']: + is_variable_namespace = True + else: + is_variable_namespace = False if namespace == 'services': is_service_namespace = 'root' else: diff --git a/src/rougail/template/engine/jinja.py b/src/rougail/template/engine/jinja.py index 9d56231ea..3c1d7ddb7 100644 --- a/src/rougail/template/engine/jinja.py +++ b/src/rougail/template/engine/jinja.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2021 Silique (https://www.silique.fr) -Copyright (C) 2022 +Copyright (C) 2022-2023 distribued with GPL-2 or later license diff --git a/src/rougail/tiramisureflector.py b/src/rougail/tiramisureflector.py index 490543437..de54e5540 100644 --- a/src/rougail/tiramisureflector.py +++ b/src/rougail/tiramisureflector.py @@ -285,7 +285,7 @@ class Common: if child.inverse: kwargs += ", 'reverse_condition': ParamValue(True)" return (f"Calculation(func.calc_value, Params(ParamValue('{child.name}'), " - f"kwargs={{{kwargs}}}))") + f"kwargs={{{kwargs}}}), func.calc_value_property_help)") def populate_informations(self): """Populate Tiramisu's informations diff --git a/tests/dictionaries/40family_unique_not_same_family/__init__.py b/tests/dictionaries/40family_unique_not_same_family/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/40family_unique_not_same_family/errno_55 b/tests/dictionaries/40family_unique_not_same_family/errno_55 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/40family_unique_not_same_family/xml/00-base.xml b/tests/dictionaries/40family_unique_not_same_family/xml/00-base.xml new file mode 100644 index 000000000..768591e0b --- /dev/null +++ b/tests/dictionaries/40family_unique_not_same_family/xml/00-base.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/dictionaries/40family_unique_not_same_family/yml/00-base.yml b/tests/dictionaries/40family_unique_not_same_family/yml/00-base.yml new file mode 100644 index 000000000..67d9c9c51 --- /dev/null +++ b/tests/dictionaries/40family_unique_not_same_family/yml/00-base.yml @@ -0,0 +1,10 @@ +version: '0.10' +variables: +- family: + - name: general + variables: + - family: + - name: general + variables: + - variable: + - name: my_variable diff --git a/tests/eosfunc/test.py b/tests/eosfunc/test.py index 5be275936..eec726c31 100644 --- a/tests/eosfunc/test.py +++ b/tests/eosfunc/test.py @@ -1,4 +1,4 @@ -from tiramisu import valid_not_equal, valid_ip_netmask, calc_value, valid_in_network +from tiramisu import valid_not_equal, valid_ip_netmask, calc_value, valid_in_network, calc_value_property_help def trange(start, stop):