Compare commits

..

No commits in common. "17e09354fa4b64a678ecf7ac3102db4c78f4555f" and "7191bbbcb3094b02f19b06c1a75b058cf858694b" have entirely different histories.

697 changed files with 1366 additions and 2732 deletions

View File

@ -10,9 +10,8 @@ import imp
from .i18n import _ from .i18n import _
from .utils import normalize_family from .utils import normalize_family
from .error import DictConsistencyError from .error import CreoleDictConsistencyError
from .xmlreflector import HIGH_COMPATIBILITY from .xmlreflector import HIGH_COMPATIBILITY
from .config import variable_namespace
#mode order is important #mode order is important
modes_level = ('basic', 'normal', 'expert') modes_level = ('basic', 'normal', 'expert')
@ -40,7 +39,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') # , '_real_container') 'level', 'submulti') # , '_real_container')
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'],
@ -65,6 +64,8 @@ CONVERSION = {'number': int}
FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie' FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie'
VARIABLE_NAMESPACE = 'rougail'
class ServiceAnnotator: class ServiceAnnotator:
"""Manage service's object """Manage service's object
@ -214,11 +215,9 @@ class ServiceAnnotator:
variable.type = type_ variable.type = type_
if type_ == 'symlink': if type_ == 'symlink':
variable.opt = value variable.opt = value
variable.multi = None
else: else:
variable.doc = key variable.doc = key
val = self.objectspace.value() val = self.objectspace.value()
val.type = type_
val.name = value val.name = value
variable.value = [val] variable.value = [val]
self.paths.add_variable('services', self.paths.add_variable('services',
@ -275,7 +274,7 @@ class ServiceAnnotator:
if not hasattr(file_, 'source'): if not hasattr(file_, 'source'):
file_.source = basename(file_.name) file_.source = basename(file_.name)
elif not hasattr(file_, 'source'): elif not hasattr(file_, 'source'):
raise DictConsistencyError(_('attribute source mandatory for file with variable name ' raise CreoleDictConsistencyError(_('attribute source mandatory for file with variable name '
'for {}').format(file_.name)) 'for {}').format(file_.name))
@ -331,7 +330,7 @@ class SpaceAnnotator(object):
for variable in fam2.variable: for variable in fam2.variable:
if variable.type == 'symlink' and '.' not in variable.name: if variable.type == 'symlink' and '.' not in variable.name:
variable.opt = self.paths.get_variable_path(variable.opt, variable.opt = self.paths.get_variable_path(variable.opt,
variable_namespace, VARIABLE_NAMESPACE,
) )
def convert_helps(self): def convert_helps(self):
@ -360,7 +359,7 @@ class SpaceAnnotator(object):
) -> None: ) -> None:
# manage leader's variable # manage leader's variable
if variable.multi is not True: if variable.multi is not True:
raise DictConsistencyError(_('the variable {} in a group must be multi').format(variable.name)) raise CreoleDictConsistencyError(_('the variable {} in a group must be multi').format(variable.name))
leader_space.variable = [] leader_space.variable = []
leader_space.name = leader_name leader_space.name = leader_name
leader_space.hidden = variable.hidden leader_space.hidden = variable.hidden
@ -401,11 +400,14 @@ class SpaceAnnotator(object):
leader_is_hidden: bool, leader_is_hidden: bool,
) -> None: ) -> None:
if variable.name != follower_names[0]: if variable.name != follower_names[0]:
raise DictConsistencyError(_('cannot found this follower {}').format(follower_names[0])) raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0]))
follower_names.remove(variable.name) follower_names.remove(variable.name)
if leader_is_hidden: if leader_is_hidden:
variable.frozen = True variable.frozen = True
variable.force_default_on_freeze = True variable.force_default_on_freeze = True
# followers are multi
if not variable.multi:
raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name))
leader_space.variable.append(variable) # pylint: disable=E1101 leader_space.variable.append(variable) # pylint: disable=E1101
self.paths.set_leader(namespace, self.paths.set_leader(namespace,
leader_family_name, leader_family_name,
@ -457,7 +459,7 @@ class SpaceAnnotator(object):
) )
has_a_leader = True has_a_leader = True
else: else:
raise DictConsistencyError(_('cannot found followers {}').format(follower_names)) raise CreoleDictConsistencyError(_('cannot found followers {}').format(follower_names))
del self.space.constraints.group del self.space.constraints.group
def remove_empty_families(self): # pylint: disable=C0111,R0201 def remove_empty_families(self): # pylint: disable=C0111,R0201
@ -532,10 +534,8 @@ class SpaceAnnotator(object):
variable.type = 'string' variable.type = 'string'
if variable.type != 'symlink' and not hasattr(variable, 'description'): if variable.type != 'symlink' and not hasattr(variable, 'description'):
variable.description = variable.name variable.description = variable.name
if hasattr(variable, 'value'): if variable.submulti:
for value in variable.value: variable.multi = 'submulti'
if not hasattr(value, 'type'):
value.type = variable.type
def convert_auto_freeze(self): # pylint: disable=C0111 def convert_auto_freeze(self): # pylint: disable=C0111
if hasattr(self.space, 'variables'): if hasattr(self.space, 'variables'):
@ -554,7 +554,7 @@ class SpaceAnnotator(object):
new_condition.param = [new_param] new_condition.param = [new_param]
new_target = self.objectspace.target() new_target = self.objectspace.target()
new_target.type = 'variable' new_target.type = 'variable'
if variables.name == variable_namespace: if variables.name == VARIABLE_NAMESPACE:
path = variable.name path = variable.name
else: else:
path = variable.namespace + '.' + family.name + '.' + variable.name path = variable.namespace + '.' + family.name + '.' + variable.name
@ -576,12 +576,12 @@ class SpaceAnnotator(object):
else: else:
choice.name = str(value) choice.name = str(value)
except: except:
raise DictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"')) raise CreoleDictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"'))
choices.append(choice.name) choices.append(choice.name)
choice.type = type_ choice.type = type_
variable.choice.append(choice) variable.choice.append(choice)
if not variable.choice: if not variable.choice:
raise DictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name)) raise CreoleDictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name))
if hasattr(variable, 'value'): if hasattr(variable, 'value'):
for value in variable.value: for value in variable.value:
value.type = type_ value.type = type_
@ -590,7 +590,7 @@ class SpaceAnnotator(object):
else: else:
cvalue = value.name cvalue = value.name
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 CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
else: else:
new_value = self.objectspace.value() new_value = self.objectspace.value()
new_value.name = values[0] new_value.name = values[0]
@ -601,7 +601,7 @@ class SpaceAnnotator(object):
def _convert_valid_enum(self, variable, path): def _convert_valid_enum(self, variable, path):
if variable.type in FORCE_CHOICE: if variable.type in FORCE_CHOICE:
if path in self.valid_enums: if path in self.valid_enums:
raise DictConsistencyError(_('cannot set valid enum for variable with type {}').format(variable.type)) raise CreoleDictConsistencyError(_('cannot set valid enum for variable with type {}').format(variable.type))
self._set_valid_enum(variable, FORCE_CHOICE[variable.type], 'string') self._set_valid_enum(variable, FORCE_CHOICE[variable.type], 'string')
if path in self.valid_enums: if path in self.valid_enums:
values = self.valid_enums[path]['values'] values = self.valid_enums[path]['values']
@ -610,7 +610,6 @@ class SpaceAnnotator(object):
if path in self.force_value: if path in self.force_value:
new_value = self.objectspace.value() new_value = self.objectspace.value()
new_value.name = self.force_value[path] new_value.name = self.force_value[path]
new_value.type = variable.type
variable.value = [new_value] variable.value = [new_value]
del self.force_value[path] del self.force_value[path]
@ -632,7 +631,7 @@ class SpaceAnnotator(object):
self._convert_valid_enum(variable, path) self._convert_valid_enum(variable, path)
# valid_enums must be empty now (all information are store in objects) # valid_enums must be empty now (all information are store in objects)
if self.valid_enums: if self.valid_enums:
raise DictConsistencyError(_('valid_enum sets for unknown variables {}').format(self.valid_enums.keys())) raise CreoleDictConsistencyError(_('valid_enum sets for unknown variables {}').format(self.valid_enums.keys()))
def change_variable_mode(self): # pylint: disable=C0111 def change_variable_mode(self): # pylint: disable=C0111
if not hasattr(self.space, 'variables'): if not hasattr(self.space, 'variables'):
@ -648,11 +647,11 @@ class SpaceAnnotator(object):
mode = modes_level[-1] mode = modes_level[-1]
for follower in variable.variable: for follower in variable.variable:
if follower.auto_save is True: if follower.auto_save is True:
raise DictConsistencyError(_('leader/followers {} ' raise CreoleDictConsistencyError(_('leader/followers {} '
'could not be ' 'could not be '
'auto_save').format(follower.name)) 'auto_save').format(follower.name))
if follower.auto_freeze is True: if follower.auto_freeze is True:
raise DictConsistencyError(_('leader/followers {} ' raise CreoleDictConsistencyError(_('leader/followers {} '
'could not be ' 'could not be '
'auto_freeze').format(follower.name)) 'auto_freeze').format(follower.name))
if HIGH_COMPATIBILITY and variable.name != follower.name: # and variable.variable[0].mode != modes_level[0]: if HIGH_COMPATIBILITY and variable.name != follower.name: # and variable.variable[0].mode != modes_level[0]:
@ -688,11 +687,11 @@ class SpaceAnnotator(object):
fill = fills[idx] fill = fills[idx]
# test if it's redefined calculation # test if it's redefined calculation
if fill.target in targets and not fill.redefine: if fill.target in targets and not fill.redefine:
raise DictConsistencyError(_(f"A fill already exists for the target: {fill.target}")) raise CreoleDictConsistencyError(_(f"A fill already exists for the target: {fill.target}"))
targets.append(fill.target) targets.append(fill.target)
# #
if not fill.name in eosfunc: if not fill.name in eosfunc:
raise DictConsistencyError(_('cannot find fill function {}').format(fill.name)) raise CreoleDictConsistencyError(_('cannot find fill function {}').format(fill.name))
namespace = fill.namespace namespace = fill.namespace
# let's replace the target by the path # let's replace the target by the path
@ -706,9 +705,9 @@ class SpaceAnnotator(object):
param_to_delete = [] param_to_delete = []
for fill_idx, param in enumerate(fill.param): for fill_idx, param in enumerate(fill.param):
if param.type not in TYPE_PARAM_FILL: if param.type not in TYPE_PARAM_FILL:
raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto')) raise CreoleDictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto'))
if param.type != 'string' and not hasattr(param, 'text'): if param.type != 'string' and not hasattr(param, 'text'):
raise DictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}")) raise CreoleDictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}"))
if param.type == 'variable': if param.type == 'variable':
try: try:
param.text, suffix = self.paths.get_variable_path(param.text, param.text, suffix = self.paths.get_variable_path(param.text,
@ -716,13 +715,14 @@ class SpaceAnnotator(object):
with_suffix=True) with_suffix=True)
if suffix: if suffix:
param.suffix = suffix param.suffix = suffix
except DictConsistencyError as err: except CreoleDictConsistencyError as err:
if param.optional is False: if param.optional is False:
raise err raise err
param_to_delete.append(fill_idx) param_to_delete.append(fill_idx)
continue continue
else: if param.hidden is True:
param.notraisepropertyerror = None param.transitive = False
param.hidden = None
param_to_delete.sort(reverse=True) param_to_delete.sort(reverse=True)
for param_idx in param_to_delete: for param_idx in param_to_delete:
fill.param.pop(param_idx) fill.param.pop(param_idx)
@ -732,39 +732,39 @@ class SpaceAnnotator(object):
del self.space.constraints.fill del self.space.constraints.fill
def filter_separators(self): # pylint: disable=C0111,R0201 def filter_separators(self): # pylint: disable=C0111,R0201
# FIXME devrait etre dans la variable
if not hasattr(self.space, 'variables'): if not hasattr(self.space, 'variables'):
return return
for family in self.space.variables.values(): for family in self.space.variables.values():
if not hasattr(family, 'separators'): if (hasattr(family, 'separators') and hasattr(family.separators, 'separator')):
continue space = family.separators.separator
if hasattr(family.separators, 'separator'): names = []
for idx, separator in enumerate(family.separators.separator): for idx, separator in enumerate(space):
option = self.paths.get_variable_obj(separator.name) namespace = self.paths.get_variable_namespace(separator.name)
if hasattr(option, 'separator'): subpath = self.paths.get_variable_path(separator.name, namespace)
subpath = self.paths.get_variable_path(separator.name, separator.name = subpath
separator.namespace, if separator.name in names:
) raise CreoleDictConsistencyError(_('{} already has a separator').format(separator.name))
raise DictConsistencyError(_('{} already has a separator').format(subpath)) names.append(separator.name)
option.separator = separator.text
del family.separators
def load_params_in_validenum(self, param): def load_params_in_validenum(self, param):
if param.type in ['string', 'python', 'number']: if param.type in ['string', 'python', 'number']:
if not hasattr(param, 'text') and (param.type == 'python' or param.type == 'number'): if not hasattr(param, 'text') and (param.type == 'python' or param.type == 'number'):
raise DictConsistencyError(_("All '{}' variables shall be set in order to calculate {}").format(param.type, 'valid_enum')) raise CreoleDictConsistencyError(_("All '{}' variables shall be set in order to calculate {}").format(param.type, 'valid_enum'))
if param.type in ['string', 'number']: if param.type in ['string', 'number']:
try: try:
values = literal_eval(param.text) values = literal_eval(param.text)
except ValueError: except ValueError:
raise DictConsistencyError(_('Cannot load {}').format(param.text)) raise CreoleDictConsistencyError(_('Cannot load {}').format(param.text))
elif param.type == 'python': elif param.type == 'python':
try: try:
#values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}}) #values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}})
values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}}) values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}})
except NameError: except NameError:
raise DictConsistencyError(_('The function {} is unknown').format(param.text)) raise CreoleDictConsistencyError(_('The function {} is unknown').format(param.text))
if not isinstance(values, list): if not isinstance(values, list):
raise DictConsistencyError(_('Function {} shall return a list').format(param.text)) raise CreoleDictConsistencyError(_('Function {} shall return a list').format(param.text))
new_values = [] new_values = []
for val in values: for val in values:
new_values.append(val) new_values.append(val)
@ -779,19 +779,17 @@ class SpaceAnnotator(object):
functions.extend(['valid_enum', 'valid_in_network', 'valid_differ']) functions.extend(['valid_enum', 'valid_in_network', 'valid_differ'])
for check_idx, check in enumerate(self.space.constraints.check): for check_idx, check in enumerate(self.space.constraints.check):
if not check.name in functions: if not check.name in functions:
raise DictConsistencyError(_('cannot find check function {}').format(check.name)) raise CreoleDictConsistencyError(_('cannot find check function {}').format(check.name))
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):
if param.type not in TYPE_PARAM_CHECK: if param.type not in TYPE_PARAM_CHECK:
raise DictConsistencyError(_('cannot use {} type as a param in check for {}').format(param.type, check.target)) raise CreoleDictConsistencyError(_('cannot use {} type as a param in check for {}').format(param.type, check.target))
if param.type == 'variable' and not self.paths.path_is_defined(param.text): if param.type == 'variable' and not self.paths.path_is_defined(param.text):
if param.optional is True: if param.optional is True:
param_option_indexes.append(idx) param_option_indexes.append(idx)
else: else:
raise DictConsistencyError(_(f'unknown param {param.text} in check')) raise CreoleDictConsistencyError(_(f'unknown param {param.text} in check'))
if param.type != 'variable':
param.notraisepropertyerror = None
param_option_indexes = list(set(param_option_indexes)) param_option_indexes = list(set(param_option_indexes))
param_option_indexes.sort(reverse=True) param_option_indexes.sort(reverse=True)
for idx in param_option_indexes: for idx in param_option_indexes:
@ -825,27 +823,27 @@ class SpaceAnnotator(object):
proposed_value_type = self.objectspace.convert_boolean(param.text) == False proposed_value_type = self.objectspace.convert_boolean(param.text) == False
remove_params.append(param_idx) remove_params.append(param_idx)
except TypeError as err: except TypeError as err:
raise DictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err)) raise CreoleDictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err))
if proposed_value_type: if proposed_value_type:
# no more supported # no more supported
raise DictConsistencyError(_('cannot load checkval value for variable {}, no more supported').format(check.target)) raise CreoleDictConsistencyError(_('cannot load checkval value for variable {}, no more supported').format(check.target))
remove_params.sort(reverse=True) remove_params.sort(reverse=True)
for param_idx in remove_params: for param_idx in remove_params:
del check.param[param_idx] del check.param[param_idx]
if len(check.param) != 1: if len(check.param) != 1:
raise DictConsistencyError(_('cannot set more than one param ' raise CreoleDictConsistencyError(_('cannot set more than one param '
'for valid_enum for variable {}' 'for valid_enum for variable {}'
'').format(check.target)) '').format(check.target))
param = check.param[0] param = check.param[0]
if check.target in self.valid_enums: if check.target in self.valid_enums:
raise DictConsistencyError(_('valid_enum already set for {}' raise CreoleDictConsistencyError(_('valid_enum already set for {}'
'').format(check.target)) '').format(check.target))
if proposed_value_type: if proposed_value_type:
if param.type == 'variable': if param.type == 'variable':
try: try:
values = self.load_params_in_validenum(param) values = self.load_params_in_validenum(param)
except NameError as err: except NameError as err:
raise DictConsistencyError(_('cannot load value for variable {}: {}').format(check.target, err)) raise CreoleDictConsistencyError(_('cannot load value for variable {}: {}').format(check.target, err))
add_default_value = not check.is_in_leadership add_default_value = not check.is_in_leadership
if add_default_value and values: if add_default_value and values:
self.force_value[check.target] = values[0] self.force_value[check.target] = values[0]
@ -859,13 +857,18 @@ class SpaceAnnotator(object):
del self.space.constraints.check[idx] del self.space.constraints.check[idx]
def check_change_warning(self): def check_change_warning(self):
#convert level to "warnings_only" #convert level to "warnings_only" and hidden to "transitive"
for check in self.space.constraints.check: for check in self.space.constraints.check:
if check.level == 'warning': if check.level == 'warning':
check.warnings_only = True check.warnings_only = True
else: else:
check.warnings_only = False check.warnings_only = False
check.level = None check.level = None
if hasattr(check, 'param'):
for param in check.param:
if not param.hidden is True:
check.transitive = False
param.hidden = None
def filter_check(self): # pylint: disable=C0111 def filter_check(self): # pylint: disable=C0111
# valid param in check # valid param in check
@ -891,20 +894,20 @@ class SpaceAnnotator(object):
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:
raise DictConsistencyError(_('{} must have {} param').format(name, params_len)) raise CreoleDictConsistencyError(_('{} must have {} param').format(name, params_len))
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:
raise DictConsistencyError(_('{} must have {} param').format(name, params_len)) raise CreoleDictConsistencyError(_('{} must have {} param').format(name, params_len))
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:
raise DictConsistencyError(_('{} must have {} param').format(name, params_len)) raise CreoleDictConsistencyError(_('{} must have {} param').format(name, params_len))
elif name == 'valid_in_network': elif name == 'valid_in_network':
params_len = 2 params_len = 2
if len(check.param) != params_len: if len(check.param) != params_len:
raise DictConsistencyError(_('{} must have {} param').format(name, params_len)) raise CreoleDictConsistencyError(_('{} 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'):
@ -920,13 +923,13 @@ class SpaceAnnotator(object):
for idx, target in enumerate(condition.target): for idx, target in enumerate(condition.target):
if target.type == 'variable': if target.type == 'variable':
if condition.source == target.name: if condition.source == target.name:
raise DictConsistencyError(_('target name and source name must be different: {}').format(condition.source)) raise CreoleDictConsistencyError(_('target name and source name must be different: {}').format(condition.source))
target.name = self.paths.get_variable_path(target.name, namespace) target.name = self.paths.get_variable_path(target.name, namespace)
elif target.type == 'family': elif target.type == 'family':
try: try:
target.name = self.paths.get_family_path(target.name, namespace) target.name = self.paths.get_family_path(target.name, namespace)
except KeyError: except KeyError:
raise DictConsistencyError(_('cannot found family {}').format(target.name)) raise CreoleDictConsistencyError(_('cannot found family {}').format(target.name))
def convert_xxxlist_to_variable(self): # pylint: disable=C0111 def convert_xxxlist_to_variable(self): # pylint: disable=C0111
# transform *list to variable or family # transform *list to variable or family
@ -960,21 +963,21 @@ class SpaceAnnotator(object):
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
if condition.name not in ['disabled_if_in', 'disabled_if_not_in', 'hidden_if_in', 'auto_hidden_if_not_in', if condition.name not in ['disabled_if_in', 'disabled_if_not_in', 'hidden_if_in', 'auto_hidden_if_not_in',
'hidden_if_not_in', 'mandatory_if_in', 'mandatory_if_not_in']: 'hidden_if_not_in', 'mandatory_if_in', 'mandatory_if_not_in']:
raise DictConsistencyError(_(f'unknown condition {condition.name}')) raise CreoleDictConsistencyError(_(f'unknown condition {condition.name}'))
def check_params(self): def check_params(self):
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
for param in condition.param: for param in condition.param:
if param.type not in TYPE_PARAM_CONDITION: if param.type not in TYPE_PARAM_CONDITION:
raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a condition')) raise CreoleDictConsistencyError(_(f'cannot use {param.type} type as a param in a condition'))
def check_target(self): def check_target(self):
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
if not hasattr(condition, 'target'): if not hasattr(condition, 'target'):
raise DictConsistencyError(_('target is mandatory in condition')) raise CreoleDictConsistencyError(_('target is mandatory in condition'))
for target in condition.target: for target in condition.target:
if target.type.endswith('list') and condition.name not in ['disabled_if_in', 'disabled_if_not_in']: if target.type.endswith('list') and condition.name not in ['disabled_if_in', 'disabled_if_not_in']:
raise DictConsistencyError(_(f'target in condition for {target.type} not allow in {condition.name}')) raise CreoleDictConsistencyError(_(f'target in condition for {target.type} not allow in {condition.name}'))
def check_condition_fallback_optional(self): def check_condition_fallback_optional(self):
# a condition with a fallback **and** the source variable doesn't exist # a condition with a fallback **and** the source variable doesn't exist
@ -984,7 +987,7 @@ class SpaceAnnotator(object):
if condition.fallback is True and not self.paths.path_is_defined(condition.source): if condition.fallback is True and not self.paths.path_is_defined(condition.source):
for target in condition.target: for target in condition.target:
if target.type in ['variable', 'family']: if target.type in ['variable', 'family']:
if target.name.startswith(variable_namespace + '.'): if target.name.startswith(VARIABLE_NAMESPACE + '.'):
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
else: else:
name = target.name name = target.name
@ -1045,7 +1048,7 @@ class SpaceAnnotator(object):
if condition.param == []: if condition.param == []:
remove_targets = [] remove_targets = []
for target in condition.target: for target in condition.target:
if target.name.startswith(f'{variable_namespace}.'): if target.name.startswith(f'{VARIABLE_NAMESPACE}.'):
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
else: else:
name = target.name name = target.name
@ -1073,7 +1076,7 @@ class SpaceAnnotator(object):
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
#parse each variable and family #parse each variable and family
for target_idx, target in enumerate(condition.target): for target_idx, target in enumerate(condition.target):
if target.name.startswith(f'{variable_namespace}.'): if target.name.startswith(f'{VARIABLE_NAMESPACE}.'):
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
else: else:
name = target.name name = target.name
@ -1129,7 +1132,7 @@ class SpaceAnnotator(object):
else: else:
param = None param = None
for target in condition.target: for target in condition.target:
if target.name.startswith(f'{variable_namespace}.'): if target.name.startswith(f'{VARIABLE_NAMESPACE}.'):
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
else: else:
name = target.name name = target.name

View File

@ -15,5 +15,3 @@ dtdfilename = join(dtddir, 'rougail.dtd')
# chemin du répertoire source des fichiers templates # chemin du répertoire source des fichiers templates
patch_dir = '/srv/rougail/patch' patch_dir = '/srv/rougail/patch'
variable_namespace = 'rougail'

View File

@ -101,6 +101,7 @@
<!ATTLIST variable hidden (True|False) "False"> <!ATTLIST variable hidden (True|False) "False">
<!ATTLIST variable disabled (True|False) "False"> <!ATTLIST variable disabled (True|False) "False">
<!ATTLIST variable multi (True|False) "False"> <!ATTLIST variable multi (True|False) "False">
<!ATTLIST variable submulti (True|False) "False">
<!ATTLIST variable redefine (True|False) "False"> <!ATTLIST variable redefine (True|False) "False">
<!ATTLIST variable exists (True|False) "True"> <!ATTLIST variable exists (True|False) "True">
<!ATTLIST variable mandatory (True|False) "False"> <!ATTLIST variable mandatory (True|False) "False">
@ -140,7 +141,7 @@
<!ELEMENT param (#PCDATA)> <!ELEMENT param (#PCDATA)>
<!ATTLIST param type (string|variable|number|python) "string"> <!ATTLIST param type (string|variable|number|python) "string">
<!ATTLIST param name CDATA #IMPLIED> <!ATTLIST param name CDATA #IMPLIED>
<!ATTLIST param notraisepropertyerror (True|False) "False"> <!ATTLIST param hidden (True|False) "True">
<!ATTLIST param optional (True|False) "False"> <!ATTLIST param optional (True|False) "False">
<!ELEMENT target (#PCDATA)> <!ELEMENT target (#PCDATA)>

View File

@ -1,4 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""
Erreurs Creole
"""
class ConfigError(Exception): class ConfigError(Exception):
pass pass
@ -14,7 +19,7 @@ class TemplateDisabled(TemplateError):
pass pass
class OperationError(Exception): class CreoleOperationError(Exception):
"""Type error or value Error for Creole variable's type or values """Type error or value Error for Creole variable's type or values
""" """
@ -25,11 +30,11 @@ class SpaceObjShallNotBeUpdated(Exception):
""" """
class DictConsistencyError(Exception): class CreoleDictConsistencyError(Exception):
"""It's not only that the Creole XML is valid against the Creole DTD """It's not only that the Creole XML is valid against the Creole DTD
it's that it is not consistent. it's that it is not consistent.
""" """
class LoaderError(Exception): class CreoleLoaderError(Exception):
pass pass

View File

@ -1,19 +1,41 @@
"""loader """loader
flattened XML specific flattened XML specific
""" """
from os.path import isfile from os.path import join, isfile
from lxml.etree import DTD from lxml.etree import DTD
import imp
from .config import dtdfilename, variable_namespace from tiramisu import (StrOption, OptionDescription, DynOptionDescription, PortOption,
IntOption, ChoiceOption, BoolOption, SymLinkOption, IPOption,
NetworkOption, NetmaskOption, DomainnameOption, BroadcastOption,
URLOption, EmailOption, FilenameOption, UsernameOption, DateOption,
PasswordOption, BoolOption, MACOption, Leadership, submulti,
Params, ParamSelfOption, ParamOption, ParamDynOption, ParamValue, Calculation, calc_value)
from .config import dtdfilename
from .i18n import _ from .i18n import _
from .error import LoaderError from .utils import normalize_family
from .annotator import VARIABLE_NAMESPACE
from .error import CreoleLoaderError
FUNC_TO_DICT = ['valid_not_equal'] FUNC_TO_DICT = ['valid_not_equal']
FORCE_INFORMATIONS = ['help', 'test', 'separator'] KNOWN_TAGS = ['family', 'variable', 'separators', 'leader', 'property']
def convert_boolean(value): class ConvertDynOptionDescription(DynOptionDescription):
def convert_suffix_to_path(self, suffix):
if not isinstance(suffix, str):
suffix = str(suffix)
return normalize_family(suffix,
check_name=False)
def convert_tiramisu_value(value, obj):
"""
convertit les variables dans le bon type si nécessaire
"""
def _convert_boolean(value):
prop = {'True': True, prop = {'True': True,
'False': False, 'False': False,
'None': None} 'None': None}
@ -21,14 +43,10 @@ def convert_boolean(value):
raise Exception('unknown value {} while trying to cast {} to boolean'.format(value, obj)) raise Exception('unknown value {} while trying to cast {} to boolean'.format(value, obj))
return prop[value] return prop[value]
def convert_tiramisu_value(value, type_):
"""
convertit les variables dans le bon type si nécessaire
"""
if value is None: if value is None:
return value return value
func = CONVERT_OPTION[type_].get('func', None) func = {IntOption: int,
BoolOption: _convert_boolean}.get(obj, None)
if func is None: if func is None:
return value return value
if isinstance(value, list): if isinstance(value, list):
@ -37,71 +55,85 @@ def convert_tiramisu_value(value, type_):
return func(value) return func(value)
CONVERT_OPTION = {'number': dict(opttype="IntOption", func=int), CONVERT_OPTION = {'number': dict(opttype=IntOption),
'choice': dict(opttype="ChoiceOption"), 'choice': dict(opttype=ChoiceOption),
'string': dict(opttype="StrOption"), 'string': dict(opttype=StrOption),
'password': dict(opttype="PasswordOption"), 'password': dict(opttype=PasswordOption),
'mail': dict(opttype="EmailOption"), 'mail': dict(opttype=EmailOption),
'boolean': dict(opttype="BoolOption", initkwargs={'default': [True]}, func=convert_boolean), 'boolean': dict(opttype=BoolOption, initkwargs={'default': True}),
'symlink': dict(opttype="SymLinkOption"), 'symlink': dict(opttype=SymLinkOption),
'filename': dict(opttype="FilenameOption"), 'filename': dict(opttype=FilenameOption),
'date': dict(opttype="DateOption"), 'date': dict(opttype=DateOption),
'unix_user': dict(opttype="UsernameOption"), 'unix_user': dict(opttype=UsernameOption),
'ip': dict(opttype="IPOption", initkwargs={'allow_reserved': True}), 'ip': dict(opttype=IPOption, initkwargs={'allow_reserved': True}),
'local_ip': dict(opttype="IPOption", initkwargs={'private_only': True, 'warnings_only': True}), 'local_ip': dict(opttype=IPOption, initkwargs={'private_only': True, 'warnings_only': True}),
'netmask': dict(opttype="NetmaskOption"), 'netmask': dict(opttype=NetmaskOption),
'network': dict(opttype="NetworkOption"), 'network': dict(opttype=NetworkOption),
'broadcast': dict(opttype="BroadcastOption"), 'broadcast': dict(opttype=BroadcastOption),
'netbios': dict(opttype="DomainnameOption", initkwargs={'type': 'netbios', 'warnings_only': True}), 'netbios': dict(opttype=DomainnameOption, initkwargs={'type': 'netbios', 'warnings_only': True}),
'domain': dict(opttype="DomainnameOption", initkwargs={'type': 'domainname', 'allow_ip': True, 'allow_without_dot': True}), 'domain': dict(opttype=DomainnameOption, initkwargs={'type': 'domainname', 'allow_ip': True, 'allow_without_dot': True}),
'domain_strict': dict(opttype="DomainnameOption", initkwargs={'type': 'domainname', 'allow_ip': False}), 'domain_strict': dict(opttype=DomainnameOption, initkwargs={'type': 'domainname', 'allow_ip': False}),
'hostname': dict(opttype="DomainnameOption", initkwargs={'type': 'hostname', 'allow_ip': True}), 'hostname': dict(opttype=DomainnameOption, initkwargs={'type': 'hostname', 'allow_ip': True}),
'hostname_strict': dict(opttype="DomainnameOption", initkwargs={'type': 'hostname', 'allow_ip': False}), 'hostname_strict': dict(opttype=DomainnameOption, initkwargs={'type': 'hostname', 'allow_ip': False}),
'web_address': dict(opttype="URLOption", initkwargs={'allow_ip': True, 'allow_without_dot': True}), 'web_address': dict(opttype=URLOption, initkwargs={'allow_ip': True, 'allow_without_dot': True}),
'port': dict(opttype="PortOption", initkwargs={'allow_private': True}), 'port': dict(opttype=PortOption, initkwargs={'allow_private': True}),
'mac': dict(opttype="MACOption"), 'mac': dict(opttype=MACOption),
'cidr': dict(opttype="IPOption", initkwargs={'cidr': True}), 'cidr': dict(opttype=IPOption, initkwargs={'cidr': True}),
'network_cidr': dict(opttype="NetworkOption", initkwargs={'cidr': True}), 'network_cidr': dict(opttype=NetworkOption, initkwargs={'cidr': True}),
} }
class PopulateTiramisuObjects: class Elt:
def __init__(self, def __init__(self, attrib):
xmlroot, self.attrib = attrib
funcs_path,
):
self.storage = ElementStorage(self.parse_dtd())
self.storage.text = ["from tiramisu import *",
"from rougail.tiramisu import ConvertDynOptionDescription",
"import imp",
f"func = imp.load_source('func', '{funcs_path}')",
]
self.make_tiramisu_objects(xmlroot)
# parse object
self.storage.get('.').get()
def parse_dtd(self):
"""Loads the DTD class PopulateTiramisuObjects:
def __init__(self):
self.storage = ElementStorage()
self.booleans = []
def parse_dtd(self, dtdfilename):
"""Loads the Creole DTD
:raises IOError: if the DTD is not found :raises IOError: if the DTD is not found
:param dtdfilename: the full filename of the DTD :param dtdfilename: the full filename of the Creole DTD
""" """
if not isfile(dtdfilename): if not isfile(dtdfilename):
raise IOError(_("no such DTD file: {}").format(dtdfilename)) raise IOError(_("no such DTD file: {}").format(dtdfilename))
booleans = []
with open(dtdfilename, 'r') as dtdfd: with open(dtdfilename, 'r') as dtdfd:
dtd = DTD(dtdfd) dtd = DTD(dtdfd)
for elt in dtd.iterelements(): for elt in dtd.iterelements():
if elt.name == 'variable': if elt.name == 'variable':
for attr in elt.iterattributes(): for attr in elt.iterattributes():
if set(attr.itervalues()) == set(['True', 'False']): if set(attr.itervalues()) == set(['True', 'False']):
booleans.append(attr.name) self.booleans.append(attr.name)
return booleans
def get_root_family(self):
family = Family(Elt({'name': 'baseoption',
'doc': 'baseoption'}),
self.booleans,
self.storage,
self.eosfunc,
)
self.storage.add('.', family)
return family
def reorder_family(self, xmlroot):
xmlelts = []
for xmlelt in xmlroot:
# VARIABLE_NAMESPACE family has to be loaded before any other family
# because `extra` family could use `VARIABLE_NAMESPACE` variables.
if xmlelt.attrib['name'] == VARIABLE_NAMESPACE:
xmlelts.insert(0, xmlelt)
else:
xmlelts.append(xmlelt)
return xmlelts
def make_tiramisu_objects(self, xmlroot, eosfunc):
self.eosfunc = imp.load_source('eosfunc', eosfunc)
def make_tiramisu_objects(self,
xmlroot,
):
family = self.get_root_family() family = self.get_root_family()
for xmlelt in self.reorder_family(xmlroot): for xmlelt in self.reorder_family(xmlroot):
self.iter_family(xmlelt, self.iter_family(xmlelt,
@ -109,44 +141,26 @@ class PopulateTiramisuObjects:
None, None,
) )
def get_root_family(self):
family = Family(BaseElt({'name': 'baseoption',
'doc': 'baseoption'}),
self.storage,
False,
'.',
)
return family
def reorder_family(self, xmlroot):
xmlelts = []
for xmlelt in xmlroot:
# variable_namespace family has to be loaded before any other family
# because `extra` family could use `variable_namespace` variables.
if xmlelt.attrib['name'] == variable_namespace:
xmlelts.insert(0, xmlelt)
else:
xmlelts.append(xmlelt)
return xmlelts
def iter_family(self, def iter_family(self,
child, child,
family, family,
subpath, subpath,
): ):
if child.tag not in KNOWN_TAGS:
raise CreoleLoaderError(_('unknown tag {}').format(child.tag))
if child.tag in ['family', 'leader']: if child.tag in ['family', 'leader']:
function = self.populate_family self.populate_family(family,
elif child.tag == 'variable':
function = self.populate_variable
elif child.tag == 'property':
# property already imported with family
return
else:
raise Exception('unknown tag {}'.format(child.tag))
function(family,
child, child,
subpath, subpath,
) )
elif child.tag == 'separators':
self.parse_separators(child)
elif child.tag == 'variable':
self.populate_variable(child, subpath, family)
elif child.tag == 'property':
self.parse_properties(family, child)
else:
raise Exception('unknown tag {}'.format(child.tag))
def populate_family(self, def populate_family(self,
parent_family, parent_family,
@ -157,10 +171,13 @@ class PopulateTiramisuObjects:
elt, elt,
) )
family = Family(elt, family = Family(elt,
self.booleans,
self.storage, self.storage,
elt.tag == 'leader', self.eosfunc,
path,
) )
self.storage.add(path, family)
if elt.tag == 'leader':
family.set_leader()
parent_family.add(family) parent_family.add(family)
if len(elt) != 0: if len(elt) != 0:
for child in elt: for child in elt:
@ -169,26 +186,43 @@ class PopulateTiramisuObjects:
path, path,
) )
def populate_variable(self, def parse_separators(self,
family, separators,
elt,
subpath,
): ):
for separator in separators:
elt = self.storage.get(separator.attrib['name'])
elt.add_information('separator', separator.text)
def populate_variable(self, elt, subpath, family):
is_follower = False is_follower = False
is_leader = False is_leader = False
if family.is_leader: if family.is_leader:
if elt.attrib['name'] != family.elt.attrib['name']: if elt.attrib['name'] != family.attrib['name']:
is_follower = True is_follower = True
else: else:
is_leader = True is_leader = True
family.add(Variable(elt, path = self.build_path(subpath,
elt,
)
variable = Variable(elt,
self.booleans,
self.storage, self.storage,
is_follower, is_follower,
is_leader, is_leader,
self.build_path(subpath, self.eosfunc,
elt,
) )
)) self.storage.add(path, variable)
family.add(variable)
def parse_properties(self, family, child):
if child.get('type') == 'calculation':
kwargs = {'condition': child.attrib['source'],
'expected': ParamValue(child.attrib.get('expected'))}
if child.attrib['inverse'] == 'True':
kwargs['reverse_condition'] = ParamValue(True)
family.attrib['properties'].append((ParamValue(child.text), kwargs))
else:
family.attrib['properties'].append(child.text)
def build_path(self, def build_path(self,
subpath, subpath,
@ -198,299 +232,321 @@ class PopulateTiramisuObjects:
return elt.attrib['name'] return elt.attrib['name']
return subpath + '.' + elt.attrib['name'] return subpath + '.' + elt.attrib['name']
def get_text(self):
return '\n'.join(self.storage.get('.').get_text())
class BaseElt:
def __init__(self, attrib):
self.attrib = attrib
def __iter__(self):
return iter([])
class ElementStorage: class ElementStorage:
def __init__(self, def __init__(self):
booleans,
):
self.paths = {} self.paths = {}
self.text = []
self.index = 0
self.booleans = booleans
def add(self, path, elt): def add(self, path, elt):
self.paths[path] = (elt, self.index) if path in self.paths:
self.index += 1 raise CreoleLoaderError(_('path already loaded {}').format(path))
self.paths[path] = elt
def get(self, path): def get(self, path):
if path not in self.paths or self.paths[path][0] is None:
raise LoaderError(_('there is no element for path {}').format(path))
return self.paths[path][0]
def get_name(self, path):
if path not in self.paths: if path not in self.paths:
raise LoaderError(_('there is no element for index {}').format(path)) raise CreoleLoaderError(_('there is no element for path {}').format(path))
return f'option_{self.paths[path][1]}' return self.paths[path]
class Common: class Common:
def __init__(self, def build_properties(self):
elt, for index, prop in enumerate(self.attrib['properties']):
storage, if isinstance(prop, tuple):
is_leader, action, kwargs = prop
path, kwargs['condition'] = ParamOption(self.storage.get(kwargs['condition']).get(), todict=True)
): prop = Calculation(calc_value,
self.option_name = None Params(action,
self.path = path kwargs=kwargs))
self.attrib = {} self.attrib['properties'][index] = prop
self.informations = {}
self.storage = storage
self.is_leader = is_leader
self.storage.add(self.path, self)
def populate_properties(self, child):
if child.get('type') == 'calculation':
action = f"ParamValue('{child.text}')"
option_name = self.storage.get(child.attrib['source']).get()
kwargs = f"'condition': ParamOption({option_name}, todict=True), 'expected': ParamValue('{child.attrib.get('expected')}')"
if child.attrib['inverse'] == 'True':
kwargs += ", 'reverse_condition': ParamValue(True)"
prop = 'Calculation(calc_value, Params(' + action + ', kwargs={' + kwargs + '}))'
else:
prop = "'" + child.text + "'"
if self.attrib['properties']: if self.attrib['properties']:
self.attrib['properties'] += ', ' self.attrib['properties'] = tuple(self.attrib['properties'])
self.attrib['properties'] += prop else:
if not self.attrib['properties']:
del self.attrib['properties'] del self.attrib['properties']
def get_attrib(self, attrib):
ret_list = []
for key, value in self.attrib.items():
if key == 'properties':
value = 'frozenset([' + self.attrib[key] + '])'
elif key in ['default', 'multi', 'suffixes', 'validators']:
value = self.attrib[key]
elif isinstance(value, str) and key != 'opt' and not value.startswith('['):
value = "'" + value.replace("'", "\\\'") + "'"
ret_list.append(f'{key}={value}')
return ', '.join(ret_list)
def populate_informations(self):
for key, value in self.informations.items():
value = value.replace('"', '\"')
self.storage.text.append(f'{self.option_name}.impl_set_information("{key}", "{value}")')
def get_text(self,
):
return self.storage.text
class Variable(Common): class Variable(Common):
def __init__(self, def __init__(self, elt, booleans, storage, is_follower, is_leader, eosfunc):
elt, self.option = None
storage, self.informations = {}
is_follower, self.attrib = {}
is_leader,
path,
):
super().__init__(elt,
storage,
is_leader,
path,
)
self.is_follower = is_follower
convert_option = CONVERT_OPTION[elt.attrib['type']] convert_option = CONVERT_OPTION[elt.attrib['type']]
del elt.attrib['type'] if 'initkwargs' in convert_option:
self.object_type = convert_option['opttype'] self.attrib.update(convert_option['initkwargs'])
self.attrib.update(convert_option.get('initkwargs', {})) if elt.attrib['type'] != 'symlink':
if self.object_type != 'SymLinkOption': self.attrib['properties'] = []
self.attrib['properties'] = ''
self.attrib['validators'] = [] self.attrib['validators'] = []
self.elt = elt self.eosfunc = eosfunc
self.storage = storage
self.booleans = booleans
self.populate_attrib(elt)
self.is_follower = is_follower
self.is_leader = is_leader
self.object_type = convert_option['opttype']
self.populate_choice(elt)
for child in elt:
self.populate_property(child)
self.populate_value(child)
self.populate_check(child)
if elt.attrib['type'] == 'symlink':
self.attrib['opt'] = storage.get(self.attrib['opt'])
def get(self): def populate_attrib(self,
if self.option_name is None: elt,
self.populate_attrib() ):
if self.object_type == 'SymLinkOption': for key, value in elt.attrib.items():
self.attrib['opt'] = self.storage.get(self.attrib['opt']).get() if key == 'multi' and elt.attrib['type'] == 'symlink':
else: continue
self.parse_multi() if key == 'multi' and value == 'submulti':
self.parse_children() value = submulti
attrib = self.get_attrib(self.attrib) elif key in self.booleans:
self.option_name = self.storage.get_name(self.path) if value == 'True':
self.storage.text.append(f'{self.option_name} = {self.object_type}({attrib})') value = True
self.populate_informations() elif value == 'False':
return self.option_name value = False
def populate_attrib(self):
for key, value in self.elt.attrib.items():
if key in self.storage.booleans:
value = convert_boolean(value)
if key in FORCE_INFORMATIONS:
self.informations[key] = value
else: else:
raise CreoleLoaderError(_('unknown value {} for {}').format(value, key))
if key in ['help', 'test']:
self.add_information(key, value)
elif key != 'type':
self.attrib[key] = value self.attrib[key] = value
def parse_children(self): def populate_choice(self,
if not 'default' in self.attrib or self.attrib['multi']: elt,
self.attrib['default'] = [] ):
if self.attrib['multi'] == 'submulti' and self.is_follower: if elt.attrib['type'] == 'choice':
self.attrib['default_multi'] = [] values = []
choices = [] for child in elt:
for child in self.elt: if child.tag == 'choice':
value = child.text
if child.attrib['type'] == 'number':
value = int(value)
values.append(value)
self.attrib['values'] = tuple(values)
def populate_property(self, child):
if child.tag == 'property': if child.tag == 'property':
self.populate_properties(child) if child.get('type') == 'calculation':
elif child.tag == 'value': kwargs = {'condition': child.attrib['source'],
if child.attrib['type'] == 'calculation': 'expected': ParamValue(child.attrib.get('expected'))}
self.attrib['default'] = self.calculation_value(child, []) if child.attrib['inverse'] == 'True':
kwargs['reverse_condition'] = ParamValue(True)
self.attrib['properties'].append((ParamValue(child.text), kwargs))
else: else:
self.populate_value(child) self.attrib['properties'].append(child.text)
elif child.tag == 'check':
self.attrib['validators'].append(self.calculation_value(child, ['ParamSelfOption()']))
elif child.tag == 'choice':
choices.append(convert_tiramisu_value(child.text, child.attrib['type']))
if choices:
self.attrib['values'] = tuple(choices)
if self.attrib['default'] == []:
del self.attrib['default']
elif not self.attrib['multi'] and isinstance(self.attrib['default'], list):
self.attrib['default'] = self.attrib['default'][-1]
if self.attrib['validators'] == []:
del self.attrib['validators']
else:
self.attrib['validators'] = '[' + ', '.join(self.attrib['validators']) + ']'
def parse_multi(self): def populate_value(self, child):
if self.is_follower: if child.tag == 'value':
if self.attrib['multi'] is True: if child.attrib.get('type') == 'calculation':
self.attrib['multi'] = 'submulti' if child.text is not None and child.text.strip():
self.attrib['default'] = (child.text.strip(),)
else: else:
self.attrib['multi'] = True params = []
def calculation_value(self, child, args):
kwargs = []
if 'name' in child.attrib:
# has parameters
function = child.attrib['name']
for param in child: for param in child:
value = self.populate_param(param) params.append(self.parse_param(param))
if 'name' not in param.attrib: self.attrib['default'] = (child.attrib['name'], params, False)
args.append(str(value))
else: else:
kwargs.append(f"'{param.attrib['name']}': " + value) if "type" in child.attrib:
type_ = CONVERT_OPTION[child.attrib['type']]['opttype']
else: else:
# function without any parameter type_ = self.object_type
function = child.text.strip() if self.attrib['multi'] is True and not self.is_follower:
ret = f"Calculation(func.{function}, Params((" + ', '.join(args) + "), kwargs=" + "{" + ', '.join(kwargs) + "})" if 'default' not in self.attrib:
if 'warnings_only' in child.attrib: self.attrib['default'] = []
ret += f', warnings_only={child.attrib["warnings_only"]}' value = convert_tiramisu_value(child.text, type_)
return ret + ')'
def populate_param(self,
param,
):
if param.attrib['type'] == 'string':
return f'ParamValue("{param.text}")'
elif param.attrib['type'] == 'number':
return f'ParamValue({param.text})'
elif param.attrib['type'] == 'variable':
value = {'option': param.text,
'notraisepropertyerror': convert_boolean(param.attrib['notraisepropertyerror']),
'todict': param.text in FUNC_TO_DICT,
}
if 'suffix' in param.attrib:
value['suffix'] = param.attrib['suffix']
return self.build_param(value)
raise LoaderError(_('unknown param type {}').format(param.attrib['type']))
def populate_value(self,
child,
):
value = convert_tiramisu_value(child.text, child.attrib['type'])
if self.attrib['multi'] == 'submulti':
self.attrib['default_multi'].append(value)
elif self.is_follower:
self.attrib['default_multi'] = value
elif self.attrib['multi']:
self.attrib['default'].append(value) self.attrib['default'].append(value)
if 'default_multi' not in self.attrib and not self.is_leader:
self.attrib['default_multi'] = value
elif self.attrib['multi'] == submulti:
if 'default' not in self.attrib:
self.attrib['default'] = []
value = convert_tiramisu_value(child.text, type_)
if not self.is_follower:
if not isinstance(value, list):
dvalue = [value]
else:
dvalue = value
self.attrib['default'].append(dvalue)
if value and 'default_multi' not in self.attrib and not self.is_leader:
self.attrib['default_multi'] = []
if not self.is_leader: if not self.is_leader:
self.attrib['default_multi'] = value self.attrib['default_multi'].append(value)
elif isinstance(value, int):
self.attrib['default'].append(value)
else: else:
self.attrib['default'].append("'" + value + "'") value = convert_tiramisu_value(child.text, type_)
if self.is_follower:
self.attrib['default_multi'] = value
else:
self.attrib['default'] = value
def build_param(self, def populate_check(self, child):
param, if child.tag == 'check':
): params = []
option_name = self.storage.get(param['option']).get() for param in child:
if 'suffix' in param: params.append(self.parse_param(param))
family = '.'.join(param['option'].split('.')[:-1]) #check.params = params
family_option = self.storage.get_name(family) self.attrib['validators'].append((child.attrib['name'], params, child.attrib['warnings_only']))
return f"ParamDynOption({option_name}, '{param['suffix']}', {family_option}, notraisepropertyerror={param['notraisepropertyerror']}, todict={param['todict']})"
return f"ParamOption({option_name}, notraisepropertyerror={param['notraisepropertyerror']}, todict={param['todict']})" def parse_param(self, param):
name = param.attrib.get('name', '')
if param.attrib['type'] == 'string':
value = param.text
elif param.attrib['type'] == 'variable':
transitive = param.attrib.get('transitive', 'False')
if transitive == 'True':
transitive = True
elif transitive == 'False':
transitive = False
else:
raise CreoleLoaderError(_('unknown transitive boolean {}').format(transitive))
value = [param.text, transitive, param.attrib.get('suffix')]
elif param.attrib['type'] == 'number':
value = int(param.text)
else:
raise CreoleLoaderError(_('unknown param type {}').format(param.attrib['type']))
return(name, value)
def add_information(self, key, value):
if key in self.informations:
raise CreoleLoaderError(_('key already exists in information {}').format(key))
self.informations[key] = value
def build_calculator(self, key):
if key in self.attrib:
values = self.attrib[key]
if isinstance(values, list):
is_list = True
else:
is_list = False
values = [values]
ret = []
for value in values:
if isinstance(value, tuple):
if key == 'validators':
args = [ParamSelfOption()]
else:
args = []
kwargs = {}
if len(value) == 3:
for param in value[1]:
if isinstance(param[1], list):
option = self.storage.get(param[1][0]).get()
param_kwargs = {'notraisepropertyerror': param[1][1]}
if value[0] in FUNC_TO_DICT:
param_kwargs['todict'] = True
if not param[1][2]:
param_value = ParamOption(option,
**param_kwargs,
)
else:
family = '.'.join(param[1][0].split('.', 3)[:2])
param_value = ParamDynOption(option,
param[1][2],
self.storage.get(family).get(),
**param_kwargs,
)
else:
param_value = ParamValue(param[1])
if not param[0]:
args.append(param_value)
else:
kwargs[param[0]] = param_value
ret.append(Calculation(getattr(self.eosfunc, value[0]),
Params(tuple(args),
kwargs=kwargs)))
else:
ret.append(value)
if not is_list:
self.attrib[key] = ret[0]
else:
self.attrib[key] = ret
def get(self):
if self.option is None:
if self.object_type is SymLinkOption:
self.attrib['opt'] = self.attrib['opt'].get()
else:
self.build_properties()
self.build_calculator('default')
self.build_calculator('validators')
if not self.attrib['validators']:
del self.attrib['validators']
try:
option = self.object_type(**self.attrib)
except Exception as err:
import traceback
traceback.print_exc()
name = self.attrib['name']
raise CreoleLoaderError(_('cannot create option "{}": {}').format(name, err))
for key, value in self.informations.items():
option.impl_set_information(key, value)
self.option = option
return self.option
class Family(Common): class Family(Common):
def __init__(self, def __init__(self,
elt, elt,
booleans,
storage, storage,
is_leader, eosfunc,
path,
): ):
super().__init__(elt, self.option = None
storage, self.attrib = {}
is_leader, self.is_leader = False
path, self.informations = {}
)
self.children = [] self.children = []
self.elt = elt self.storage = storage
self.eosfunc = eosfunc
self.attrib['properties'] = []
for key, value in elt.attrib.items():
if key == 'help':
self.add_information(key, value)
else:
self.attrib[key] = value
def add(self, child): def add(self, child):
self.children.append(child) self.children.append(child)
def get(self): def add_information(self, key, value):
if not self.option_name: if key in self.informations and not (key == 'icon' and self.informations[key] is None):
self.populate_attrib() raise CreoleLoaderError(_('key already exists in information {}').format(key))
self.parse_children()
self.option_name = self.storage.get_name(self.path)
object_name = self.get_object_name()
attrib = self.get_attrib(self.attrib) + ', children=[' + ', '.join([child.get() for child in self.children]) + ']'
self.storage.text.append(f'{self.option_name} = {object_name}({attrib})')
self.populate_informations()
return self.option_name
def populate_attrib(self):
for key, value in self.elt.attrib.items():
if key == 'help':
self.informations[key] = value self.informations[key] = value
elif key == 'dynamic':
dynamic = self.storage.get(value).get()
self.attrib['suffixes'] = f"Calculation(func.calc_value, Params((ParamOption({dynamic}))))"
else:
self.attrib[key] = value
def parse_children(self): def set_leader(self):
self.attrib['properties'] = '' self.is_leader = True
for child in self.elt:
if child.tag == 'property':
self.populate_properties(child)
if not self.attrib['properties']:
del self.attrib['properties']
def get_object_name(self): def get(self):
if 'suffixes' in self.attrib: if self.option is None:
return 'ConvertDynOptionDescription' self.attrib['children'] = []
for child in self.children:
self.attrib['children'].append(child.get())
self.build_properties()
try:
if 'dynamic' in self.attrib:
dynamic = self.storage.get(self.attrib['dynamic']).get()
del self.attrib['dynamic']
self.attrib['suffixes'] = Calculation(self.eosfunc.calc_value,
Params((ParamOption(dynamic),)))
option = ConvertDynOptionDescription(**self.attrib)
elif not self.is_leader: elif not self.is_leader:
return 'OptionDescription' option = OptionDescription(**self.attrib)
return 'Leadership' else:
option = Leadership(**self.attrib)
except Exception as err:
print(self.attrib)
raise CreoleLoaderError(_('cannot create optiondescription "{}": {}').format(self.attrib['name'], err))
for key, value in self.informations.items():
option.impl_set_information(key, value)
self.option = option
return self.option
def load(xmlroot: str, def load(xmlroot: str,
dtd_path: str,
funcs_path: str): funcs_path: str):
tiramisu_objects = PopulateTiramisuObjects(xmlroot, tiramisu_objects = PopulateTiramisuObjects()
funcs_path, tiramisu_objects.parse_dtd(dtd_path)
) tiramisu_objects.make_tiramisu_objects(xmlroot,
return tiramisu_objects.get_text() funcs_path)
return tiramisu_objects.storage.paths['.'].get()

View File

@ -28,18 +28,17 @@ from lxml.etree import Element, SubElement # pylint: disable=E0611
from .i18n import _ from .i18n import _
from .xmlreflector import XMLReflector, HIGH_COMPATIBILITY from .xmlreflector import XMLReflector, HIGH_COMPATIBILITY
from .annotator import ERASED_ATTRIBUTES, ServiceAnnotator, SpaceAnnotator from .annotator import ERASED_ATTRIBUTES, VARIABLE_NAMESPACE, ServiceAnnotator, SpaceAnnotator
from .utils import normalize_family from .utils import normalize_family
from .error import OperationError, SpaceObjShallNotBeUpdated, DictConsistencyError from .error import CreoleOperationError, SpaceObjShallNotBeUpdated, CreoleDictConsistencyError
from .path import Path from .path import Path
from .config import variable_namespace
# CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type # CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type
FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables') FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables')
# CreoleObjSpace's elements that shall be forced to the UnRedefinable type # CreoleObjSpace's elements that shall be forced to the UnRedefinable type
FORCE_UNREDEFINABLES = ('value',) FORCE_UNREDEFINABLES = ('value',)
# CreoleObjSpace's elements that shall be set to the UnRedefinable type # CreoleObjSpace's elements that shall be set to the UnRedefinable type
UNREDEFINABLE = ('multi', 'type') UNREDEFINABLE = ('submulti', 'multi', 'type')
PROPERTIES = ('hidden', 'frozen', 'auto_freeze', 'auto_save', 'force_default_on_freeze', PROPERTIES = ('hidden', 'frozen', 'auto_freeze', 'auto_save', 'force_default_on_freeze',
'force_store_value', 'disabled', 'mandatory') 'force_store_value', 'disabled', 'mandatory')
@ -47,14 +46,17 @@ CONVERT_PROPERTIES = {'auto_save': ['force_store_value'], 'auto_freeze': ['force
RENAME_ATTIBUTES = {'description': 'doc'} RENAME_ATTIBUTES = {'description': 'doc'}
INCOMPATIBLE_ATTRIBUTES = [['multi', 'submulti']]
FORCED_TEXT_ELTS_AS_NAME = ('choice', 'property', 'value', 'target') FORCED_TEXT_ELTS_AS_NAME = ('choice', 'property', 'value', 'target')
CONVERT_EXPORT = {'Leadership': 'leader', CONVERT_EXPORT = {'Leadership': 'leader',
'Separators': 'separators',
'Variable': 'variable', 'Variable': 'variable',
'Value': 'value', 'Value': 'value',
'Property': 'property', 'Property': 'property',
'Choice': 'choice', 'Choice': 'choice',
'Param': 'param', 'Param': 'param',
'Separator': 'separator',
'Check': 'check', 'Check': 'check',
} }
@ -179,7 +181,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(_('Family {} is set several times').format(child.attrib['name'])) raise CreoleDictConsistencyError(_('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
@ -297,12 +299,12 @@ class CreoleObjSpace:
) )
elif exists is False: elif exists is False:
raise SpaceObjShallNotBeUpdated() raise SpaceObjShallNotBeUpdated()
raise DictConsistencyError(_(f'Already present in another XML file, {name} cannot be re-created')) raise CreoleDictConsistencyError(_(f'Already present in another XML file, {name} cannot be re-created'))
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)() return getattr(self, child.tag)()
raise DictConsistencyError(_(f'Redefined object: {name} does not exist yet')) raise CreoleDictConsistencyError(_(f'Redefined object: {name} does not exist yet'))
def create_tree_structure(self, def create_tree_structure(self,
space, space,
@ -326,12 +328,12 @@ class CreoleObjSpace:
elif isinstance(variableobj, self.UnRedefinable): elif isinstance(variableobj, self.UnRedefinable):
setattr(space, child.tag, []) setattr(space, child.tag, [])
elif not isinstance(variableobj, self.Atom): # pragma: no cover elif not isinstance(variableobj, self.Atom): # pragma: no cover
raise OperationError(_("Creole object {} " raise CreoleOperationError(_("Creole object {} "
"has a wrong type").format(type(variableobj))) "has a wrong type").format(type(variableobj)))
def is_already_exists(self, name, space, child, namespace): def is_already_exists(self, name, space, child, namespace):
if isinstance(space, self.family): # pylint: disable=E1101 if isinstance(space, self.family): # pylint: disable=E1101
if namespace != variable_namespace: if namespace != VARIABLE_NAMESPACE:
name = space.path + '.' + name name = space.path + '.' + name
return self.paths.path_is_defined(name) return self.paths.path_is_defined(name)
if child.tag == 'family': if child.tag == 'family':
@ -364,14 +366,14 @@ class CreoleObjSpace:
else: else:
norm_name = name norm_name = name
return getattr(family, variable.tag)[norm_name] return getattr(family, variable.tag)[norm_name]
if namespace == variable_namespace: if namespace == VARIABLE_NAMESPACE:
path = name path = name
else: else:
path = family.path + '.' + name path = family.path + '.' + name
old_family_name = self.paths.get_variable_family_name(path) old_family_name = self.paths.get_variable_family_name(path)
if normalize_family(family.name) == old_family_name: if normalize_family(family.name) == old_family_name:
return getattr(family, variable.tag)[name] return getattr(family, variable.tag)[name]
old_family = self.space.variables[variable_namespace].family[old_family_name] # pylint: disable=E1101 old_family = self.space.variables[VARIABLE_NAMESPACE].family[old_family_name] # pylint: disable=E1101
variable_obj = old_family.variable[name] variable_obj = old_family.variable[name]
del old_family.variable[name] del old_family.variable[name]
if 'variable' not in vars(family): if 'variable' not in vars(family):
@ -453,12 +455,19 @@ 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']
raise DictConsistencyError(_(f'cannot redefine attribute {attr} for variable {name}')) raise CreoleDictConsistencyError(_(f'cannot redefine attribute {attr} for variable {name}'))
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):
setattr(variableobj, attr, val) setattr(variableobj, attr, val)
keys = list(vars(variableobj).keys()) keys = list(vars(variableobj).keys())
for incompatible in INCOMPATIBLE_ATTRIBUTES:
found = False
for inc in incompatible:
if inc in keys:
if found:
raise CreoleDictConsistencyError(_('those attributes are incompatible {}').format(incompatible))
found = True
def variableobj_tree_visitor(self, def variableobj_tree_visitor(self,
child, child,
@ -505,7 +514,7 @@ class CreoleObjSpace:
document.attrib.get('dynamic') != None, document.attrib.get('dynamic') != None,
variableobj) variableobj)
if child.attrib.get('redefine', 'False') == 'True': if child.attrib.get('redefine', 'False') == 'True':
if namespace == variable_namespace: if namespace == VARIABLE_NAMESPACE:
self.redefine_variables.append(child.attrib['name']) self.redefine_variables.append(child.attrib['name'])
else: else:
self.redefine_variables.append(namespace + '.' + family_name + '.' + self.redefine_variables.append(namespace + '.' + family_name + '.' +
@ -513,7 +522,7 @@ class CreoleObjSpace:
elif child.tag == 'family': elif child.tag == 'family':
family_name = normalize_family(child.attrib['name']) family_name = normalize_family(child.attrib['name'])
if namespace != variable_namespace: if namespace != VARIABLE_NAMESPACE:
family_name = namespace + '.' + family_name family_name = namespace + '.' + family_name
self.paths.add_family(namespace, self.paths.add_family(namespace,
family_name, family_name,
@ -591,7 +600,7 @@ class CreoleObjSpace:
def _xml_export(self, def _xml_export(self,
node, node,
space, space,
node_name=variable_namespace, node_name=VARIABLE_NAMESPACE,
): ):
for name in self.get_attributes(space): for name in self.get_attributes(space):
subspace = getattr(space, name) subspace = getattr(space, name)

View File

@ -1,7 +1,7 @@
from .i18n import _ from .i18n import _
from .utils import normalize_family from .utils import normalize_family
from .error import OperationError, DictConsistencyError from .error import CreoleOperationError, CreoleDictConsistencyError
from .config import variable_namespace from .annotator import VARIABLE_NAMESPACE
class Path: class Path:
@ -30,13 +30,13 @@ class Path:
current_namespace: str, current_namespace: str,
) -> str: # pylint: disable=C0111 ) -> str: # pylint: disable=C0111
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 CreoleOperationError('current_namespace must not be None')
dico = self.families[normalize_family(name, dico = self.families[normalize_family(name,
check_name=False, check_name=False,
allow_dot=True, allow_dot=True,
)] )]
if dico['namespace'] != variable_namespace and current_namespace != dico['namespace']: if dico['namespace'] != VARIABLE_NAMESPACE and current_namespace != dico['namespace']:
raise DictConsistencyError(_('A family located in the {} namespace ' raise CreoleDictConsistencyError(_('A family located in the {} namespace '
'shall not be used in the {} namespace').format( 'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace)) dico['namespace'], current_namespace))
path = dico['name'] path = dico['name']
@ -48,7 +48,7 @@ class Path:
name: str, name: str,
) -> 'Family': # pylint: disable=C0111 ) -> 'Family': # pylint: disable=C0111
if name not in self.families: if name not in self.families:
raise DictConsistencyError(_('unknown family {}').format(name)) raise CreoleDictConsistencyError(_('unknown family {}').format(name))
dico = self.families[name] dico = self.families[name]
return dico['variableobj'] return dico['variableobj']
@ -59,7 +59,7 @@ class Path:
name: str, name: str,
leader_name: str, leader_name: str,
) -> None: # pylint: disable=C0111 ) -> None: # pylint: disable=C0111
if namespace != variable_namespace: if namespace != VARIABLE_NAMESPACE:
# need rebuild path and move object in new path # need rebuild path and move object in new path
old_path = namespace + '.' + leader_family_name + '.' + name old_path = namespace + '.' + leader_family_name + '.' + name
dico = self._get_variable(old_path) dico = self._get_variable(old_path)
@ -74,7 +74,7 @@ class Path:
name = new_path name = new_path
dico = self._get_variable(name) dico = self._get_variable(name)
if dico['leader'] != None: if dico['leader'] != None:
raise DictConsistencyError(_('Already defined leader {} for variable' raise CreoleDictConsistencyError(_('Already defined leader {} for variable'
' {}'.format(dico['leader'], name))) ' {}'.format(dico['leader'], name)))
dico['leader'] = leader_name dico['leader'] = leader_name
@ -89,7 +89,7 @@ class Path:
is_dynamic: bool, is_dynamic: bool,
variableobj, variableobj,
) -> str: # pylint: disable=C0111 ) -> str: # pylint: disable=C0111
if namespace == variable_namespace or '.' in name: if namespace == VARIABLE_NAMESPACE or '.' in name:
varname = name varname = name
else: else:
varname = '.'.join([namespace, family, name]) varname = '.'.join([namespace, family, name])
@ -127,7 +127,7 @@ class Path:
with_suffix: bool=False, with_suffix: bool=False,
) -> str: # pylint: disable=C0111 ) -> str: # pylint: disable=C0111
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 CreoleOperationError('current_namespace must not be None')
if with_suffix: if with_suffix:
dico, suffix = self._get_variable(name, dico, suffix = self._get_variable(name,
with_suffix=True, with_suffix=True,
@ -135,8 +135,8 @@ class Path:
else: else:
dico = self._get_variable(name) dico = self._get_variable(name)
if not allow_source: if not allow_source:
if dico['namespace'] not in [variable_namespace, 'services'] and current_namespace != dico['namespace']: if dico['namespace'] not in [VARIABLE_NAMESPACE, 'services'] and current_namespace != dico['namespace']:
raise DictConsistencyError(_('A variable located in the {} namespace ' raise CreoleDictConsistencyError(_('A variable located in the {} namespace '
'shall not be used in the {} namespace').format( 'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace)) dico['namespace'], current_namespace))
if '.' in dico['name']: if '.' in dico['name']:
@ -161,13 +161,13 @@ class Path:
with_suffix: bool=False, with_suffix: bool=False,
) -> str: ) -> str:
if name not in self.variables: if name not in self.variables:
if name.startswith(f'{variable_namespace}.'): if name.startswith(f'{VARIABLE_NAMESPACE}.'):
name = name.split('.')[-1] name = name.split('.')[-1]
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):
return variable, name[len(var_name):] return variable, name[len(var_name):]
raise DictConsistencyError(_('unknown option {}').format(name)) raise CreoleDictConsistencyError(_('unknown option {}').format(name))
if with_suffix: if with_suffix:
return self.variables[name], None return self.variables[name], None
return self.variables[name] return self.variables[name]

View File

@ -18,7 +18,8 @@ from Cheetah.NameMapper import NotFound as CheetahNotFound
from tiramisu import Config from tiramisu import Config
from tiramisu.error import PropertiesOptionError from tiramisu.error import PropertiesOptionError
from .config import patch_dir, variable_namespace from .annotator import VARIABLE_NAMESPACE
from .config import patch_dir
from .error import FileNotFound, TemplateError from .error import FileNotFound, TemplateError
from .i18n import _ from .i18n import _
from .utils import normalize_family from .utils import normalize_family
@ -372,7 +373,7 @@ class CreoleTemplateEngine:
""" """
for option in await self.config.option.list(type='all'): for option in await self.config.option.list(type='all'):
namespace = await option.option.name() namespace = await option.option.name()
if namespace == variable_namespace: if namespace == VARIABLE_NAMESPACE:
await self.load_eole_variables_rougail(option) await self.load_eole_variables_rougail(option)
else: else:
families = await self.load_eole_variables(namespace, families = await self.load_eole_variables(namespace,

View File

@ -1,10 +0,0 @@
from tiramisu import DynOptionDescription
from .utils import normalize_family
class ConvertDynOptionDescription(DynOptionDescription):
def convert_suffix_to_path(self, suffix):
if not isinstance(suffix, str):
suffix = str(suffix)
return normalize_family(suffix,
check_name=False)

View File

@ -6,7 +6,7 @@ from os import listdir
from lxml.etree import DTD, parse, tostring # , XMLParser from lxml.etree import DTD, parse, tostring # , XMLParser
from .i18n import _ from .i18n import _
from .error import DictConsistencyError from .error import CreoleDictConsistencyError
HIGH_COMPATIBILITY = True HIGH_COMPATIBILITY = True
@ -38,7 +38,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(_("not a valid xml file: {}").format(xmlfile)) raise CreoleDictConsistencyError(_("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):

View File

@ -1,7 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_2 = OptionDescription(doc='tata', name='tata', children=[])
option_1 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -21,5 +21,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='module_instancie', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'auto_freeze', 'mandatory', 'basic', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))]), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['basic']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -21,5 +21,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='module_instancie', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'auto_freeze', 'mandatory', 'expert', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))]), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -12,5 +12,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,8 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'mandatory', 'basic']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['basic']), children=[option_3])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -12,5 +12,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,8 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'mandatory', 'expert']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['expert']), children=[option_3])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -14,5 +14,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,8 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -16,8 +16,9 @@
<variable doc="without_type" multi="False" name="without_type" type="string"> <variable doc="without_type" multi="False" name="without_type" type="string">
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value type="string">non</value> <value>non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_4 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='without_type', multi=False, name='without_type', default='non')
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -14,5 +14,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,8 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -24,5 +24,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -23,5 +23,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})), values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -21,5 +21,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((), kwargs={})), values=('oui', 'non'))
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -14,5 +14,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,8 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='Redefine description', multi=True, name='mode_conteneur_actif', default=['non'], default_multi='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -4,11 +4,8 @@
<services/> <services/>
<variables> <variables>
<family name="général"> <family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change" hidden="True"> <variable name="mode_conteneur_actif" type="oui/non" description="Redefine description" hidden="True" submulti="True">
<value>non</value>
</variable>
<variable name="activer_ejabberd" type="oui/non" description="No change" hidden="True">
<value>non</value> <value>non</value>
</variable> </variable>
</family> </family>

