Compare commits
No commits in common. "4351662f2e30d1bee58de4eb2ce88a7882df597f" and "5bf8d69e91e3b7bd3dd1307606099d52c71c0eb0" have entirely different histories.
4351662f2e
...
5bf8d69e91
|
@ -38,7 +38,7 @@ modes = mode_factory()
|
||||||
# that shall not be present in the exported (flatened) XML
|
# that shall not be present in the exported (flatened) XML
|
||||||
ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace',
|
ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace',
|
||||||
'remove_condition', 'path', 'instance_mode', 'index', 'is_in_leadership',
|
'remove_condition', 'path', 'instance_mode', 'index', 'is_in_leadership',
|
||||||
'level', 'remove_fill', 'xmlfiles')
|
'level', 'remove_fill')
|
||||||
ERASED_CONTAINER_ATTRIBUTES = ('id', 'container', 'group_id', 'group', 'container_group')
|
ERASED_CONTAINER_ATTRIBUTES = ('id', 'container', 'group_id', 'group', 'container_group')
|
||||||
|
|
||||||
FORCE_CHOICE = {'oui/non': ['oui', 'non'],
|
FORCE_CHOICE = {'oui/non': ['oui', 'non'],
|
||||||
|
@ -125,7 +125,7 @@ class GroupAnnotator:
|
||||||
# if variable.hidden:
|
# if variable.hidden:
|
||||||
# leader_is_hidden = True
|
# leader_is_hidden = True
|
||||||
else:
|
else:
|
||||||
leader_space = self.objectspace.Leadership(variable.xmlfiles)
|
leader_space = self.objectspace.Leadership()
|
||||||
leader_is_hidden = self.manage_leader(leader_space,
|
leader_is_hidden = self.manage_leader(leader_space,
|
||||||
leader_family_name,
|
leader_family_name,
|
||||||
leader_name,
|
leader_name,
|
||||||
|
@ -233,7 +233,7 @@ class ServiceAnnotator:
|
||||||
families = {}
|
families = {}
|
||||||
for idx, service_name in enumerate(self.objectspace.space.services.service.keys()):
|
for idx, service_name in enumerate(self.objectspace.space.services.service.keys()):
|
||||||
service = self.objectspace.space.services.service[service_name]
|
service = self.objectspace.space.services.service[service_name]
|
||||||
new_service = self.objectspace.service(service.xmlfiles)
|
new_service = self.objectspace.service()
|
||||||
for elttype, values in vars(service).items():
|
for elttype, values in vars(service).items():
|
||||||
if not isinstance(values, (dict, list)) or elttype in ERASED_ATTRIBUTES:
|
if not isinstance(values, (dict, list)) or elttype in ERASED_ATTRIBUTES:
|
||||||
setattr(new_service, elttype, values)
|
setattr(new_service, elttype, values)
|
||||||
|
@ -242,7 +242,6 @@ class ServiceAnnotator:
|
||||||
path = '.'.join(['services', service_name, eltname])
|
path = '.'.join(['services', service_name, eltname])
|
||||||
family = self.gen_family(eltname,
|
family = self.gen_family(eltname,
|
||||||
path,
|
path,
|
||||||
service.xmlfiles,
|
|
||||||
)
|
)
|
||||||
if isinstance(values, dict):
|
if isinstance(values, dict):
|
||||||
values = list(values.values())
|
values = list(values.values())
|
||||||
|
@ -259,9 +258,8 @@ class ServiceAnnotator:
|
||||||
def gen_family(self,
|
def gen_family(self,
|
||||||
name,
|
name,
|
||||||
path,
|
path,
|
||||||
xmlfiles
|
|
||||||
):
|
):
|
||||||
family = self.objectspace.family(xmlfiles)
|
family = self.objectspace.family()
|
||||||
family.name = normalize_family(name)
|
family.name = normalize_family(name)
|
||||||
family.doc = name
|
family.doc = name
|
||||||
family.mode = None
|
family.mode = None
|
||||||
|
@ -309,10 +307,7 @@ class ServiceAnnotator:
|
||||||
if not self.objectspace.paths.family_is_defined(subpath):
|
if not self.objectspace.paths.family_is_defined(subpath):
|
||||||
break
|
break
|
||||||
idx += 1
|
idx += 1
|
||||||
family = self.gen_family(c_name,
|
family = self.gen_family(c_name, subpath)
|
||||||
subpath,
|
|
||||||
elt.xmlfiles,
|
|
||||||
)
|
|
||||||
family.variable = []
|
family.variable = []
|
||||||
listname = '{}list'.format(name)
|
listname = '{}list'.format(name)
|
||||||
activate_path = '.'.join([subpath, 'activate'])
|
activate_path = '.'.join([subpath, 'activate'])
|
||||||
|
@ -350,7 +345,7 @@ class ServiceAnnotator:
|
||||||
elt,
|
elt,
|
||||||
path,
|
path,
|
||||||
):
|
):
|
||||||
variable = self.objectspace.variable(elt.xmlfiles)
|
variable = self.objectspace.variable()
|
||||||
variable.name = normalize_family(key)
|
variable.name = normalize_family(key)
|
||||||
variable.mode = None
|
variable.mode = None
|
||||||
if key == 'name':
|
if key == 'name':
|
||||||
|
@ -375,7 +370,7 @@ class ServiceAnnotator:
|
||||||
variable.multi = None
|
variable.multi = None
|
||||||
else:
|
else:
|
||||||
variable.doc = key
|
variable.doc = key
|
||||||
val = self.objectspace.value(elt.xmlfiles)
|
val = self.objectspace.value()
|
||||||
val.type = type_
|
val.type = type_
|
||||||
val.name = value
|
val.name = value
|
||||||
variable.value = [val]
|
variable.value = [val]
|
||||||
|
@ -474,17 +469,17 @@ class VariableAnnotator:
|
||||||
path,
|
path,
|
||||||
):
|
):
|
||||||
if variable.type in FORCE_CHOICE:
|
if variable.type in FORCE_CHOICE:
|
||||||
check = self.objectspace.check(variable.xmlfiles)
|
check = self.objectspace.check()
|
||||||
check.name = 'valid_enum'
|
check.name = 'valid_enum'
|
||||||
check.target = path
|
check.target = path
|
||||||
check.namespace = namespace
|
check.namespace = namespace
|
||||||
check.param = []
|
check.param = []
|
||||||
for value in FORCE_CHOICE[variable.type]:
|
for value in FORCE_CHOICE[variable.type]:
|
||||||
param = self.objectspace.param(variable.xmlfiles)
|
param = self.objectspace.param()
|
||||||
param.text = value
|
param.text = value
|
||||||
check.param.append(param)
|
check.param.append(param)
|
||||||
if not hasattr(self.objectspace.space, 'constraints'):
|
if not hasattr(self.objectspace.space, 'constraints'):
|
||||||
self.objectspace.space.constraints = self.objectspace.constraints(variable.xmlfiles)
|
self.objectspace.space.constraints = self.objectspace.constraints()
|
||||||
self.objectspace.space.constraints.namespace = namespace
|
self.objectspace.space.constraints.namespace = namespace
|
||||||
if not hasattr(self.objectspace.space.constraints, 'check'):
|
if not hasattr(self.objectspace.space.constraints, 'check'):
|
||||||
self.objectspace.space.constraints.check = []
|
self.objectspace.space.constraints.check = []
|
||||||
|
@ -547,14 +542,14 @@ class VariableAnnotator:
|
||||||
def convert_auto_freeze(self): # pylint: disable=C0111
|
def convert_auto_freeze(self): # pylint: disable=C0111
|
||||||
def _convert_auto_freeze(variable, namespace):
|
def _convert_auto_freeze(variable, namespace):
|
||||||
if variable.auto_freeze:
|
if variable.auto_freeze:
|
||||||
new_condition = self.objectspace.condition(variable.xmlfiles)
|
new_condition = self.objectspace.condition()
|
||||||
new_condition.name = 'auto_hidden_if_not_in'
|
new_condition.name = 'auto_hidden_if_not_in'
|
||||||
new_condition.namespace = namespace
|
new_condition.namespace = namespace
|
||||||
new_condition.source = FREEZE_AUTOFREEZE_VARIABLE
|
new_condition.source = FREEZE_AUTOFREEZE_VARIABLE
|
||||||
new_param = self.objectspace.param(variable.xmlfiles)
|
new_param = self.objectspace.param()
|
||||||
new_param.text = 'oui'
|
new_param.text = 'oui'
|
||||||
new_condition.param = [new_param]
|
new_condition.param = [new_param]
|
||||||
new_target = self.objectspace.target(variable.xmlfiles)
|
new_target = self.objectspace.target()
|
||||||
new_target.type = 'variable'
|
new_target.type = 'variable'
|
||||||
path = variable.namespace + '.' + normalize_family(family.name) + '.' + variable.name
|
path = variable.namespace + '.' + normalize_family(family.name) + '.' + variable.name
|
||||||
new_target.name = path
|
new_target.name = path
|
||||||
|
@ -588,8 +583,7 @@ class VariableAnnotator:
|
||||||
subpath = self.objectspace.paths.get_variable_path(separator.name,
|
subpath = self.objectspace.paths.get_variable_path(separator.name,
|
||||||
separator.namespace,
|
separator.namespace,
|
||||||
)
|
)
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(separator.xmlfiles)
|
raise DictConsistencyError(_('{} already has a separator').format(subpath))
|
||||||
raise DictConsistencyError(_(f'{subpath} already has a separator in {xmlfiles}'))
|
|
||||||
option.separator = separator.text
|
option.separator = separator.text
|
||||||
del family.separators
|
del family.separators
|
||||||
|
|
||||||
|
@ -628,8 +622,7 @@ class ConstraintAnnotator:
|
||||||
remove_indexes = []
|
remove_indexes = []
|
||||||
for check_idx, check in enumerate(self.objectspace.space.constraints.check):
|
for check_idx, check in enumerate(self.objectspace.space.constraints.check):
|
||||||
if not check.name in self.functions:
|
if not check.name in self.functions:
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
raise DictConsistencyError(_('cannot find check function {}').format(check.name))
|
||||||
raise DictConsistencyError(_(f'cannot find check function "{check.name}" in {xmlfiles}'))
|
|
||||||
if hasattr(check, 'param'):
|
if hasattr(check, 'param'):
|
||||||
param_option_indexes = []
|
param_option_indexes = []
|
||||||
for idx, param in enumerate(check.param):
|
for idx, param in enumerate(check.param):
|
||||||
|
@ -637,8 +630,7 @@ class ConstraintAnnotator:
|
||||||
if param.optional is True:
|
if param.optional is True:
|
||||||
param_option_indexes.append(idx)
|
param_option_indexes.append(idx)
|
||||||
else:
|
else:
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
raise DictConsistencyError(_(f'unknown param {param.text} in check'))
|
||||||
raise DictConsistencyError(_(f'cannot find check param "{param.text}" in {xmlfiles}'))
|
|
||||||
if param.type != 'variable':
|
if param.type != 'variable':
|
||||||
param.notraisepropertyerror = None
|
param.notraisepropertyerror = None
|
||||||
param_option_indexes = list(set(param_option_indexes))
|
param_option_indexes = list(set(param_option_indexes))
|
||||||
|
@ -774,7 +766,7 @@ class ConstraintAnnotator:
|
||||||
for listvar in listvars:
|
for listvar in listvars:
|
||||||
variable = self.objectspace.paths.get_variable_obj(listvar)
|
variable = self.objectspace.paths.get_variable_obj(listvar)
|
||||||
type_ = 'variable'
|
type_ = 'variable'
|
||||||
new_target = self.objectspace.target(variable.xmlfiles)
|
new_target = self.objectspace.target()
|
||||||
new_target.type = type_
|
new_target.type = type_
|
||||||
new_target.name = listvar
|
new_target.name = listvar
|
||||||
new_target.index = target.index
|
new_target.index = target.index
|
||||||
|
@ -899,7 +891,7 @@ class ConstraintAnnotator:
|
||||||
if hasattr(leader_or_variable, actions[0]) and getattr(leader_or_variable, actions[0]) is True:
|
if hasattr(leader_or_variable, actions[0]) and getattr(leader_or_variable, actions[0]) is True:
|
||||||
continue
|
continue
|
||||||
for idx, action in enumerate(actions):
|
for idx, action in enumerate(actions):
|
||||||
prop = self.objectspace.property_(leader_or_variable.xmlfiles)
|
prop = self.objectspace.property_()
|
||||||
prop.type = 'calculation'
|
prop.type = 'calculation'
|
||||||
prop.inverse = inverse
|
prop.inverse = inverse
|
||||||
prop.source = condition.source
|
prop.source = condition.source
|
||||||
|
@ -932,7 +924,7 @@ class ConstraintAnnotator:
|
||||||
}
|
}
|
||||||
choices = []
|
choices = []
|
||||||
for value in values:
|
for value in values:
|
||||||
choice = self.objectspace.choice(variable.xmlfiles)
|
choice = self.objectspace.choice()
|
||||||
try:
|
try:
|
||||||
if value is not None:
|
if value is not None:
|
||||||
choice.name = CONVERSION.get(type_, str)(value)
|
choice.name = CONVERSION.get(type_, str)(value)
|
||||||
|
@ -956,7 +948,7 @@ class ConstraintAnnotator:
|
||||||
if cvalue not in choices:
|
if cvalue not in choices:
|
||||||
raise DictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
|
raise DictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
|
||||||
else:
|
else:
|
||||||
new_value = self.objectspace.value(variable.xmlfiles)
|
new_value = self.objectspace.value()
|
||||||
new_value.name = choices[0]
|
new_value.name = choices[0]
|
||||||
new_value.type = type_
|
new_value.type = type_
|
||||||
variable.value = [new_value]
|
variable.value = [new_value]
|
||||||
|
@ -981,30 +973,26 @@ class ConstraintAnnotator:
|
||||||
else:
|
else:
|
||||||
raise DictConsistencyError(_(f'unknown parameter {param.text} in check "valid_entier" for variable {check.target}'))
|
raise DictConsistencyError(_(f'unknown parameter {param.text} in check "valid_entier" for variable {check.target}'))
|
||||||
else:
|
else:
|
||||||
check_ = self.objectspace.check(variable.xmlfiles)
|
check_ = self.objectspace.check()
|
||||||
if name == 'valid_differ':
|
if name == 'valid_differ':
|
||||||
name = 'valid_not_equal'
|
name = 'valid_not_equal'
|
||||||
elif name == 'valid_network_netmask':
|
elif name == 'valid_network_netmask':
|
||||||
params_len = 1
|
params_len = 1
|
||||||
if len(check.param) != params_len:
|
if len(check.param) != params_len:
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||||
raise DictConsistencyError(_(f'{name} must have {params_len} param in {xmlfiles}'))
|
|
||||||
elif name == 'valid_ipnetmask':
|
elif name == 'valid_ipnetmask':
|
||||||
params_len = 1
|
params_len = 1
|
||||||
if len(check.param) != params_len:
|
if len(check.param) != params_len:
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||||
raise DictConsistencyError(_(f'{name} must have {params_len} param in {xmlfiles}'))
|
|
||||||
name = 'valid_ip_netmask'
|
name = 'valid_ip_netmask'
|
||||||
elif name == 'valid_broadcast':
|
elif name == 'valid_broadcast':
|
||||||
params_len = 2
|
params_len = 2
|
||||||
if len(check.param) != params_len:
|
if len(check.param) != params_len:
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||||
raise DictConsistencyError(_(f'{name} must have {params_len} param in {xmlfiles}'))
|
|
||||||
elif name == 'valid_in_network':
|
elif name == 'valid_in_network':
|
||||||
if len(check.param) not in (1, 2):
|
|
||||||
params_len = 2
|
params_len = 2
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
if len(check.param) != params_len:
|
||||||
raise DictConsistencyError(_(f'{name} must have {params_len} param in {xmlfiles}'))
|
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||||
check_.name = name
|
check_.name = name
|
||||||
check_.warnings_only = check.warnings_only
|
check_.warnings_only = check.warnings_only
|
||||||
if hasattr(check, 'param'):
|
if hasattr(check, 'param'):
|
||||||
|
@ -1038,8 +1026,7 @@ class ConstraintAnnotator:
|
||||||
)
|
)
|
||||||
if suffix is not None:
|
if suffix is not None:
|
||||||
raise DictConsistencyError(_(f'Cannot add fill function to "{fill.target}" only with the suffix "{suffix}"'))
|
raise DictConsistencyError(_(f'Cannot add fill function to "{fill.target}" only with the suffix "{suffix}"'))
|
||||||
variable = self.objectspace.paths.get_variable_obj(fill.target)
|
value = self.objectspace.value()
|
||||||
value = self.objectspace.value(variable.xmlfiles)
|
|
||||||
value.type = 'calculation'
|
value.type = 'calculation'
|
||||||
value.name = fill.name
|
value.name = fill.name
|
||||||
if hasattr(fill, 'param'):
|
if hasattr(fill, 'param'):
|
||||||
|
@ -1071,6 +1058,7 @@ class ConstraintAnnotator:
|
||||||
for param_idx in param_to_delete:
|
for param_idx in param_to_delete:
|
||||||
fill.param.pop(param_idx)
|
fill.param.pop(param_idx)
|
||||||
value.param = fill.param
|
value.param = fill.param
|
||||||
|
variable = self.objectspace.paths.get_variable_obj(fill.target)
|
||||||
variable.value = [value]
|
variable.value = [value]
|
||||||
del self.objectspace.space.constraints.fill
|
del self.objectspace.space.constraints.fill
|
||||||
|
|
||||||
|
@ -1078,7 +1066,6 @@ class ConstraintAnnotator:
|
||||||
if hasattr(self.objectspace.space.constraints, 'index'):
|
if hasattr(self.objectspace.space.constraints, 'index'):
|
||||||
del self.objectspace.space.constraints.index
|
del self.objectspace.space.constraints.index
|
||||||
del self.objectspace.space.constraints.namespace
|
del self.objectspace.space.constraints.namespace
|
||||||
del self.objectspace.space.constraints.xmlfiles
|
|
||||||
if vars(self.objectspace.space.constraints):
|
if vars(self.objectspace.space.constraints):
|
||||||
raise Exception('constraints again?')
|
raise Exception('constraints again?')
|
||||||
del self.objectspace.space.constraints
|
del self.objectspace.space.constraints
|
||||||
|
@ -1139,7 +1126,7 @@ class FamilyAnnotator:
|
||||||
# if the variable is mandatory and doesn't have any value
|
# if the variable is mandatory and doesn't have any value
|
||||||
# then the variable's mode is set to 'basic'
|
# then the variable's mode is set to 'basic'
|
||||||
if not hasattr(variable, 'value') and variable.type == 'boolean':
|
if not hasattr(variable, 'value') and variable.type == 'boolean':
|
||||||
new_value = self.objectspace.value(variable.xmlfiles)
|
new_value = self.objectspace.value()
|
||||||
new_value.name = True
|
new_value.name = True
|
||||||
new_value.type = 'boolean'
|
new_value.type = 'boolean'
|
||||||
variable.value = [new_value]
|
variable.value = [new_value]
|
||||||
|
|
|
@ -59,10 +59,7 @@ CONVERT_EXPORT = {'Leadership': 'leader',
|
||||||
# _____________________________________________________________________________
|
# _____________________________________________________________________________
|
||||||
# special types definitions for the Object Space's internal representation
|
# special types definitions for the Object Space's internal representation
|
||||||
class RootCreoleObject:
|
class RootCreoleObject:
|
||||||
def __init__(self, xmlfiles):
|
""
|
||||||
if not isinstance(xmlfiles, list):
|
|
||||||
xmlfiles = [xmlfiles]
|
|
||||||
self.xmlfiles = xmlfiles
|
|
||||||
|
|
||||||
|
|
||||||
class CreoleObjSpace:
|
class CreoleObjSpace:
|
||||||
|
@ -160,14 +157,12 @@ class CreoleObjSpace:
|
||||||
self.fill_removed = []
|
self.fill_removed = []
|
||||||
self.check_removed = []
|
self.check_removed = []
|
||||||
self.condition_removed = []
|
self.condition_removed = []
|
||||||
self.xml_parse_document(xmlfile,
|
self.xml_parse_document(document,
|
||||||
document,
|
|
||||||
self.space,
|
self.space,
|
||||||
namespace,
|
namespace,
|
||||||
)
|
)
|
||||||
|
|
||||||
def xml_parse_document(self,
|
def xml_parse_document(self,
|
||||||
xmlfile,
|
|
||||||
document,
|
document,
|
||||||
space,
|
space,
|
||||||
namespace,
|
namespace,
|
||||||
|
@ -184,7 +179,7 @@ class CreoleObjSpace:
|
||||||
continue
|
continue
|
||||||
if child.tag == 'family':
|
if child.tag == 'family':
|
||||||
if child.attrib['name'] in family_names:
|
if child.attrib['name'] in family_names:
|
||||||
raise DictConsistencyError(_(f'Family "{child.attrib["name"]}" is set several times in "{xmlfile}"'))
|
raise DictConsistencyError(_('Family {} is set several times').format(child.attrib['name']))
|
||||||
family_names.append(child.attrib['name'])
|
family_names.append(child.attrib['name'])
|
||||||
if child.tag == 'variables':
|
if child.tag == 'variables':
|
||||||
child.attrib['name'] = namespace
|
child.attrib['name'] = namespace
|
||||||
|
@ -193,8 +188,7 @@ class CreoleObjSpace:
|
||||||
continue
|
continue
|
||||||
# variable objects creation
|
# variable objects creation
|
||||||
try:
|
try:
|
||||||
variableobj = self.generate_variableobj(xmlfile,
|
variableobj = self.generate_variableobj(child,
|
||||||
child,
|
|
||||||
space,
|
space,
|
||||||
namespace,
|
namespace,
|
||||||
)
|
)
|
||||||
|
@ -203,8 +197,7 @@ class CreoleObjSpace:
|
||||||
self.set_text_to_obj(child,
|
self.set_text_to_obj(child,
|
||||||
variableobj,
|
variableobj,
|
||||||
)
|
)
|
||||||
self.set_xml_attributes_to_obj(xmlfile,
|
self.set_xml_attributes_to_obj(child,
|
||||||
child,
|
|
||||||
variableobj,
|
variableobj,
|
||||||
)
|
)
|
||||||
self.variableobj_tree_visitor(child,
|
self.variableobj_tree_visitor(child,
|
||||||
|
@ -222,14 +215,12 @@ class CreoleObjSpace:
|
||||||
child,
|
child,
|
||||||
)
|
)
|
||||||
if list(child) != []:
|
if list(child) != []:
|
||||||
self.xml_parse_document(xmlfile,
|
self.xml_parse_document(child,
|
||||||
child,
|
|
||||||
variableobj,
|
variableobj,
|
||||||
namespace,
|
namespace,
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_variableobj(self,
|
def generate_variableobj(self,
|
||||||
xmlfile,
|
|
||||||
child,
|
child,
|
||||||
space,
|
space,
|
||||||
namespace,
|
namespace,
|
||||||
|
@ -237,10 +228,9 @@ class CreoleObjSpace:
|
||||||
"""
|
"""
|
||||||
instanciates or creates Creole Object Subspace objects
|
instanciates or creates Creole Object Subspace objects
|
||||||
"""
|
"""
|
||||||
variableobj = getattr(self, child.tag)(xmlfile)
|
variableobj = getattr(self, child.tag)()
|
||||||
if isinstance(variableobj, self.Redefinable):
|
if isinstance(variableobj, self.Redefinable):
|
||||||
variableobj = self.create_or_update_redefinable_object(xmlfile,
|
variableobj = self.create_or_update_redefinable_object(child.attrib,
|
||||||
child.attrib,
|
|
||||||
space,
|
space,
|
||||||
child,
|
child,
|
||||||
namespace,
|
namespace,
|
||||||
|
@ -258,7 +248,6 @@ class CreoleObjSpace:
|
||||||
return variableobj
|
return variableobj
|
||||||
|
|
||||||
def create_or_update_redefinable_object(self,
|
def create_or_update_redefinable_object(self,
|
||||||
xmlfile,
|
|
||||||
subspace,
|
subspace,
|
||||||
space,
|
space,
|
||||||
child,
|
child,
|
||||||
|
@ -292,17 +281,15 @@ class CreoleObjSpace:
|
||||||
name = child.text
|
name = child.text
|
||||||
else:
|
else:
|
||||||
name = subspace['name']
|
name = subspace['name']
|
||||||
existed_var = self.is_already_exists(name,
|
if self.is_already_exists(name,
|
||||||
space,
|
space,
|
||||||
child,
|
child,
|
||||||
namespace,
|
namespace,
|
||||||
)
|
):
|
||||||
if existed_var:
|
|
||||||
default_redefine = child.tag in FORCE_REDEFINABLES
|
default_redefine = child.tag in FORCE_REDEFINABLES
|
||||||
redefine = self.convert_boolean(subspace.get('redefine', default_redefine))
|
redefine = self.convert_boolean(subspace.get('redefine', default_redefine))
|
||||||
exists = self.convert_boolean(subspace.get('exists', True))
|
exists = self.convert_boolean(subspace.get('exists', True))
|
||||||
if redefine is True:
|
if redefine is True:
|
||||||
existed_var.xmlfiles.append(xmlfile)
|
|
||||||
return self.translate_in_space(name,
|
return self.translate_in_space(name,
|
||||||
space,
|
space,
|
||||||
child,
|
child,
|
||||||
|
@ -310,21 +297,12 @@ class CreoleObjSpace:
|
||||||
)
|
)
|
||||||
elif exists is False:
|
elif exists is False:
|
||||||
raise SpaceObjShallNotBeUpdated()
|
raise SpaceObjShallNotBeUpdated()
|
||||||
xmlfiles = self.display_xmlfiles(existed_var.xmlfiles)
|
raise DictConsistencyError(_(f'Already present in another XML file, {name} cannot be re-created'))
|
||||||
raise DictConsistencyError(_(f'"{child.tag}" named "{name}" cannot be re-created in "{xmlfile}", already defined in {xmlfiles}'))
|
|
||||||
redefine = self.convert_boolean(subspace.get('redefine', False))
|
redefine = self.convert_boolean(subspace.get('redefine', False))
|
||||||
exists = self.convert_boolean(subspace.get('exists', False))
|
exists = self.convert_boolean(subspace.get('exists', False))
|
||||||
if redefine is False or exists is True:
|
if redefine is False or exists is True:
|
||||||
return getattr(self, child.tag)(xmlfile)
|
return getattr(self, child.tag)()
|
||||||
raise DictConsistencyError(_(f'Redefined object in "{xmlfile}": "{name}" does not exist yet'))
|
raise DictConsistencyError(_(f'Redefined object: {name} does not exist yet'))
|
||||||
|
|
||||||
def display_xmlfiles(self,
|
|
||||||
xmlfiles: list,
|
|
||||||
) -> str:
|
|
||||||
if len(xmlfiles) == 1:
|
|
||||||
return '"' + xmlfiles[0] + '"'
|
|
||||||
else:
|
|
||||||
return '"' + '", "'.join(xmlfiles[:-1]) + '"' + ' and ' + '"' + xmlfiles[-1] + '"'
|
|
||||||
|
|
||||||
def create_tree_structure(self,
|
def create_tree_structure(self,
|
||||||
space,
|
space,
|
||||||
|
@ -351,25 +329,16 @@ class CreoleObjSpace:
|
||||||
raise OperationError(_("Creole object {} "
|
raise OperationError(_("Creole object {} "
|
||||||
"has a wrong type").format(type(variableobj)))
|
"has a wrong type").format(type(variableobj)))
|
||||||
|
|
||||||
def is_already_exists(self,
|
def is_already_exists(self, name, space, child, namespace):
|
||||||
name: str,
|
|
||||||
space: str,
|
|
||||||
child,
|
|
||||||
namespace: str,
|
|
||||||
):
|
|
||||||
if isinstance(space, self.family): # pylint: disable=E1101
|
if isinstance(space, self.family): # pylint: disable=E1101
|
||||||
if namespace != Config['variable_namespace']:
|
if namespace != Config['variable_namespace']:
|
||||||
name = space.path + '.' + name
|
name = space.path + '.' + name
|
||||||
if self.paths.path_is_defined(name):
|
return self.paths.path_is_defined(name)
|
||||||
return self.paths.get_variable_obj(name)
|
|
||||||
return
|
|
||||||
if child.tag == 'family':
|
if child.tag == 'family':
|
||||||
norm_name = normalize_family(name)
|
norm_name = normalize_family(name)
|
||||||
else:
|
else:
|
||||||
norm_name = name
|
norm_name = name
|
||||||
children = getattr(space, child.tag, {})
|
return norm_name in getattr(space, child.tag, {})
|
||||||
if norm_name in children:
|
|
||||||
return children[norm_name]
|
|
||||||
|
|
||||||
def convert_boolean(self, value): # pylint: disable=R0201
|
def convert_boolean(self, value): # pylint: disable=R0201
|
||||||
"""Boolean coercion. The Creole XML may contain srings like `True` or `False`
|
"""Boolean coercion. The Creole XML may contain srings like `True` or `False`
|
||||||
|
@ -482,7 +451,6 @@ class CreoleObjSpace:
|
||||||
variableobj.text = text
|
variableobj.text = text
|
||||||
|
|
||||||
def set_xml_attributes_to_obj(self,
|
def set_xml_attributes_to_obj(self,
|
||||||
xmlfile,
|
|
||||||
child,
|
child,
|
||||||
variableobj,
|
variableobj,
|
||||||
):
|
):
|
||||||
|
@ -495,8 +463,7 @@ class CreoleObjSpace:
|
||||||
# UNREDEFINABLE concerns only 'variable' node so we can fix name
|
# UNREDEFINABLE concerns only 'variable' node so we can fix name
|
||||||
# to child.attrib['name']
|
# to child.attrib['name']
|
||||||
name = child.attrib['name']
|
name = child.attrib['name']
|
||||||
xmlfiles = self.display_xmlfiles(variableobj.xmlfiles[:-1])
|
raise DictConsistencyError(_(f'cannot redefine attribute {attr} for variable {name}'))
|
||||||
raise DictConsistencyError(_(f'cannot redefine attribute "{attr}" for variable "{name}" in "{xmlfile}", already defined in {xmlfiles}'))
|
|
||||||
if attr in self.booleans_attributs:
|
if attr in self.booleans_attributs:
|
||||||
val = self.convert_boolean(val)
|
val = self.convert_boolean(val)
|
||||||
if not (attr == 'name' and getattr(variableobj, 'name', None) != None):
|
if not (attr == 'name' and getattr(variableobj, 'name', None) != None):
|
||||||
|
|
|
@ -13,8 +13,7 @@ class Path:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.variables = {}
|
self.variables = {}
|
||||||
self.families = {}
|
self.families = {}
|
||||||
self.full_paths_families = {}
|
self.full_paths = {}
|
||||||
self.full_paths_variables = {}
|
|
||||||
|
|
||||||
# Family
|
# Family
|
||||||
def add_family(self,
|
def add_family(self,
|
||||||
|
@ -24,7 +23,7 @@ class Path:
|
||||||
) -> str: # pylint: disable=C0111
|
) -> str: # pylint: disable=C0111
|
||||||
if '.' not in name and namespace == Config['variable_namespace']:
|
if '.' not in name and namespace == Config['variable_namespace']:
|
||||||
full_name = '.'.join([namespace, name])
|
full_name = '.'.join([namespace, name])
|
||||||
self.full_paths_families[name] = full_name
|
self.full_paths[name] = full_name
|
||||||
else:
|
else:
|
||||||
full_name = name
|
full_name = name
|
||||||
if full_name in self.families and self.families[full_name]['variableobj'] != variableobj:
|
if full_name in self.families and self.families[full_name]['variableobj'] != variableobj:
|
||||||
|
@ -42,8 +41,8 @@ class Path:
|
||||||
check_name=False,
|
check_name=False,
|
||||||
allow_dot=True,
|
allow_dot=True,
|
||||||
)
|
)
|
||||||
if '.' not in name and current_namespace == Config['variable_namespace'] and name in self.full_paths_families:
|
if '.' not in name and current_namespace == Config['variable_namespace'] and name in self.full_paths:
|
||||||
name = self.full_paths_families[name]
|
name = self.full_paths[name]
|
||||||
if current_namespace is None: # pragma: no cover
|
if current_namespace is None: # pragma: no cover
|
||||||
raise OperationError('current_namespace must not be None')
|
raise OperationError('current_namespace must not be None')
|
||||||
dico = self.families[name]
|
dico = self.families[name]
|
||||||
|
@ -56,8 +55,8 @@ class Path:
|
||||||
def get_family_obj(self,
|
def get_family_obj(self,
|
||||||
name: str,
|
name: str,
|
||||||
) -> 'Family': # pylint: disable=C0111
|
) -> 'Family': # pylint: disable=C0111
|
||||||
if '.' not in name and name in self.full_paths_families:
|
if '.' not in name and name in self.full_paths:
|
||||||
name = self.full_paths_families[name]
|
name = self.full_paths[name]
|
||||||
if name not in self.families:
|
if name not in self.families:
|
||||||
raise DictConsistencyError(_('unknown family {}').format(name))
|
raise DictConsistencyError(_('unknown family {}').format(name))
|
||||||
dico = self.families[name]
|
dico = self.families[name]
|
||||||
|
@ -66,7 +65,7 @@ class Path:
|
||||||
def family_is_defined(self,
|
def family_is_defined(self,
|
||||||
name: str,
|
name: str,
|
||||||
) -> str: # pylint: disable=C0111
|
) -> str: # pylint: disable=C0111
|
||||||
if '.' not in name and name not in self.families and name in self.full_paths_families:
|
if '.' not in name and name not in self.families and name in self.full_paths:
|
||||||
return True
|
return True
|
||||||
return name in self.families
|
return name in self.families
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ class Path:
|
||||||
dico['variableobj'],
|
dico['variableobj'],
|
||||||
)
|
)
|
||||||
if namespace == Config['variable_namespace']:
|
if namespace == Config['variable_namespace']:
|
||||||
self.full_paths_variables[name] = new_path
|
self.full_paths[name] = new_path
|
||||||
else:
|
else:
|
||||||
name = new_path
|
name = new_path
|
||||||
dico = self._get_variable(name)
|
dico = self._get_variable(name)
|
||||||
|
@ -111,7 +110,7 @@ class Path:
|
||||||
) -> str: # pylint: disable=C0111
|
) -> str: # pylint: disable=C0111
|
||||||
if '.' not in name:
|
if '.' not in name:
|
||||||
full_name = '.'.join([namespace, family, name])
|
full_name = '.'.join([namespace, family, name])
|
||||||
self.full_paths_variables[name] = full_name
|
self.full_paths[name] = full_name
|
||||||
else:
|
else:
|
||||||
full_name = name
|
full_name = name
|
||||||
if namespace == Config['variable_namespace']:
|
if namespace == Config['variable_namespace']:
|
||||||
|
@ -177,7 +176,7 @@ class Path:
|
||||||
def path_is_defined(self,
|
def path_is_defined(self,
|
||||||
name: str,
|
name: str,
|
||||||
) -> str: # pylint: disable=C0111
|
) -> str: # pylint: disable=C0111
|
||||||
if '.' not in name and name not in self.variables and name in self.full_paths_variables:
|
if '.' not in name and name not in self.variables and name in self.full_paths:
|
||||||
return True
|
return True
|
||||||
return name in self.variables
|
return name in self.variables
|
||||||
|
|
||||||
|
@ -187,8 +186,8 @@ class Path:
|
||||||
) -> str:
|
) -> str:
|
||||||
if name not in self.variables:
|
if name not in self.variables:
|
||||||
if name not in self.variables:
|
if name not in self.variables:
|
||||||
if '.' not in name and name in self.full_paths_variables:
|
if '.' not in name and name in self.full_paths:
|
||||||
name = self.full_paths_variables[name]
|
name = self.full_paths[name]
|
||||||
if name not in self.variables:
|
if name not in self.variables:
|
||||||
for var_name, variable in self.variables.items():
|
for var_name, variable in self.variables.items():
|
||||||
if variable['is_dynamic'] and name.startswith(var_name):
|
if variable['is_dynamic'] and name.startswith(var_name):
|
||||||
|
@ -196,9 +195,9 @@ class Path:
|
||||||
raise Exception('This option is dynamic, should use "with_suffix" attribute')
|
raise Exception('This option is dynamic, should use "with_suffix" attribute')
|
||||||
return variable, name[len(var_name):]
|
return variable, name[len(var_name):]
|
||||||
if '.' not in name:
|
if '.' not in name:
|
||||||
for var_name, path in self.full_paths_variables.items():
|
for var_name, path in self.full_paths.items():
|
||||||
if name.startswith(var_name):
|
if name.startswith(var_name):
|
||||||
variable = self.variables[self.full_paths_variables[var_name]]
|
variable = self.variables[self.full_paths[var_name]]
|
||||||
if variable['is_dynamic']:
|
if variable['is_dynamic']:
|
||||||
if not with_suffix:
|
if not with_suffix:
|
||||||
raise Exception('This option is dynamic, should use "with_suffix" attribute')
|
raise Exception('This option is dynamic, should use "with_suffix" attribute')
|
||||||
|
|
|
@ -37,7 +37,7 @@ class XMLReflector(object):
|
||||||
# document = parse(BytesIO(xmlfile), XMLParser(remove_blank_text=True))
|
# document = parse(BytesIO(xmlfile), XMLParser(remove_blank_text=True))
|
||||||
document = parse(xmlfile)
|
document = parse(xmlfile)
|
||||||
if not self.dtd.validate(document):
|
if not self.dtd.validate(document):
|
||||||
raise DictConsistencyError(_(f'"{xmlfile}" not a valid xml file: {self.dtd.error_log.filter_from_errors()[0]}'))
|
raise DictConsistencyError(_("not a valid xml file: {}").format(xmlfile))
|
||||||
return document.getroot()
|
return document.getroot()
|
||||||
|
|
||||||
def load_xml_from_folders(self, xmlfolders):
|
def load_xml_from_folders(self, xmlfolders):
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<rougail>
|
|
||||||
<variables>
|
|
||||||
<family name="general">
|
|
||||||
<variable name="general" type="oui/non" description="description">
|
|
||||||
<value>non</value>
|
|
||||||
</variable>
|
|
||||||
</family>
|
|
||||||
</variables>
|
|
||||||
</rougail>
|
|
||||||
<!-- vim: ts=4 sw=4 expandtab
|
|
||||||
-->
|
|
|
@ -1 +0,0 @@
|
||||||
{"rougail.general.general": "non"}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import imp
|
|
||||||
func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py')
|
|
||||||
for key, value in dict(locals()).items():
|
|
||||||
if key != ['imp', 'func']:
|
|
||||||
setattr(func, key, value)
|
|
||||||
try:
|
|
||||||
from tiramisu3 import *
|
|
||||||
except:
|
|
||||||
from tiramisu import *
|
|
||||||
from rougail.tiramisu import ConvertDynOptionDescription
|
|
||||||
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='general', doc='description', multi=False, default='non', values=('oui', 'non'))
|
|
||||||
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
|
|
||||||
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
|
|
||||||
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<rougail>
|
|
||||||
|
|
||||||
<services/>
|
|
||||||
|
|
||||||
<variables>
|
|
||||||
<family name="general">
|
|
||||||
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
|
|
||||||
<value>oui</value>
|
|
||||||
</variable>
|
|
||||||
<variable name="adresse_ip_eth0" type="local_ip" description="Adresse IP de la carte" mandatory="True" mode="basic"/>
|
|
||||||
<variable name="adresse_netmask_eth0" type="netmask" description="Masque de sous réseau de la carte" mandatory="True" mode="basic"/>
|
|
||||||
<variable name="adresse_ip" type="local_ip" description="IP" mandatory="True" mode="basic"/>
|
|
||||||
</family>
|
|
||||||
<separators/>
|
|
||||||
</variables>
|
|
||||||
|
|
||||||
<constraints>
|
|
||||||
<check name="valid_in_network" target="adresse_ip" level="warning">
|
|
||||||
<param type="variable">adresse_ip_eth0</param>
|
|
||||||
<param type="variable">adresse_netmask_eth0</param>
|
|
||||||
</check>
|
|
||||||
</constraints>
|
|
||||||
|
|
||||||
<help/>
|
|
||||||
|
|
||||||
</rougail>
|
|
||||||
<!-- vim: ts=4 sw=4 expandtab
|
|
||||||
-->
|
|
|
@ -1 +0,0 @@
|
||||||
{"rougail.general.mode_conteneur_actif": "oui", "rougail.general.adresse_ip_eth0": null, "rougail.general.adresse_netmask_eth0": null, "rougail.general.adresse_ip": null}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import imp
|
|
||||||
func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py')
|
|
||||||
for key, value in dict(locals()).items():
|
|
||||||
if key != ['imp', 'func']:
|
|
||||||
setattr(func, key, value)
|
|
||||||
try:
|
|
||||||
from tiramisu3 import *
|
|
||||||
except:
|
|
||||||
from tiramisu import *
|
|
||||||
from rougail.tiramisu import ConvertDynOptionDescription
|
|
||||||
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='oui', values=('oui', 'non'))
|
|
||||||
option_4 = IPOption(private_only=True, warnings_only=True, properties=frozenset({'basic', 'mandatory'}), name='adresse_ip_eth0', doc='Adresse IP de la carte', multi=False)
|
|
||||||
option_5 = NetmaskOption(properties=frozenset({'basic', 'mandatory'}), name='adresse_netmask_eth0', doc='Masque de sous réseau de la carte', multi=False)
|
|
||||||
option_6 = IPOption(private_only=True, warnings_only=True, properties=frozenset({'basic', 'mandatory'}), validators=[Calculation(func.valid_in_network, Params((ParamSelfOption(), ParamOption(option_4, notraisepropertyerror=False, todict=False), ParamOption(option_5, notraisepropertyerror=False, todict=False)), kwargs={}), warnings_only=True)], name='adresse_ip', doc='IP', multi=False)
|
|
||||||
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'basic'}), children=[option_3, option_4, option_5, option_6])
|
|
||||||
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
|
|
||||||
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<rougail>
|
|
||||||
|
|
||||||
<services/>
|
|
||||||
|
|
||||||
<variables>
|
|
||||||
<family name="general">
|
|
||||||
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
|
|
||||||
<value>oui</value>
|
|
||||||
</variable>
|
|
||||||
<variable name="adresse_ip_eth0" type="cidr" description="Adresse IP de la carte" mandatory="True" mode="basic"/>
|
|
||||||
<variable name="adresse_ip" type="local_ip" description="IP" mandatory="True" mode="basic"/>
|
|
||||||
</family>
|
|
||||||
<separators/>
|
|
||||||
</variables>
|
|
||||||
|
|
||||||
<constraints>
|
|
||||||
<check name="valid_in_network" target="adresse_ip" level="warning">
|
|
||||||
<param type="variable">adresse_ip_eth0</param>
|
|
||||||
</check>
|
|
||||||
</constraints>
|
|
||||||
|
|
||||||
<help/>
|
|
||||||
|
|
||||||
</rougail>
|
|
||||||
<!-- vim: ts=4 sw=4 expandtab
|
|
||||||
-->
|
|
|
@ -1 +0,0 @@
|
||||||
{"rougail.general.mode_conteneur_actif": "oui", "rougail.general.adresse_ip_eth0": null, "rougail.general.adresse_ip": null}
|
|
|
@ -1,16 +0,0 @@
|
||||||
import imp
|
|
||||||
func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py')
|
|
||||||
for key, value in dict(locals()).items():
|
|
||||||
if key != ['imp', 'func']:
|
|
||||||
setattr(func, key, value)
|
|
||||||
try:
|
|
||||||
from tiramisu3 import *
|
|
||||||
except:
|
|
||||||
from tiramisu import *
|
|
||||||
from rougail.tiramisu import ConvertDynOptionDescription
|
|
||||||
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='oui', values=('oui', 'non'))
|
|
||||||
option_4 = IPOption(cidr=True, properties=frozenset({'basic', 'mandatory'}), name='adresse_ip_eth0', doc='Adresse IP de la carte', multi=False)
|
|
||||||
option_5 = IPOption(private_only=True, warnings_only=True, properties=frozenset({'basic', 'mandatory'}), validators=[Calculation(func.valid_in_network, Params((ParamSelfOption(), ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={}), warnings_only=True)], name='adresse_ip', doc='IP', multi=False)
|
|
||||||
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'basic'}), children=[option_3, option_4, option_5])
|
|
||||||
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
|
|
||||||
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<rougail>
|
|
||||||
|
|
||||||
<services/>
|
|
||||||
|
|
||||||
<variables>
|
|
||||||
<family name="extra">
|
|
||||||
<variable name="mode_conteneur_actif" type="oui/non" description="No change" hidden="True">
|
|
||||||
<value>non</value>
|
|
||||||
</variable>
|
|
||||||
<variable name="activer_ejabberd" type="oui/non" description="No change" hidden="True">
|
|
||||||
<value>non</value>
|
|
||||||
</variable>
|
|
||||||
</family>
|
|
||||||
<separators/>
|
|
||||||
</variables>
|
|
||||||
|
|
||||||
<constraints>
|
|
||||||
</constraints>
|
|
||||||
|
|
||||||
<help/>
|
|
||||||
|
|
||||||
</rougail>
|
|
||||||
<!-- vim: ts=4 sw=4 expandtab
|
|
||||||
-->
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?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>
|
|
|
@ -1 +0,0 @@
|
||||||
{"rougail.extra.mode_conteneur_actif": "non", "rougail.extra.activer_ejabberd": "non", "extra.ejabberd.description": "Exportation de la base de ejabberd", "extra.ejabberd.day": null, "extra.ejabberd.mode": "pre"}
|
|
|
@ -1,20 +0,0 @@
|
||||||
import imp
|
|
||||||
func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py')
|
|
||||||
for key, value in dict(locals()).items():
|
|
||||||
if key != ['imp', 'func']:
|
|
||||||
setattr(func, key, value)
|
|
||||||
try:
|
|
||||||
from tiramisu3 import *
|
|
||||||
except:
|
|
||||||
from tiramisu import *
|
|
||||||
from rougail.tiramisu import ConvertDynOptionDescription
|
|
||||||
option_3 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non'))
|
|
||||||
option_4 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='activer_ejabberd', doc='No change', multi=False, default='non', values=('oui', 'non'))
|
|
||||||
option_2 = OptionDescription(name='extra', doc='extra', properties=frozenset({'normal'}), children=[option_3, option_4])
|
|
||||||
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
|
|
||||||
option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='description', doc='description', multi=False, default='Exportation de la base de ejabberd')
|
|
||||||
option_8 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='day', doc='day', multi=False, default=Calculation(func.calc_multi_condition, Params((ParamValue("non")), kwargs={'condition_1': ParamOption(option_4, notraisepropertyerror=True, todict=False), 'match': ParamValue("none"), 'mismatch': ParamValue("daily")})), values=('none', 'daily', 'weekly', 'monthly'))
|
|
||||||
option_9 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode', doc='mode', multi=False, default='pre', values=('pre', 'post'))
|
|
||||||
option_6 = OptionDescription(name='ejabberd', doc='ejabberd', properties=frozenset({'normal'}), children=[option_7, option_8, option_9])
|
|
||||||
option_5 = OptionDescription(name='extra', doc='extra', children=[option_6])
|
|
||||||
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5])
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<rougail>
|
|
||||||
|
|
||||||
<services/>
|
|
||||||
|
|
||||||
<variables>
|
|
||||||
<family name="general">
|
|
||||||
<variable name="mode_conteneur_actif" type="string" description="No change">
|
|
||||||
<value>b</value>
|
|
||||||
</variable>
|
|
||||||
<variable name="int" type="number" description="No change"/>
|
|
||||||
</family>
|
|
||||||
<separators/>
|
|
||||||
</variables>
|
|
||||||
|
|
||||||
<constraints>
|
|
||||||
<check name="unknown" target="int">
|
|
||||||
<param name="mini">0</param>
|
|
||||||
<param name="maxi">100</param>
|
|
||||||
</check>
|
|
||||||
</constraints>
|
|
||||||
|
|
||||||
<help/>
|
|
||||||
|
|
||||||
</rougail>
|
|
||||||
<!-- vim: ts=4 sw=4 expandtab
|
|
||||||
-->
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<rougail>
|
|
||||||
|
|
||||||
<services/>
|
|
||||||
|
|
||||||
<variables>
|
|
||||||
<family name="general">
|
|
||||||
<variable name="mode_conteneur_actif" type="string" description="No change">
|
|
||||||
<value>b</value>
|
|
||||||
</variable>
|
|
||||||
</family>
|
|
||||||
<separators/>
|
|
||||||
</variables>
|
|
||||||
|
|
||||||
<constraints>
|
|
||||||
<check name="valid_differ" target="mode_conteneur_actif">
|
|
||||||
<param type="variable">int3</param>
|
|
||||||
</check>
|
|
||||||
|
|
||||||
</constraints>
|
|
||||||
|
|
||||||
<help/>
|
|
||||||
|
|
||||||
</rougail>
|
|
||||||
<!-- vim: ts=4 sw=4 expandtab
|
|
||||||
-->
|
|
|
@ -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
|
||||||
|
|
||||||
def calc_val(*args, **kwargs):
|
def calc_val(*args, **kwargs):
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
|
|
Loading…
Reference in New Issue