todict in valid_not_equal

This commit is contained in:
Emmanuel Garette 2020-02-18 22:12:55 +01:00
parent 9bb1a8c26a
commit d139862568
3 changed files with 13 additions and 7 deletions

View file

@ -143,6 +143,7 @@
<!ATTLIST variable mode (basic|normal|expert) "normal"> <!ATTLIST variable mode (basic|normal|expert) "normal">
<!ATTLIST variable remove_check (True|False) "False"> <!ATTLIST variable remove_check (True|False) "False">
<!ATTLIST variable remove_condition (True|False) "False"> <!ATTLIST variable remove_condition (True|False) "False">
<!ATTLIST variable test CDATA #IMPLIED>
<!ELEMENT separators (separator*)> <!ELEMENT separators (separator*)>

View file

@ -25,6 +25,9 @@ from .utils import normalize_family
import imp import imp
FUNC_TO_DICT = ['valid_not_equal']
class ConvertDynOptionDescription(DynOptionDescription): class ConvertDynOptionDescription(DynOptionDescription):
def convert_suffix_to_path(self, suffix): def convert_suffix_to_path(self, suffix):
return normalize_family(suffix, return normalize_family(suffix,
@ -323,7 +326,7 @@ class Variable(Common):
value = submulti value = submulti
else: else:
raise CreoleLoaderError(_('unknown value {} for {}').format(value, key)) raise CreoleLoaderError(_('unknown value {} for {}').format(value, key))
if key == 'help': if key in ['help', 'test']:
self.add_information(key, value) self.add_information(key, value)
elif key == 'type': elif key == 'type':
pass pass
@ -357,7 +360,7 @@ class Variable(Common):
self.attrib['properties'].append(child.text) self.attrib['properties'].append(child.text)
elif child.tag == 'value': elif child.tag == 'value':
if child.attrib.get('type') == 'calculation': 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(),) self.attrib['default'] = (child.text.strip(),)
else: else:
params = [] params = []
@ -457,7 +460,10 @@ class Variable(Common):
if len(value) == 3: if len(value) == 3:
for param in value[1]: for param in value[1]:
if isinstance(param[1], list): 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: else:
param_value = ParamValue(param[1]) param_value = ParamValue(param[1])
if not param[0]: if not param[0]:

View file

@ -122,7 +122,6 @@ class CheetahTemplate(ChtTemplate):
"""Initialize Creole CheetahTemplate """Initialize Creole CheetahTemplate
""" """
extra_context = {'is_defined' : IsDefined(context), extra_context = {'is_defined' : IsDefined(context),
# 'creole_client' : CreoleClient(config),
'normalize_family': normalize_family, 'normalize_family': normalize_family,
'rougail_filename': destfilename 'rougail_filename': destfilename
} }
@ -138,9 +137,9 @@ class CreoleLeader:
""" """
On rend la variable itérable pour pouvoir faire: On rend la variable itérable pour pouvoir faire:
for ip in iplist: for ip in iplist:
print ip.network print(ip.network)
print ip.netmask print(ip.netmask)
print ip print(ip)
index is used for CreoleLint index is used for CreoleLint
""" """
self._value = value self._value = value