From d1398625680f536da2e177ee2e4f199a0d048c16 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 18 Feb 2020 22:12:55 +0100 Subject: [PATCH] todict in valid_not_equal --- data/rougail.dtd | 1 + src/rougail/loader.py | 12 +++++++++--- src/rougail/template.py | 7 +++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/data/rougail.dtd b/data/rougail.dtd index f10e8d00..4dc3ef58 100644 --- a/data/rougail.dtd +++ b/data/rougail.dtd @@ -143,6 +143,7 @@ + diff --git a/src/rougail/loader.py b/src/rougail/loader.py index 2d52adef..6bcfc4e5 100644 --- a/src/rougail/loader.py +++ b/src/rougail/loader.py @@ -25,6 +25,9 @@ from .utils import normalize_family import imp +FUNC_TO_DICT = ['valid_not_equal'] + + class ConvertDynOptionDescription(DynOptionDescription): def convert_suffix_to_path(self, suffix): return normalize_family(suffix, @@ -323,7 +326,7 @@ class Variable(Common): value = submulti else: raise CreoleLoaderError(_('unknown value {} for {}').format(value, key)) - if key == 'help': + if key in ['help', 'test']: self.add_information(key, value) elif key == 'type': pass @@ -357,7 +360,7 @@ class Variable(Common): self.attrib['properties'].append(child.text) elif child.tag == 'value': if child.attrib.get('type') == 'calculation': - if child.text.strip(): + if child.text is not None and child.text.strip(): self.attrib['default'] = (child.text.strip(),) else: params = [] @@ -457,7 +460,10 @@ class Variable(Common): if len(value) == 3: for param in value[1]: if isinstance(param[1], list): - param_value = ParamOption(self.storage.get(param[1][0]).get(), notraisepropertyerror=param[1][1]) + if value[0] in FUNC_TO_DICT: + param_value = ParamOption(self.storage.get(param[1][0]).get(), notraisepropertyerror=param[1][1], todict=True) + else: + param_value = ParamOption(self.storage.get(param[1][0]).get(), notraisepropertyerror=param[1][1]) else: param_value = ParamValue(param[1]) if not param[0]: diff --git a/src/rougail/template.py b/src/rougail/template.py index d6ed3c43..1a933da8 100644 --- a/src/rougail/template.py +++ b/src/rougail/template.py @@ -122,7 +122,6 @@ class CheetahTemplate(ChtTemplate): """Initialize Creole CheetahTemplate """ extra_context = {'is_defined' : IsDefined(context), - # 'creole_client' : CreoleClient(config), 'normalize_family': normalize_family, 'rougail_filename': destfilename } @@ -138,9 +137,9 @@ class CreoleLeader: """ On rend la variable itérable pour pouvoir faire: for ip in iplist: - print ip.network - print ip.netmask - print ip + print(ip.network) + print(ip.netmask) + print(ip) index is used for CreoleLint """ self._value = value