View File

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": [["non"]]}

View File

@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<family doc="rougail" name="rougail">
<family doc="general" name="general">
<property>normal</property>
<variable doc="Redefine description" multi="submulti" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>force_default_on_freeze</property>
<property>frozen</property>
<property>hidden</property>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
</family>
<separators/>
</family>
</rougail>

View File

@ -12,7 +12,7 @@
<property>basic</property> <property>basic</property>
<property expected="oui" inverse="True" source="rougail.general.module_instancie" type="calculation">auto_frozen</property> <property expected="oui" inverse="True" source="rougail.general.module_instancie" type="calculation">auto_frozen</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -30,5 +30,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,10 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_5 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='module_instancie', default='non', values=('oui', 'non'))
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'auto_freeze', 'mandatory', 'basic', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_5, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))]), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})), values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['basic']), children=[option_3, option_4, option_5])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -10,7 +10,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>basic</property> <property>basic</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -21,5 +21,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'mandatory', 'basic']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})), values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['basic']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -23,5 +23,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})), values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -23,5 +23,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})), values=('oui', 'non'))
option_2 = OptionDescription(doc='Général', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -7,7 +7,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>expert</property> <property>expert</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -18,5 +18,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_3 = DomainnameOption(type='domainname', allow_ip=True, allow_without_dot=True, properties=frozenset(['mandatory', 'expert']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -10,7 +10,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param type="number">3</param> <param transitive="False" type="number">3</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -21,5 +21,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = IntOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamValue(3)), kwargs={})))
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -23,5 +23,6 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non'))
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default=Calculation(func.calc_val, Params((ParamOption(option_4, notraisepropertyerror=False, todict=False)), kwargs={})), values=('oui', 'non'))
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -3,7 +3,7 @@
<family doc="rougail" name="rougail"> <family doc="rougail" name="rougail">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" separator="Établissement" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice> <choice type="string">oui</choice>
<choice type="string">non</choice> <choice type="string">non</choice>
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
@ -14,5 +14,8 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators>
<separator name="rougail.general.mode_conteneur_actif">Établissement</separator>
</separators>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_3.impl_set_information("separator", "Établissement")
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -3,7 +3,7 @@
<family doc="rougail" name="rougail"> <family doc="rougail" name="rougail">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" separator="Établissement" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice> <choice type="string">oui</choice>
<choice type="string">non</choice> <choice type="string">non</choice>
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
@ -14,5 +14,8 @@
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators>
<separator name="rougail.general.mode_conteneur_actif">Établissement</separator>
</separators>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_3.impl_set_information("separator", "Établissement")
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -20,9 +20,10 @@
<property>mandatory</property> <property>mandatory</property>
<property>basic</property> <property>basic</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param type="string">oui</param> <param transitive="False" type="string">oui</param>
</value> </value>
</variable> </variable>
</family> </family>
<separators/>
</family> </family>
</rougail> </rougail>

View File

@ -1,9 +0,0 @@
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non'))
option_4 = StrOption(properties=frozenset(['force_store_value', 'frozen', 'hidden', 'mandatory', 'basic']), doc='autosave variable', multi=False, name='autosavevar', default=Calculation(func.calc_val, Params((ParamValue("oui")), kwargs={})))
option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['basic']), children=[option_3, option_4])
option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

Some files were not shown because too many files have changed in this diff Show More