refactoring
This commit is contained in:
parent
05ca7ed578
commit
17e09354fa
@ -10,8 +10,9 @@ import imp
|
||||
|
||||
from .i18n import _
|
||||
from .utils import normalize_family
|
||||
from .error import CreoleDictConsistencyError
|
||||
from .error import DictConsistencyError
|
||||
from .xmlreflector import HIGH_COMPATIBILITY
|
||||
from .config import variable_namespace
|
||||
|
||||
#mode order is important
|
||||
modes_level = ('basic', 'normal', 'expert')
|
||||
@ -64,8 +65,6 @@ CONVERSION = {'number': int}
|
||||
|
||||
FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie'
|
||||
|
||||
VARIABLE_NAMESPACE = 'rougail'
|
||||
|
||||
|
||||
class ServiceAnnotator:
|
||||
"""Manage service's object
|
||||
@ -215,9 +214,11 @@ class ServiceAnnotator:
|
||||
variable.type = type_
|
||||
if type_ == 'symlink':
|
||||
variable.opt = value
|
||||
variable.multi = None
|
||||
else:
|
||||
variable.doc = key
|
||||
val = self.objectspace.value()
|
||||
val.type = type_
|
||||
val.name = value
|
||||
variable.value = [val]
|
||||
self.paths.add_variable('services',
|
||||
@ -274,7 +275,7 @@ class ServiceAnnotator:
|
||||
if not hasattr(file_, 'source'):
|
||||
file_.source = basename(file_.name)
|
||||
elif not hasattr(file_, 'source'):
|
||||
raise CreoleDictConsistencyError(_('attribute source mandatory for file with variable name '
|
||||
raise DictConsistencyError(_('attribute source mandatory for file with variable name '
|
||||
'for {}').format(file_.name))
|
||||
|
||||
|
||||
@ -330,7 +331,7 @@ class SpaceAnnotator(object):
|
||||
for variable in fam2.variable:
|
||||
if variable.type == 'symlink' and '.' not in variable.name:
|
||||
variable.opt = self.paths.get_variable_path(variable.opt,
|
||||
VARIABLE_NAMESPACE,
|
||||
variable_namespace,
|
||||
)
|
||||
|
||||
def convert_helps(self):
|
||||
@ -359,7 +360,7 @@ class SpaceAnnotator(object):
|
||||
) -> None:
|
||||
# manage leader's variable
|
||||
if variable.multi is not True:
|
||||
raise CreoleDictConsistencyError(_('the variable {} in a group must be multi').format(variable.name))
|
||||
raise DictConsistencyError(_('the variable {} in a group must be multi').format(variable.name))
|
||||
leader_space.variable = []
|
||||
leader_space.name = leader_name
|
||||
leader_space.hidden = variable.hidden
|
||||
@ -400,7 +401,7 @@ class SpaceAnnotator(object):
|
||||
leader_is_hidden: bool,
|
||||
) -> None:
|
||||
if variable.name != follower_names[0]:
|
||||
raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0]))
|
||||
raise DictConsistencyError(_('cannot found this follower {}').format(follower_names[0]))
|
||||
follower_names.remove(variable.name)
|
||||
if leader_is_hidden:
|
||||
variable.frozen = True
|
||||
@ -456,7 +457,7 @@ class SpaceAnnotator(object):
|
||||
)
|
||||
has_a_leader = True
|
||||
else:
|
||||
raise CreoleDictConsistencyError(_('cannot found followers {}').format(follower_names))
|
||||
raise DictConsistencyError(_('cannot found followers {}').format(follower_names))
|
||||
del self.space.constraints.group
|
||||
|
||||
def remove_empty_families(self): # pylint: disable=C0111,R0201
|
||||
@ -531,6 +532,10 @@ class SpaceAnnotator(object):
|
||||
variable.type = 'string'
|
||||
if variable.type != 'symlink' and not hasattr(variable, 'description'):
|
||||
variable.description = variable.name
|
||||
if hasattr(variable, 'value'):
|
||||
for value in variable.value:
|
||||
if not hasattr(value, 'type'):
|
||||
value.type = variable.type
|
||||
|
||||
def convert_auto_freeze(self): # pylint: disable=C0111
|
||||
if hasattr(self.space, 'variables'):
|
||||
@ -549,7 +554,7 @@ class SpaceAnnotator(object):
|
||||
new_condition.param = [new_param]
|
||||
new_target = self.objectspace.target()
|
||||
new_target.type = 'variable'
|
||||
if variables.name == VARIABLE_NAMESPACE:
|
||||
if variables.name == variable_namespace:
|
||||
path = variable.name
|
||||
else:
|
||||
path = variable.namespace + '.' + family.name + '.' + variable.name
|
||||
@ -571,12 +576,12 @@ class SpaceAnnotator(object):
|
||||
else:
|
||||
choice.name = str(value)
|
||||
except:
|
||||
raise CreoleDictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"'))
|
||||
raise DictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"'))
|
||||
choices.append(choice.name)
|
||||
choice.type = type_
|
||||
variable.choice.append(choice)
|
||||
if not variable.choice:
|
||||
raise CreoleDictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name))
|
||||
raise DictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name))
|
||||
if hasattr(variable, 'value'):
|
||||
for value in variable.value:
|
||||
value.type = type_
|
||||
@ -585,7 +590,7 @@ class SpaceAnnotator(object):
|
||||
else:
|
||||
cvalue = value.name
|
||||
if cvalue not in choices:
|
||||
raise CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
|
||||
raise DictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
|
||||
else:
|
||||
new_value = self.objectspace.value()
|
||||
new_value.name = values[0]
|
||||
@ -596,7 +601,7 @@ class SpaceAnnotator(object):
|
||||
def _convert_valid_enum(self, variable, path):
|
||||
if variable.type in FORCE_CHOICE:
|
||||
if path in self.valid_enums:
|
||||
raise CreoleDictConsistencyError(_('cannot set valid enum for variable with type {}').format(variable.type))
|
||||
raise DictConsistencyError(_('cannot set valid enum for variable with type {}').format(variable.type))
|
||||
self._set_valid_enum(variable, FORCE_CHOICE[variable.type], 'string')
|
||||
if path in self.valid_enums:
|
||||
values = self.valid_enums[path]['values']
|
||||
@ -605,6 +610,7 @@ class SpaceAnnotator(object):
|
||||
if path in self.force_value:
|
||||
new_value = self.objectspace.value()
|
||||
new_value.name = self.force_value[path]
|
||||
new_value.type = variable.type
|
||||
variable.value = [new_value]
|
||||
del self.force_value[path]
|
||||
|
||||
@ -626,7 +632,7 @@ class SpaceAnnotator(object):
|
||||
self._convert_valid_enum(variable, path)
|
||||
# valid_enums must be empty now (all information are store in objects)
|
||||
if self.valid_enums:
|
||||
raise CreoleDictConsistencyError(_('valid_enum sets for unknown variables {}').format(self.valid_enums.keys()))
|
||||
raise DictConsistencyError(_('valid_enum sets for unknown variables {}').format(self.valid_enums.keys()))
|
||||
|
||||
def change_variable_mode(self): # pylint: disable=C0111
|
||||
if not hasattr(self.space, 'variables'):
|
||||
@ -642,11 +648,11 @@ class SpaceAnnotator(object):
|
||||
mode = modes_level[-1]
|
||||
for follower in variable.variable:
|
||||
if follower.auto_save is True:
|
||||
raise CreoleDictConsistencyError(_('leader/followers {} '
|
||||
raise DictConsistencyError(_('leader/followers {} '
|
||||
'could not be '
|
||||
'auto_save').format(follower.name))
|
||||
if follower.auto_freeze is True:
|
||||
raise CreoleDictConsistencyError(_('leader/followers {} '
|
||||
raise DictConsistencyError(_('leader/followers {} '
|
||||
'could not be '
|
||||
'auto_freeze').format(follower.name))
|
||||
if HIGH_COMPATIBILITY and variable.name != follower.name: # and variable.variable[0].mode != modes_level[0]:
|
||||
@ -682,11 +688,11 @@ class SpaceAnnotator(object):
|
||||
fill = fills[idx]
|
||||
# test if it's redefined calculation
|
||||
if fill.target in targets and not fill.redefine:
|
||||
raise CreoleDictConsistencyError(_(f"A fill already exists for the target: {fill.target}"))
|
||||
raise DictConsistencyError(_(f"A fill already exists for the target: {fill.target}"))
|
||||
targets.append(fill.target)
|
||||
#
|
||||
if not fill.name in eosfunc:
|
||||
raise CreoleDictConsistencyError(_('cannot find fill function {}').format(fill.name))
|
||||
raise DictConsistencyError(_('cannot find fill function {}').format(fill.name))
|
||||
|
||||
namespace = fill.namespace
|
||||
# let's replace the target by the path
|
||||
@ -700,9 +706,9 @@ class SpaceAnnotator(object):
|
||||
param_to_delete = []
|
||||
for fill_idx, param in enumerate(fill.param):
|
||||
if param.type not in TYPE_PARAM_FILL:
|
||||
raise CreoleDictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto'))
|
||||
raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto'))
|
||||
if param.type != 'string' and not hasattr(param, 'text'):
|
||||
raise CreoleDictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}"))
|
||||
raise DictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}"))
|
||||
if param.type == 'variable':
|
||||
try:
|
||||
param.text, suffix = self.paths.get_variable_path(param.text,
|
||||
@ -710,14 +716,13 @@ class SpaceAnnotator(object):
|
||||
with_suffix=True)
|
||||
if suffix:
|
||||
param.suffix = suffix
|
||||
except CreoleDictConsistencyError as err:
|
||||
except DictConsistencyError as err:
|
||||
if param.optional is False:
|
||||
raise err
|
||||
param_to_delete.append(fill_idx)
|
||||
continue
|
||||
if param.hidden is True:
|
||||
param.transitive = False
|
||||
param.hidden = None
|
||||
else:
|
||||
param.notraisepropertyerror = None
|
||||
param_to_delete.sort(reverse=True)
|
||||
for param_idx in param_to_delete:
|
||||
fill.param.pop(param_idx)
|
||||
@ -739,27 +744,27 @@ class SpaceAnnotator(object):
|
||||
subpath = self.paths.get_variable_path(separator.name,
|
||||
separator.namespace,
|
||||
)
|
||||
raise CreoleDictConsistencyError(_('{} already has a separator').format(subpath))
|
||||
raise DictConsistencyError(_('{} already has a separator').format(subpath))
|
||||
option.separator = separator.text
|
||||
del family.separators
|
||||
|
||||
def load_params_in_validenum(self, param):
|
||||
if param.type in ['string', 'python', 'number']:
|
||||
if not hasattr(param, 'text') and (param.type == 'python' or param.type == 'number'):
|
||||
raise CreoleDictConsistencyError(_("All '{}' variables shall be set in order to calculate {}").format(param.type, 'valid_enum'))
|
||||
raise DictConsistencyError(_("All '{}' variables shall be set in order to calculate {}").format(param.type, 'valid_enum'))
|
||||
if param.type in ['string', 'number']:
|
||||
try:
|
||||
values = literal_eval(param.text)
|
||||
except ValueError:
|
||||
raise CreoleDictConsistencyError(_('Cannot load {}').format(param.text))
|
||||
raise DictConsistencyError(_('Cannot load {}').format(param.text))
|
||||
elif param.type == 'python':
|
||||
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}})
|
||||
except NameError:
|
||||
raise CreoleDictConsistencyError(_('The function {} is unknown').format(param.text))
|
||||
raise DictConsistencyError(_('The function {} is unknown').format(param.text))
|
||||
if not isinstance(values, list):
|
||||
raise CreoleDictConsistencyError(_('Function {} shall return a list').format(param.text))
|
||||
raise DictConsistencyError(_('Function {} shall return a list').format(param.text))
|
||||
new_values = []
|
||||
for val in values:
|
||||
new_values.append(val)
|
||||
@ -774,17 +779,19 @@ class SpaceAnnotator(object):
|
||||
functions.extend(['valid_enum', 'valid_in_network', 'valid_differ'])
|
||||
for check_idx, check in enumerate(self.space.constraints.check):
|
||||
if not check.name in functions:
|
||||
raise CreoleDictConsistencyError(_('cannot find check function {}').format(check.name))
|
||||
raise DictConsistencyError(_('cannot find check function {}').format(check.name))
|
||||
if hasattr(check, 'param'):
|
||||
param_option_indexes = []
|
||||
for idx, param in enumerate(check.param):
|
||||
if param.type not in TYPE_PARAM_CHECK:
|
||||
raise CreoleDictConsistencyError(_('cannot use {} type as a param in check for {}').format(param.type, check.target))
|
||||
raise DictConsistencyError(_('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.optional is True:
|
||||
param_option_indexes.append(idx)
|
||||
else:
|
||||
raise CreoleDictConsistencyError(_(f'unknown param {param.text} in check'))
|
||||
raise DictConsistencyError(_(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.sort(reverse=True)
|
||||
for idx in param_option_indexes:
|
||||
@ -818,27 +825,27 @@ class SpaceAnnotator(object):
|
||||
proposed_value_type = self.objectspace.convert_boolean(param.text) == False
|
||||
remove_params.append(param_idx)
|
||||
except TypeError as err:
|
||||
raise CreoleDictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err))
|
||||
raise DictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err))
|
||||
if proposed_value_type:
|
||||
# no more supported
|
||||
raise CreoleDictConsistencyError(_('cannot load checkval value for variable {}, no more supported').format(check.target))
|
||||
raise DictConsistencyError(_('cannot load checkval value for variable {}, no more supported').format(check.target))
|
||||
remove_params.sort(reverse=True)
|
||||
for param_idx in remove_params:
|
||||
del check.param[param_idx]
|
||||
if len(check.param) != 1:
|
||||
raise CreoleDictConsistencyError(_('cannot set more than one param '
|
||||
raise DictConsistencyError(_('cannot set more than one param '
|
||||
'for valid_enum for variable {}'
|
||||
'').format(check.target))
|
||||
param = check.param[0]
|
||||
if check.target in self.valid_enums:
|
||||
raise CreoleDictConsistencyError(_('valid_enum already set for {}'
|
||||
raise DictConsistencyError(_('valid_enum already set for {}'
|
||||
'').format(check.target))
|
||||
if proposed_value_type:
|
||||
if param.type == 'variable':
|
||||
try:
|
||||
values = self.load_params_in_validenum(param)
|
||||
except NameError as err:
|
||||
raise CreoleDictConsistencyError(_('cannot load value for variable {}: {}').format(check.target, err))
|
||||
raise DictConsistencyError(_('cannot load value for variable {}: {}').format(check.target, err))
|
||||
add_default_value = not check.is_in_leadership
|
||||
if add_default_value and values:
|
||||
self.force_value[check.target] = values[0]
|
||||
@ -852,18 +859,13 @@ class SpaceAnnotator(object):
|
||||
del self.space.constraints.check[idx]
|
||||
|
||||
def check_change_warning(self):
|
||||
#convert level to "warnings_only" and hidden to "transitive"
|
||||
#convert level to "warnings_only"
|
||||
for check in self.space.constraints.check:
|
||||
if check.level == 'warning':
|
||||
check.warnings_only = True
|
||||
else:
|
||||
check.warnings_only = False
|
||||
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
|
||||
# valid param in check
|
||||
@ -889,20 +891,20 @@ class SpaceAnnotator(object):
|
||||
elif name == 'valid_network_netmask':
|
||||
params_len = 1
|
||||
if len(check.param) != params_len:
|
||||
raise CreoleDictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
elif name == 'valid_ipnetmask':
|
||||
params_len = 1
|
||||
if len(check.param) != params_len:
|
||||
raise CreoleDictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
name = 'valid_ip_netmask'
|
||||
elif name == 'valid_broadcast':
|
||||
params_len = 2
|
||||
if len(check.param) != params_len:
|
||||
raise CreoleDictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
elif name == 'valid_in_network':
|
||||
params_len = 2
|
||||
if len(check.param) != params_len:
|
||||
raise CreoleDictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
raise DictConsistencyError(_('{} must have {} param').format(name, params_len))
|
||||
check_.name = name
|
||||
check_.warnings_only = check.warnings_only
|
||||
if hasattr(check, 'param'):
|
||||
@ -918,13 +920,13 @@ class SpaceAnnotator(object):
|
||||
for idx, target in enumerate(condition.target):
|
||||
if target.type == 'variable':
|
||||
if condition.source == target.name:
|
||||
raise CreoleDictConsistencyError(_('target name and source name must be different: {}').format(condition.source))
|
||||
raise DictConsistencyError(_('target name and source name must be different: {}').format(condition.source))
|
||||
target.name = self.paths.get_variable_path(target.name, namespace)
|
||||
elif target.type == 'family':
|
||||
try:
|
||||
target.name = self.paths.get_family_path(target.name, namespace)
|
||||
except KeyError:
|
||||
raise CreoleDictConsistencyError(_('cannot found family {}').format(target.name))
|
||||
raise DictConsistencyError(_('cannot found family {}').format(target.name))
|
||||
|
||||
def convert_xxxlist_to_variable(self): # pylint: disable=C0111
|
||||
# transform *list to variable or family
|
||||
@ -958,21 +960,21 @@ class SpaceAnnotator(object):
|
||||
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',
|
||||
'hidden_if_not_in', 'mandatory_if_in', 'mandatory_if_not_in']:
|
||||
raise CreoleDictConsistencyError(_(f'unknown condition {condition.name}'))
|
||||
raise DictConsistencyError(_(f'unknown condition {condition.name}'))
|
||||
|
||||
def check_params(self):
|
||||
for condition in self.space.constraints.condition:
|
||||
for param in condition.param:
|
||||
if param.type not in TYPE_PARAM_CONDITION:
|
||||
raise CreoleDictConsistencyError(_(f'cannot use {param.type} type as a param in a condition'))
|
||||
raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a condition'))
|
||||
|
||||
def check_target(self):
|
||||
for condition in self.space.constraints.condition:
|
||||
if not hasattr(condition, 'target'):
|
||||
raise CreoleDictConsistencyError(_('target is mandatory in condition'))
|
||||
raise DictConsistencyError(_('target is mandatory in condition'))
|
||||
for target in condition.target:
|
||||
if target.type.endswith('list') and condition.name not in ['disabled_if_in', 'disabled_if_not_in']:
|
||||
raise CreoleDictConsistencyError(_(f'target in condition for {target.type} not allow in {condition.name}'))
|
||||
raise DictConsistencyError(_(f'target in condition for {target.type} not allow in {condition.name}'))
|
||||
|
||||
def check_condition_fallback_optional(self):
|
||||
# a condition with a fallback **and** the source variable doesn't exist
|
||||
@ -982,7 +984,7 @@ class SpaceAnnotator(object):
|
||||
if condition.fallback is True and not self.paths.path_is_defined(condition.source):
|
||||
for target in condition.target:
|
||||
if target.type in ['variable', 'family']:
|
||||
if target.name.startswith(VARIABLE_NAMESPACE + '.'):
|
||||
if target.name.startswith(variable_namespace + '.'):
|
||||
name = target.name.split('.')[-1]
|
||||
else:
|
||||
name = target.name
|
||||
@ -1043,7 +1045,7 @@ class SpaceAnnotator(object):
|
||||
if condition.param == []:
|
||||
remove_targets = []
|
||||
for target in condition.target:
|
||||
if target.name.startswith(f'{VARIABLE_NAMESPACE}.'):
|
||||
if target.name.startswith(f'{variable_namespace}.'):
|
||||
name = target.name.split('.')[-1]
|
||||
else:
|
||||
name = target.name
|
||||
@ -1071,7 +1073,7 @@ class SpaceAnnotator(object):
|
||||
for condition in self.space.constraints.condition:
|
||||
#parse each variable and family
|
||||
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]
|
||||
else:
|
||||
name = target.name
|
||||
@ -1127,7 +1129,7 @@ class SpaceAnnotator(object):
|
||||
else:
|
||||
param = None
|
||||
for target in condition.target:
|
||||
if target.name.startswith(f'{VARIABLE_NAMESPACE}.'):
|
||||
if target.name.startswith(f'{variable_namespace}.'):
|
||||
name = target.name.split('.')[-1]
|
||||
else:
|
||||
name = target.name
|
||||
|
@ -15,3 +15,5 @@ dtdfilename = join(dtddir, 'rougail.dtd')
|
||||
|
||||
# chemin du répertoire source des fichiers templates
|
||||
patch_dir = '/srv/rougail/patch'
|
||||
|
||||
variable_namespace = 'rougail'
|
||||
|
@ -140,7 +140,7 @@
|
||||
<!ELEMENT param (#PCDATA)>
|
||||
<!ATTLIST param type (string|variable|number|python) "string">
|
||||
<!ATTLIST param name CDATA #IMPLIED>
|
||||
<!ATTLIST param hidden (True|False) "True">
|
||||
<!ATTLIST param notraisepropertyerror (True|False) "False">
|
||||
<!ATTLIST param optional (True|False) "False">
|
||||
|
||||
<!ELEMENT target (#PCDATA)>
|
||||
|
@ -1,9 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Erreurs Creole
|
||||
"""
|
||||
|
||||
|
||||
class ConfigError(Exception):
|
||||
pass
|
||||
|
||||
@ -19,7 +14,7 @@ class TemplateDisabled(TemplateError):
|
||||
pass
|
||||
|
||||
|
||||
class CreoleOperationError(Exception):
|
||||
class OperationError(Exception):
|
||||
"""Type error or value Error for Creole variable's type or values
|
||||
"""
|
||||
|
||||
@ -30,11 +25,11 @@ class SpaceObjShallNotBeUpdated(Exception):
|
||||
"""
|
||||
|
||||
|
||||
class CreoleDictConsistencyError(Exception):
|
||||
class DictConsistencyError(Exception):
|
||||
"""It's not only that the Creole XML is valid against the Creole DTD
|
||||
it's that it is not consistent.
|
||||
"""
|
||||
|
||||
|
||||
class CreoleLoaderError(Exception):
|
||||
class LoaderError(Exception):
|
||||
pass
|
||||
|
@ -1,33 +1,16 @@
|
||||
"""loader
|
||||
flattened XML specific
|
||||
"""
|
||||
from os.path import join, isfile
|
||||
from os.path import isfile
|
||||
from lxml.etree import DTD
|
||||
import imp
|
||||
|
||||
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 .config import dtdfilename, variable_namespace
|
||||
from .i18n import _
|
||||
from .utils import normalize_family
|
||||
from .annotator import VARIABLE_NAMESPACE
|
||||
from .error import CreoleLoaderError
|
||||
from .error import LoaderError
|
||||
|
||||
|
||||
FUNC_TO_DICT = ['valid_not_equal']
|
||||
|
||||
|
||||
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)
|
||||
FORCE_INFORMATIONS = ['help', 'test', 'separator']
|
||||
|
||||
|
||||
def convert_boolean(value):
|
||||
@ -54,90 +37,71 @@ def convert_tiramisu_value(value, type_):
|
||||
return func(value)
|
||||
|
||||
|
||||
CONVERT_OPTION = {'number': dict(opttype=IntOption, func=int),
|
||||
'choice': dict(opttype=ChoiceOption),
|
||||
'string': dict(opttype=StrOption),
|
||||
'password': dict(opttype=PasswordOption),
|
||||
'mail': dict(opttype=EmailOption),
|
||||
'boolean': dict(opttype=BoolOption, initkwargs={'default': True}, func=convert_boolean),
|
||||
'symlink': dict(opttype=SymLinkOption),
|
||||
'filename': dict(opttype=FilenameOption),
|
||||
'date': dict(opttype=DateOption),
|
||||
'unix_user': dict(opttype=UsernameOption),
|
||||
'ip': dict(opttype=IPOption, initkwargs={'allow_reserved': True}),
|
||||
'local_ip': dict(opttype=IPOption, initkwargs={'private_only': True, 'warnings_only': True}),
|
||||
'netmask': dict(opttype=NetmaskOption),
|
||||
'network': dict(opttype=NetworkOption),
|
||||
'broadcast': dict(opttype=BroadcastOption),
|
||||
'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_strict': dict(opttype=DomainnameOption, initkwargs={'type': 'domainname', 'allow_ip': False}),
|
||||
'hostname': dict(opttype=DomainnameOption, initkwargs={'type': 'hostname', 'allow_ip': True}),
|
||||
'hostname_strict': dict(opttype=DomainnameOption, initkwargs={'type': 'hostname', 'allow_ip': False}),
|
||||
'web_address': dict(opttype=URLOption, initkwargs={'allow_ip': True, 'allow_without_dot': True}),
|
||||
'port': dict(opttype=PortOption, initkwargs={'allow_private': True}),
|
||||
'mac': dict(opttype=MACOption),
|
||||
'cidr': dict(opttype=IPOption, initkwargs={'cidr': True}),
|
||||
'network_cidr': dict(opttype=NetworkOption, initkwargs={'cidr': True}),
|
||||
CONVERT_OPTION = {'number': dict(opttype="IntOption", func=int),
|
||||
'choice': dict(opttype="ChoiceOption"),
|
||||
'string': dict(opttype="StrOption"),
|
||||
'password': dict(opttype="PasswordOption"),
|
||||
'mail': dict(opttype="EmailOption"),
|
||||
'boolean': dict(opttype="BoolOption", initkwargs={'default': [True]}, func=convert_boolean),
|
||||
'symlink': dict(opttype="SymLinkOption"),
|
||||
'filename': dict(opttype="FilenameOption"),
|
||||
'date': dict(opttype="DateOption"),
|
||||
'unix_user': dict(opttype="UsernameOption"),
|
||||
'ip': dict(opttype="IPOption", initkwargs={'allow_reserved': True}),
|
||||
'local_ip': dict(opttype="IPOption", initkwargs={'private_only': True, 'warnings_only': True}),
|
||||
'netmask': dict(opttype="NetmaskOption"),
|
||||
'network': dict(opttype="NetworkOption"),
|
||||
'broadcast': dict(opttype="BroadcastOption"),
|
||||
'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_strict': dict(opttype="DomainnameOption", initkwargs={'type': 'domainname', 'allow_ip': False}),
|
||||
'hostname': dict(opttype="DomainnameOption", initkwargs={'type': 'hostname', 'allow_ip': True}),
|
||||
'hostname_strict': dict(opttype="DomainnameOption", initkwargs={'type': 'hostname', 'allow_ip': False}),
|
||||
'web_address': dict(opttype="URLOption", initkwargs={'allow_ip': True, 'allow_without_dot': True}),
|
||||
'port': dict(opttype="PortOption", initkwargs={'allow_private': True}),
|
||||
'mac': dict(opttype="MACOption"),
|
||||
'cidr': dict(opttype="IPOption", initkwargs={'cidr': True}),
|
||||
'network_cidr': dict(opttype="NetworkOption", initkwargs={'cidr': True}),
|
||||
}
|
||||
|
||||
|
||||
class BaseElt:
|
||||
def __init__(self, attrib):
|
||||
self.attrib = attrib
|
||||
|
||||
|
||||
class Common:
|
||||
def populate_properties(self, 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)
|
||||
self.attrib['properties'].append((ParamValue(child.text), kwargs))
|
||||
else:
|
||||
self.attrib['properties'].append(child.text)
|
||||
|
||||
def build_properties(self):
|
||||
for index, prop in enumerate(self.attrib['properties']):
|
||||
if isinstance(prop, tuple):
|
||||
action, kwargs = prop
|
||||
kwargs['condition'] = ParamOption(self.storage.get(kwargs['condition']).get(), todict=True)
|
||||
prop = Calculation(calc_value,
|
||||
Params(action,
|
||||
kwargs=kwargs))
|
||||
self.attrib['properties'][index] = prop
|
||||
if self.attrib['properties']:
|
||||
self.attrib['properties'] = tuple(self.attrib['properties'])
|
||||
else:
|
||||
del self.attrib['properties']
|
||||
|
||||
|
||||
class PopulateTiramisuObjects:
|
||||
def __init__(self):
|
||||
self.storage = ElementStorage()
|
||||
self.booleans = []
|
||||
def __init__(self,
|
||||
xmlroot,
|
||||
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, dtdfilename):
|
||||
"""Loads the Creole DTD
|
||||
def parse_dtd(self):
|
||||
"""Loads the DTD
|
||||
|
||||
:raises IOError: if the DTD is not found
|
||||
|
||||
:param dtdfilename: the full filename of the Creole DTD
|
||||
:param dtdfilename: the full filename of the DTD
|
||||
"""
|
||||
if not isfile(dtdfilename):
|
||||
raise IOError(_("no such DTD file: {}").format(dtdfilename))
|
||||
booleans = []
|
||||
with open(dtdfilename, 'r') as dtdfd:
|
||||
dtd = DTD(dtdfd)
|
||||
for elt in dtd.iterelements():
|
||||
if elt.name == 'variable':
|
||||
for attr in elt.iterattributes():
|
||||
if set(attr.itervalues()) == set(['True', 'False']):
|
||||
self.booleans.append(attr.name)
|
||||
|
||||
def make_tiramisu_objects(self, xmlroot, eosfunc):
|
||||
self.eosfunc = imp.load_source('eosfunc', eosfunc)
|
||||
booleans.append(attr.name)
|
||||
return booleans
|
||||
|
||||
def make_tiramisu_objects(self,
|
||||
xmlroot,
|
||||
):
|
||||
family = self.get_root_family()
|
||||
for xmlelt in self.reorder_family(xmlroot):
|
||||
self.iter_family(xmlelt,
|
||||
@ -148,19 +112,18 @@ class PopulateTiramisuObjects:
|
||||
def get_root_family(self):
|
||||
family = Family(BaseElt({'name': 'baseoption',
|
||||
'doc': 'baseoption'}),
|
||||
self.booleans,
|
||||
self.storage,
|
||||
self.eosfunc,
|
||||
False,
|
||||
'.',
|
||||
)
|
||||
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:
|
||||
# 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)
|
||||
@ -194,12 +157,10 @@ class PopulateTiramisuObjects:
|
||||
elt,
|
||||
)
|
||||
family = Family(elt,
|
||||
self.booleans,
|
||||
self.storage,
|
||||
self.eosfunc,
|
||||
elt.tag == 'leader',
|
||||
path,
|
||||
)
|
||||
self.storage.add(path, family)
|
||||
parent_family.add(family)
|
||||
if len(elt) != 0:
|
||||
for child in elt:
|
||||
@ -216,22 +177,18 @@ class PopulateTiramisuObjects:
|
||||
is_follower = False
|
||||
is_leader = False
|
||||
if family.is_leader:
|
||||
if elt.attrib['name'] != family.attrib['name']:
|
||||
if elt.attrib['name'] != family.elt.attrib['name']:
|
||||
is_follower = True
|
||||
else:
|
||||
is_leader = True
|
||||
path = self.build_path(subpath,
|
||||
elt,
|
||||
)
|
||||
variable = Variable(elt,
|
||||
self.booleans,
|
||||
family.add(Variable(elt,
|
||||
self.storage,
|
||||
is_follower,
|
||||
is_leader,
|
||||
self.eosfunc,
|
||||
)
|
||||
self.storage.add(path, variable)
|
||||
family.add(variable)
|
||||
self.build_path(subpath,
|
||||
elt,
|
||||
)
|
||||
))
|
||||
|
||||
def build_path(self,
|
||||
subpath,
|
||||
@ -241,306 +198,299 @@ class PopulateTiramisuObjects:
|
||||
return 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:
|
||||
def __init__(self):
|
||||
def __init__(self,
|
||||
booleans,
|
||||
):
|
||||
self.paths = {}
|
||||
self.text = []
|
||||
self.index = 0
|
||||
self.booleans = booleans
|
||||
|
||||
def add(self, path, elt):
|
||||
if path in self.paths:
|
||||
raise CreoleLoaderError(_('path already loaded {}').format(path))
|
||||
self.paths[path] = elt
|
||||
self.paths[path] = (elt, self.index)
|
||||
self.index += 1
|
||||
|
||||
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:
|
||||
raise CreoleLoaderError(_('there is no element for path {}').format(path))
|
||||
return self.paths[path]
|
||||
raise LoaderError(_('there is no element for index {}').format(path))
|
||||
return f'option_{self.paths[path][1]}'
|
||||
|
||||
|
||||
class Common:
|
||||
def __init__(self,
|
||||
elt,
|
||||
storage,
|
||||
is_leader,
|
||||
path,
|
||||
):
|
||||
self.option_name = None
|
||||
self.path = path
|
||||
self.attrib = {}
|
||||
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']:
|
||||
self.attrib['properties'] += ', '
|
||||
self.attrib['properties'] += prop
|
||||
if not 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):
|
||||
def __init__(self, elt, booleans, storage, is_follower, is_leader, eosfunc):
|
||||
self.option = None
|
||||
self.informations = {}
|
||||
self.attrib = {}
|
||||
convert_option = CONVERT_OPTION[elt.attrib['type']]
|
||||
if 'initkwargs' in convert_option:
|
||||
self.attrib.update(convert_option['initkwargs'])
|
||||
if elt.attrib['type'] != 'symlink':
|
||||
self.attrib['properties'] = []
|
||||
self.attrib['validators'] = []
|
||||
self.eosfunc = eosfunc
|
||||
self.storage = storage
|
||||
self.booleans = booleans
|
||||
self.populate_attrib(elt)
|
||||
def __init__(self,
|
||||
elt,
|
||||
storage,
|
||||
is_follower,
|
||||
is_leader,
|
||||
path,
|
||||
):
|
||||
super().__init__(elt,
|
||||
storage,
|
||||
is_leader,
|
||||
path,
|
||||
)
|
||||
self.is_follower = is_follower
|
||||
self.is_leader = is_leader
|
||||
convert_option = CONVERT_OPTION[elt.attrib['type']]
|
||||
del elt.attrib['type']
|
||||
self.object_type = convert_option['opttype']
|
||||
if 'multi' in self.attrib and self.attrib['multi']:
|
||||
self.attrib['default'] = []
|
||||
if self.is_follower:
|
||||
self.attrib['default_multi'] = []
|
||||
self.parse_children(elt)
|
||||
if self.is_follower:
|
||||
if self.attrib['multi'] is True:
|
||||
self.attrib['multi'] = submulti
|
||||
else:
|
||||
self.attrib['multi'] = True
|
||||
if elt.attrib['type'] == 'symlink':
|
||||
self.attrib['opt'] = storage.get(self.attrib['opt'])
|
||||
self.attrib.update(convert_option.get('initkwargs', {}))
|
||||
if self.object_type != 'SymLinkOption':
|
||||
self.attrib['properties'] = ''
|
||||
self.attrib['validators'] = []
|
||||
self.elt = elt
|
||||
|
||||
def parse_children(self,
|
||||
elt,
|
||||
):
|
||||
if elt.attrib['type'] == 'choice':
|
||||
values = []
|
||||
for child in elt:
|
||||
def get(self):
|
||||
if self.option_name is None:
|
||||
self.populate_attrib()
|
||||
if self.object_type == 'SymLinkOption':
|
||||
self.attrib['opt'] = self.storage.get(self.attrib['opt']).get()
|
||||
else:
|
||||
self.parse_multi()
|
||||
self.parse_children()
|
||||
attrib = self.get_attrib(self.attrib)
|
||||
self.option_name = self.storage.get_name(self.path)
|
||||
self.storage.text.append(f'{self.option_name} = {self.object_type}({attrib})')
|
||||
self.populate_informations()
|
||||
return self.option_name
|
||||
|
||||
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:
|
||||
self.attrib[key] = value
|
||||
|
||||
def parse_children(self):
|
||||
if not 'default' in self.attrib or self.attrib['multi']:
|
||||
self.attrib['default'] = []
|
||||
if self.attrib['multi'] == 'submulti' and self.is_follower:
|
||||
self.attrib['default_multi'] = []
|
||||
choices = []
|
||||
for child in self.elt:
|
||||
if child.tag == 'property':
|
||||
self.populate_properties(child)
|
||||
elif child.tag == 'value':
|
||||
if child.attrib.get('type') == 'calculation':
|
||||
self.calc_value(child)
|
||||
if child.attrib['type'] == 'calculation':
|
||||
self.attrib['default'] = self.calculation_value(child, [])
|
||||
else:
|
||||
self.populate_value(child, elt)
|
||||
self.populate_value(child)
|
||||
elif child.tag == 'check':
|
||||
self.populate_check(child)
|
||||
self.attrib['validators'].append(self.calculation_value(child, ['ParamSelfOption()']))
|
||||
elif child.tag == 'choice':
|
||||
value = child.text
|
||||
if child.attrib['type'] == 'number':
|
||||
value = int(value)
|
||||
values.append(value)
|
||||
if elt.attrib['type'] == 'choice':
|
||||
self.attrib['values'] = tuple(values)
|
||||
|
||||
def populate_attrib(self,
|
||||
elt,
|
||||
):
|
||||
for key, value in elt.attrib.items():
|
||||
if key == 'multi' and elt.attrib['type'] == 'symlink':
|
||||
continue
|
||||
if key in self.booleans:
|
||||
if value == 'True':
|
||||
value = True
|
||||
elif value == 'False':
|
||||
value = False
|
||||
else:
|
||||
raise CreoleLoaderError(_('unknown value {} for {}').format(value, key))
|
||||
if key in ['help', 'test', 'separator']:
|
||||
self.add_information(key, value)
|
||||
elif key != 'type':
|
||||
self.attrib[key] = value
|
||||
|
||||
def calc_value(self, child):
|
||||
args = []
|
||||
kwargs = {}
|
||||
if child.text is not None and child.text.strip():
|
||||
function = child.text.strip()
|
||||
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:
|
||||
function = child.attrib['name']
|
||||
for param in child:
|
||||
self.parse_param(args,
|
||||
kwargs,
|
||||
param,
|
||||
)
|
||||
self.attrib['default'] = {'function': getattr(self.eosfunc, function),
|
||||
'args': args,
|
||||
'kwargs': kwargs,
|
||||
'warnings_only': False}
|
||||
self.attrib['validators'] = '[' + ', '.join(self.attrib['validators']) + ']'
|
||||
|
||||
def populate_value(self, child, elt):
|
||||
if "type" in child.attrib:
|
||||
type_ = child.attrib['type']
|
||||
else:
|
||||
type_ = elt.attrib['type']
|
||||
value = convert_tiramisu_value(child.text, type_)
|
||||
def parse_multi(self):
|
||||
if self.is_follower:
|
||||
if self.attrib['multi'] is True:
|
||||
self.attrib['default_multi'].append(value)
|
||||
self.attrib['multi'] = 'submulti'
|
||||
else:
|
||||
self.attrib['default_multi'] = value
|
||||
elif self.attrib['multi'] is True:
|
||||
self.attrib['default'].append(value)
|
||||
if not self.is_leader:
|
||||
self.attrib['default_multi'] = value
|
||||
self.attrib['multi'] = True
|
||||
|
||||
def calculation_value(self, child, args):
|
||||
kwargs = []
|
||||
if 'name' in child.attrib:
|
||||
# has parameters
|
||||
function = child.attrib['name']
|
||||
for param in child:
|
||||
value = self.populate_param(param)
|
||||
if 'name' not in param.attrib:
|
||||
args.append(str(value))
|
||||
else:
|
||||
kwargs.append(f"'{param.attrib['name']}': " + value)
|
||||
else:
|
||||
self.attrib['default'] = value
|
||||
# function without any parameter
|
||||
function = child.text.strip()
|
||||
ret = f"Calculation(func.{function}, Params((" + ', '.join(args) + "), kwargs=" + "{" + ', '.join(kwargs) + "})"
|
||||
if 'warnings_only' in child.attrib:
|
||||
ret += f', warnings_only={child.attrib["warnings_only"]}'
|
||||
return ret + ')'
|
||||
|
||||
def populate_check(self, child):
|
||||
args = [ParamSelfOption()]
|
||||
kwargs = {}
|
||||
for param in child:
|
||||
self.parse_param(args,
|
||||
kwargs,
|
||||
param,
|
||||
)
|
||||
self.attrib['validators'].append({'function': getattr(self.eosfunc, child.attrib['name']),
|
||||
'args': args,
|
||||
'kwargs': kwargs,
|
||||
'warnings_only': convert_boolean(child.attrib['warnings_only'])})
|
||||
|
||||
def parse_param(self,
|
||||
args,
|
||||
kwargs,
|
||||
param,
|
||||
):
|
||||
def populate_param(self,
|
||||
param,
|
||||
):
|
||||
if param.attrib['type'] == 'string':
|
||||
value = ParamValue(param.text)
|
||||
return f'ParamValue("{param.text}")'
|
||||
elif param.attrib['type'] == 'number':
|
||||
value = ParamValue(int(param.text))
|
||||
return f'ParamValue({param.text})'
|
||||
elif param.attrib['type'] == 'variable':
|
||||
transitive = convert_boolean(param.attrib.get('transitive', 'False'))
|
||||
value = {'option': param.text,
|
||||
'notraisepropertyerror': transitive,
|
||||
'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)
|
||||
if not self.is_leader:
|
||||
self.attrib['default_multi'] = value
|
||||
elif isinstance(value, int):
|
||||
self.attrib['default'].append(value)
|
||||
else:
|
||||
raise CreoleLoaderError(_('unknown param type {}').format(param.attrib['type']))
|
||||
if 'name' not in param.attrib:
|
||||
args.append(value)
|
||||
else:
|
||||
kwargs[param.attrib['name']] = value
|
||||
self.attrib['default'].append("'" + value + "'")
|
||||
|
||||
def build_calculator(self, key):
|
||||
def build_param(param):
|
||||
option = self.storage.get(param['option']).get()
|
||||
if 'suffix' in param:
|
||||
family = '.'.join(param['option'].split('.')[:-1])
|
||||
return ParamDynOption(option,
|
||||
param['suffix'],
|
||||
self.storage.get(family).get(),
|
||||
notraisepropertyerror=param['notraisepropertyerror'],
|
||||
todict=param['todict'],
|
||||
)
|
||||
return ParamOption(option,
|
||||
notraisepropertyerror=param['notraisepropertyerror'],
|
||||
todict=param['todict'],
|
||||
)
|
||||
return param
|
||||
def build_calculation(value):
|
||||
args = []
|
||||
kwargs = {}
|
||||
for param in value['args']:
|
||||
if isinstance(param, dict):
|
||||
param = build_param(param)
|
||||
args.append(param)
|
||||
for key, param in value['kwargs'].items():
|
||||
if isinstance(param, dict):
|
||||
param = build_param(param)
|
||||
kwargs[key] = param
|
||||
return Calculation(value['function'],
|
||||
Params(tuple(args),
|
||||
kwargs=kwargs,
|
||||
),
|
||||
warnings_only=value['warnings_only'],
|
||||
)
|
||||
if key in self.attrib:
|
||||
values = self.attrib[key]
|
||||
if isinstance(values, list):
|
||||
self.attrib[key] = []
|
||||
for value in values:
|
||||
if isinstance(value, dict):
|
||||
value = build_calculation(value)
|
||||
self.attrib[key].append(value)
|
||||
else:
|
||||
if isinstance(values, dict):
|
||||
values = build_calculation(values)
|
||||
self.attrib[key] = values
|
||||
|
||||
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 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
|
||||
def build_param(self,
|
||||
param,
|
||||
):
|
||||
option_name = self.storage.get(param['option']).get()
|
||||
if 'suffix' in param:
|
||||
family = '.'.join(param['option'].split('.')[:-1])
|
||||
family_option = self.storage.get_name(family)
|
||||
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']})"
|
||||
|
||||
|
||||
class Family(Common):
|
||||
def __init__(self,
|
||||
elt,
|
||||
booleans,
|
||||
storage,
|
||||
eosfunc,
|
||||
is_leader=False,
|
||||
is_leader,
|
||||
path,
|
||||
):
|
||||
self.option = None
|
||||
self.attrib = {}
|
||||
self.is_leader = False
|
||||
self.informations = {}
|
||||
super().__init__(elt,
|
||||
storage,
|
||||
is_leader,
|
||||
path,
|
||||
)
|
||||
self.children = []
|
||||
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
|
||||
if not isinstance(elt, BaseElt) and len(elt) != 0:
|
||||
for child in elt:
|
||||
if child.tag == 'property':
|
||||
self.populate_properties(child)
|
||||
self.is_leader = is_leader
|
||||
self.elt = elt
|
||||
|
||||
def add(self, child):
|
||||
self.children.append(child)
|
||||
|
||||
def add_information(self, key, value):
|
||||
if key in self.informations and not (key == 'icon' and self.informations[key] is None):
|
||||
raise CreoleLoaderError(_('key already exists in information {}').format(key))
|
||||
self.informations[key] = value
|
||||
|
||||
def get(self):
|
||||
if self.option is None:
|
||||
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:
|
||||
option = OptionDescription(**self.attrib)
|
||||
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
|
||||
if not self.option_name:
|
||||
self.populate_attrib()
|
||||
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
|
||||
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):
|
||||
self.attrib['properties'] = ''
|
||||
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):
|
||||
if 'suffixes' in self.attrib:
|
||||
return 'ConvertDynOptionDescription'
|
||||
elif not self.is_leader:
|
||||
return 'OptionDescription'
|
||||
return 'Leadership'
|
||||
|
||||
|
||||
def load(xmlroot: str,
|
||||
dtd_path: str,
|
||||
funcs_path: str):
|
||||
tiramisu_objects = PopulateTiramisuObjects()
|
||||
tiramisu_objects.parse_dtd(dtd_path)
|
||||
tiramisu_objects.make_tiramisu_objects(xmlroot,
|
||||
funcs_path)
|
||||
return tiramisu_objects.storage.paths['.'].get()
|
||||
tiramisu_objects = PopulateTiramisuObjects(xmlroot,
|
||||
funcs_path,
|
||||
)
|
||||
return tiramisu_objects.get_text()
|
||||
|
@ -28,10 +28,11 @@ from lxml.etree import Element, SubElement # pylint: disable=E0611
|
||||
|
||||
from .i18n import _
|
||||
from .xmlreflector import XMLReflector, HIGH_COMPATIBILITY
|
||||
from .annotator import ERASED_ATTRIBUTES, VARIABLE_NAMESPACE, ServiceAnnotator, SpaceAnnotator
|
||||
from .annotator import ERASED_ATTRIBUTES, ServiceAnnotator, SpaceAnnotator
|
||||
from .utils import normalize_family
|
||||
from .error import CreoleOperationError, SpaceObjShallNotBeUpdated, CreoleDictConsistencyError
|
||||
from .error import OperationError, SpaceObjShallNotBeUpdated, DictConsistencyError
|
||||
from .path import Path
|
||||
from .config import variable_namespace
|
||||
|
||||
# CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type
|
||||
FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables')
|
||||
@ -178,7 +179,7 @@ class CreoleObjSpace:
|
||||
continue
|
||||
if child.tag == 'family':
|
||||
if child.attrib['name'] in family_names:
|
||||
raise CreoleDictConsistencyError(_('Family {} is set several times').format(child.attrib['name']))
|
||||
raise DictConsistencyError(_('Family {} is set several times').format(child.attrib['name']))
|
||||
family_names.append(child.attrib['name'])
|
||||
if child.tag == 'variables':
|
||||
child.attrib['name'] = namespace
|
||||
@ -296,12 +297,12 @@ class CreoleObjSpace:
|
||||
)
|
||||
elif exists is False:
|
||||
raise SpaceObjShallNotBeUpdated()
|
||||
raise CreoleDictConsistencyError(_(f'Already present in another XML file, {name} cannot be re-created'))
|
||||
raise DictConsistencyError(_(f'Already present in another XML file, {name} cannot be re-created'))
|
||||
redefine = self.convert_boolean(subspace.get('redefine', False))
|
||||
exists = self.convert_boolean(subspace.get('exists', False))
|
||||
if redefine is False or exists is True:
|
||||
return getattr(self, child.tag)()
|
||||
raise CreoleDictConsistencyError(_(f'Redefined object: {name} does not exist yet'))
|
||||
raise DictConsistencyError(_(f'Redefined object: {name} does not exist yet'))
|
||||
|
||||
def create_tree_structure(self,
|
||||
space,
|
||||
@ -325,12 +326,12 @@ class CreoleObjSpace:
|
||||
elif isinstance(variableobj, self.UnRedefinable):
|
||||
setattr(space, child.tag, [])
|
||||
elif not isinstance(variableobj, self.Atom): # pragma: no cover
|
||||
raise CreoleOperationError(_("Creole object {} "
|
||||
raise OperationError(_("Creole object {} "
|
||||
"has a wrong type").format(type(variableobj)))
|
||||
|
||||
def is_already_exists(self, name, space, child, namespace):
|
||||
if isinstance(space, self.family): # pylint: disable=E1101
|
||||
if namespace != VARIABLE_NAMESPACE:
|
||||
if namespace != variable_namespace:
|
||||
name = space.path + '.' + name
|
||||
return self.paths.path_is_defined(name)
|
||||
if child.tag == 'family':
|
||||
@ -363,14 +364,14 @@ class CreoleObjSpace:
|
||||
else:
|
||||
norm_name = name
|
||||
return getattr(family, variable.tag)[norm_name]
|
||||
if namespace == VARIABLE_NAMESPACE:
|
||||
if namespace == variable_namespace:
|
||||
path = name
|
||||
else:
|
||||
path = family.path + '.' + name
|
||||
old_family_name = self.paths.get_variable_family_name(path)
|
||||
if normalize_family(family.name) == old_family_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]
|
||||
del old_family.variable[name]
|
||||
if 'variable' not in vars(family):
|
||||
@ -452,7 +453,7 @@ class CreoleObjSpace:
|
||||
# UNREDEFINABLE concerns only 'variable' node so we can fix name
|
||||
# to child.attrib['name']
|
||||
name = child.attrib['name']
|
||||
raise CreoleDictConsistencyError(_(f'cannot redefine attribute {attr} for variable {name}'))
|
||||
raise DictConsistencyError(_(f'cannot redefine attribute {attr} for variable {name}'))
|
||||
if attr in self.booleans_attributs:
|
||||
val = self.convert_boolean(val)
|
||||
if not (attr == 'name' and getattr(variableobj, 'name', None) != None):
|
||||
@ -504,7 +505,7 @@ class CreoleObjSpace:
|
||||
document.attrib.get('dynamic') != None,
|
||||
variableobj)
|
||||
if child.attrib.get('redefine', 'False') == 'True':
|
||||
if namespace == VARIABLE_NAMESPACE:
|
||||
if namespace == variable_namespace:
|
||||
self.redefine_variables.append(child.attrib['name'])
|
||||
else:
|
||||
self.redefine_variables.append(namespace + '.' + family_name + '.' +
|
||||
@ -512,7 +513,7 @@ class CreoleObjSpace:
|
||||
|
||||
elif child.tag == 'family':
|
||||
family_name = normalize_family(child.attrib['name'])
|
||||
if namespace != VARIABLE_NAMESPACE:
|
||||
if namespace != variable_namespace:
|
||||
family_name = namespace + '.' + family_name
|
||||
self.paths.add_family(namespace,
|
||||
family_name,
|
||||
@ -590,7 +591,7 @@ class CreoleObjSpace:
|
||||
def _xml_export(self,
|
||||
node,
|
||||
space,
|
||||
node_name=VARIABLE_NAMESPACE,
|
||||
node_name=variable_namespace,
|
||||
):
|
||||
for name in self.get_attributes(space):
|
||||
subspace = getattr(space, name)
|
||||
|
@ -1,7 +1,7 @@
|
||||
from .i18n import _
|
||||
from .utils import normalize_family
|
||||
from .error import CreoleOperationError, CreoleDictConsistencyError
|
||||
from .annotator import VARIABLE_NAMESPACE
|
||||
from .error import OperationError, DictConsistencyError
|
||||
from .config import variable_namespace
|
||||
|
||||
|
||||
class Path:
|
||||
@ -30,13 +30,13 @@ class Path:
|
||||
current_namespace: str,
|
||||
) -> str: # pylint: disable=C0111
|
||||
if current_namespace is None: # pragma: no cover
|
||||
raise CreoleOperationError('current_namespace must not be None')
|
||||
raise OperationError('current_namespace must not be None')
|
||||
dico = self.families[normalize_family(name,
|
||||
check_name=False,
|
||||
allow_dot=True,
|
||||
)]
|
||||
if dico['namespace'] != VARIABLE_NAMESPACE and current_namespace != dico['namespace']:
|
||||
raise CreoleDictConsistencyError(_('A family located in the {} namespace '
|
||||
if dico['namespace'] != variable_namespace and current_namespace != dico['namespace']:
|
||||
raise DictConsistencyError(_('A family located in the {} namespace '
|
||||
'shall not be used in the {} namespace').format(
|
||||
dico['namespace'], current_namespace))
|
||||
path = dico['name']
|
||||
@ -48,7 +48,7 @@ class Path:
|
||||
name: str,
|
||||
) -> 'Family': # pylint: disable=C0111
|
||||
if name not in self.families:
|
||||
raise CreoleDictConsistencyError(_('unknown family {}').format(name))
|
||||
raise DictConsistencyError(_('unknown family {}').format(name))
|
||||
dico = self.families[name]
|
||||
return dico['variableobj']
|
||||
|
||||
@ -59,7 +59,7 @@ class Path:
|
||||
name: str,
|
||||
leader_name: str,
|
||||
) -> None: # pylint: disable=C0111
|
||||
if namespace != VARIABLE_NAMESPACE:
|
||||
if namespace != variable_namespace:
|
||||
# need rebuild path and move object in new path
|
||||
old_path = namespace + '.' + leader_family_name + '.' + name
|
||||
dico = self._get_variable(old_path)
|
||||
@ -74,7 +74,7 @@ class Path:
|
||||
name = new_path
|
||||
dico = self._get_variable(name)
|
||||
if dico['leader'] != None:
|
||||
raise CreoleDictConsistencyError(_('Already defined leader {} for variable'
|
||||
raise DictConsistencyError(_('Already defined leader {} for variable'
|
||||
' {}'.format(dico['leader'], name)))
|
||||
dico['leader'] = leader_name
|
||||
|
||||
@ -89,7 +89,7 @@ class Path:
|
||||
is_dynamic: bool,
|
||||
variableobj,
|
||||
) -> str: # pylint: disable=C0111
|
||||
if namespace == VARIABLE_NAMESPACE or '.' in name:
|
||||
if namespace == variable_namespace or '.' in name:
|
||||
varname = name
|
||||
else:
|
||||
varname = '.'.join([namespace, family, name])
|
||||
@ -127,7 +127,7 @@ class Path:
|
||||
with_suffix: bool=False,
|
||||
) -> str: # pylint: disable=C0111
|
||||
if current_namespace is None: # pragma: no cover
|
||||
raise CreoleOperationError('current_namespace must not be None')
|
||||
raise OperationError('current_namespace must not be None')
|
||||
if with_suffix:
|
||||
dico, suffix = self._get_variable(name,
|
||||
with_suffix=True,
|
||||
@ -135,8 +135,8 @@ class Path:
|
||||
else:
|
||||
dico = self._get_variable(name)
|
||||
if not allow_source:
|
||||
if dico['namespace'] not in [VARIABLE_NAMESPACE, 'services'] and current_namespace != dico['namespace']:
|
||||
raise CreoleDictConsistencyError(_('A variable located in the {} namespace '
|
||||
if dico['namespace'] not in [variable_namespace, 'services'] and current_namespace != dico['namespace']:
|
||||
raise DictConsistencyError(_('A variable located in the {} namespace '
|
||||
'shall not be used in the {} namespace').format(
|
||||
dico['namespace'], current_namespace))
|
||||
if '.' in dico['name']:
|
||||
@ -161,13 +161,13 @@ class Path:
|
||||
with_suffix: bool=False,
|
||||
) -> str:
|
||||
if name not in self.variables:
|
||||
if name.startswith(f'{VARIABLE_NAMESPACE}.'):
|
||||
if name.startswith(f'{variable_namespace}.'):
|
||||
name = name.split('.')[-1]
|
||||
if name not in self.variables:
|
||||
for var_name, variable in self.variables.items():
|
||||
if variable['is_dynamic'] and name.startswith(var_name):
|
||||
return variable, name[len(var_name):]
|
||||
raise CreoleDictConsistencyError(_('unknown option {}').format(name))
|
||||
raise DictConsistencyError(_('unknown option {}').format(name))
|
||||
if with_suffix:
|
||||
return self.variables[name], None
|
||||
return self.variables[name]
|
||||
|
@ -18,8 +18,7 @@ from Cheetah.NameMapper import NotFound as CheetahNotFound
|
||||
from tiramisu import Config
|
||||
from tiramisu.error import PropertiesOptionError
|
||||
|
||||
from .annotator import VARIABLE_NAMESPACE
|
||||
from .config import patch_dir
|
||||
from .config import patch_dir, variable_namespace
|
||||
from .error import FileNotFound, TemplateError
|
||||
from .i18n import _
|
||||
from .utils import normalize_family
|
||||
@ -373,7 +372,7 @@ class CreoleTemplateEngine:
|
||||
"""
|
||||
for option in await self.config.option.list(type='all'):
|
||||
namespace = await option.option.name()
|
||||
if namespace == VARIABLE_NAMESPACE:
|
||||
if namespace == variable_namespace:
|
||||
await self.load_eole_variables_rougail(option)
|
||||
else:
|
||||
families = await self.load_eole_variables(namespace,
|
||||
|
10
src/rougail/tiramisu.py
Normal file
10
src/rougail/tiramisu.py
Normal file
@ -0,0 +1,10 @@
|
||||
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)
|
@ -6,7 +6,7 @@ from os import listdir
|
||||
from lxml.etree import DTD, parse, tostring # , XMLParser
|
||||
|
||||
from .i18n import _
|
||||
from .error import CreoleDictConsistencyError
|
||||
from .error import DictConsistencyError
|
||||
|
||||
HIGH_COMPATIBILITY = True
|
||||
|
||||
@ -38,7 +38,7 @@ class XMLReflector(object):
|
||||
# document = parse(BytesIO(xmlfile), XMLParser(remove_blank_text=True))
|
||||
document = parse(xmlfile)
|
||||
if not self.dtd.validate(document):
|
||||
raise CreoleDictConsistencyError(_("not a valid xml file: {}").format(xmlfile))
|
||||
raise DictConsistencyError(_("not a valid xml file: {}").format(xmlfile))
|
||||
return document.getroot()
|
||||
|
||||
def load_xml_from_folders(self, xmlfolders):
|
||||
|
0
tests/flattener_dicos/00empty/__init__.py
Normal file
0
tests/flattener_dicos/00empty/__init__.py
Normal file
0
tests/flattener_dicos/00empty/tiramisu/__init__.py
Normal file
0
tests/flattener_dicos/00empty/tiramisu/__init__.py
Normal file
7
tests/flattener_dicos/00empty/tiramisu/base.py
Normal file
7
tests/flattener_dicos/00empty/tiramisu/base.py
Normal file
@ -0,0 +1,7 @@
|
||||
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])
|
0
tests/flattener_dicos/00load_autofreeze/__init__.py
Normal file
0
tests/flattener_dicos/00load_autofreeze/__init__.py
Normal file
9
tests/flattener_dicos/00load_autofreeze/tiramisu/base.py
Normal file
9
tests/flattener_dicos/00load_autofreeze/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/00load_autosave/__init__.py
Normal file
0
tests/flattener_dicos/00load_autosave/__init__.py
Normal file
8
tests/flattener_dicos/00load_autosave/tiramisu/base.py
Normal file
8
tests/flattener_dicos/00load_autosave/tiramisu/base.py
Normal file
@ -0,0 +1,8 @@
|
||||
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])
|
@ -0,0 +1,8 @@
|
||||
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])
|
0
tests/flattener_dicos/00load_comment/__init__.py
Normal file
0
tests/flattener_dicos/00load_comment/__init__.py
Normal file
8
tests/flattener_dicos/00load_comment/tiramisu/base.py
Normal file
8
tests/flattener_dicos/00load_comment/tiramisu/base.py
Normal file
@ -0,0 +1,8 @@
|
||||
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])
|
0
tests/flattener_dicos/00load_notype/__init__.py
Normal file
0
tests/flattener_dicos/00load_notype/__init__.py
Normal file
@ -16,7 +16,7 @@
|
||||
<variable doc="without_type" multi="False" name="without_type" type="string">
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value>non</value>
|
||||
<value type="string">non</value>
|
||||
</variable>
|
||||
</family>
|
||||
</family>
|
||||
|
9
tests/flattener_dicos/00load_notype/tiramisu/base.py
Normal file
9
tests/flattener_dicos/00load_notype/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/00load_save/__init__.py
Normal file
0
tests/flattener_dicos/00load_save/__init__.py
Normal file
8
tests/flattener_dicos/00load_save/tiramisu/base.py
Normal file
8
tests/flattener_dicos/00load_save/tiramisu/base.py
Normal file
@ -0,0 +1,8 @@
|
||||
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])
|
0
tests/flattener_dicos/00load_subfolder/__init__.py
Normal file
0
tests/flattener_dicos/00load_subfolder/__init__.py
Normal file
9
tests/flattener_dicos/00load_subfolder/tiramisu/base.py
Normal file
9
tests/flattener_dicos/00load_subfolder/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01auto_base/__init__.py
Normal file
0
tests/flattener_dicos/01auto_base/__init__.py
Normal file
@ -12,7 +12,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
9
tests/flattener_dicos/01auto_base/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01auto_base/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01base_multi/__init__.py
Normal file
0
tests/flattener_dicos/01base_multi/__init__.py
Normal file
8
tests/flattener_dicos/01base_multi/tiramisu/base.py
Normal file
8
tests/flattener_dicos/01base_multi/tiramisu/base.py
Normal file
@ -0,0 +1,8 @@
|
||||
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])
|
0
tests/flattener_dicos/01fill_autofreeze/__init__.py
Normal file
0
tests/flattener_dicos/01fill_autofreeze/__init__.py
Normal file
@ -12,7 +12,7 @@
|
||||
<property>basic</property>
|
||||
<property expected="oui" inverse="True" source="rougail.general.module_instancie" type="calculation">auto_frozen</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
10
tests/flattener_dicos/01fill_autofreeze/tiramisu/base.py
Normal file
10
tests/flattener_dicos/01fill_autofreeze/tiramisu/base.py
Normal file
@ -0,0 +1,10 @@
|
||||
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])
|
0
tests/flattener_dicos/01fill_autosave/__init__.py
Normal file
0
tests/flattener_dicos/01fill_autosave/__init__.py
Normal file
@ -10,7 +10,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>basic</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
9
tests/flattener_dicos/01fill_autosave/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01fill_autosave/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01fill_base/__init__.py
Normal file
0
tests/flattener_dicos/01fill_base/__init__.py
Normal file
@ -12,7 +12,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
9
tests/flattener_dicos/01fill_base/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01fill_base/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01fill_baseaccent/__init__.py
Normal file
0
tests/flattener_dicos/01fill_baseaccent/__init__.py
Normal file
@ -12,7 +12,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
9
tests/flattener_dicos/01fill_baseaccent/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01fill_baseaccent/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01fill_mandatory/__init__.py
Normal file
0
tests/flattener_dicos/01fill_mandatory/__init__.py
Normal file
@ -7,7 +7,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>expert</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
9
tests/flattener_dicos/01fill_mandatory/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01fill_mandatory/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01fill_number/__init__.py
Normal file
0
tests/flattener_dicos/01fill_number/__init__.py
Normal file
@ -10,7 +10,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="number">3</param>
|
||||
<param type="number">3</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
9
tests/flattener_dicos/01fill_number/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01fill_number/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01fill_optional/__init__.py
Normal file
0
tests/flattener_dicos/01fill_optional/__init__.py
Normal file
@ -12,7 +12,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.mode_conteneur_actif1</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
|
||||
|
9
tests/flattener_dicos/01fill_optional/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01fill_optional/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/01separator_base/__init__.py
Normal file
0
tests/flattener_dicos/01separator_base/__init__.py
Normal file
9
tests/flattener_dicos/01separator_base/tiramisu/base.py
Normal file
9
tests/flattener_dicos/01separator_base/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
@ -0,0 +1,9 @@
|
||||
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])
|
0
tests/flattener_dicos/10autosave_hidden/__init__.py
Normal file
0
tests/flattener_dicos/10autosave_hidden/__init__.py
Normal file
@ -20,7 +20,7 @@
|
||||
<property>mandatory</property>
|
||||
<property>basic</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="string">oui</param>
|
||||
<param type="string">oui</param>
|
||||
</value>
|
||||
</variable>
|
||||
</family>
|
||||
|
9
tests/flattener_dicos/10autosave_hidden/tiramisu/base.py
Normal file
9
tests/flattener_dicos/10autosave_hidden/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
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])
|
@ -21,7 +21,7 @@
|
||||
<property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">hidden</property>
|
||||
<property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">force_default_on_freeze</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="string">oui</param>
|
||||
<param type="string">oui</param>
|
||||
</value>
|
||||
</variable>
|
||||
</family>
|
||||
|
@ -0,0 +1,9 @@
|
||||
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', 'mandatory', 'basic', Calculation(calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('force_default_on_freeze'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')}))]), 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])
|
0
tests/flattener_dicos/10check_base/__init__.py
Normal file
0
tests/flattener_dicos/10check_base/__init__.py
Normal file
@ -6,7 +6,7 @@
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="string">
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value>b</value>
|
||||
<value type="string">b</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="int" type="number">
|
||||
<check name="valid_entier" warnings_only="False">
|
||||
|
9
tests/flattener_dicos/10check_base/tiramisu/base.py
Normal file
9
tests/flattener_dicos/10check_base/tiramisu/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
from tiramisu import *
|
||||
from rougail.tiramisu import ConvertDynOptionDescription
|
||||
import imp
|
||||
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
|
||||
option_3 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='b')
|
||||
option_4 = IntOption(properties=frozenset(['normal']), validators=[Calculation(func.valid_entier, Params((ParamSelfOption()), kwargs={'mini': ParamValue("0"), 'maxi': ParamValue("100")}), warnings_only=False)], doc='No change', multi=False, name='int')
|
||||
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])
|
0
tests/flattener_dicos/10check_option/__init__.py
Normal file
0
tests/flattener_dicos/10check_option/__init__.py
Normal file
@ -6,17 +6,17 @@
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="string">
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value>b</value>
|
||||
<value type="string">b</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="int2" type="number">
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value>100</value>
|
||||
<value type="number">100</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="int" type="number">
|
||||
<check name="valid_entier" warnings_only="False">
|
||||
<param name="mini" type="string">0</param>
|
||||
<param name="maxi" type="variable">rougail.general.int2</param>
|
||||
<param name="maxi" notraisepropertyerror="False" type="variable">rougail.general.int2</param>
|
||||
</check>
|
||||
<property>normal</property>
|
||||
</variable>
|
||||
|
10
tests/flattener_dicos/10check_option/tiramisu/base.py
Normal file
10
tests/flattener_dicos/10check_option/tiramisu/base.py
Normal file
@ -0,0 +1,10 @@
|
||||
from tiramisu import *
|
||||
from rougail.tiramisu import ConvertDynOptionDescription
|
||||
import imp
|
||||
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
|
||||
option_3 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='b')
|
||||
option_4 = IntOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='int2', default=100)
|
||||
option_5 = IntOption(properties=frozenset(['normal']), validators=[Calculation(func.valid_entier, Params((ParamSelfOption()), kwargs={'mini': ParamValue("0"), 'maxi': ParamOption(option_4, notraisepropertyerror=False, todict=False)}), warnings_only=False)], doc='No change', multi=False, name='int')
|
||||
option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), 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])
|
0
tests/flattener_dicos/10check_optional/__init__.py
Normal file
0
tests/flattener_dicos/10check_optional/__init__.py
Normal file
@ -6,11 +6,11 @@
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="string">
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value>b</value>
|
||||
<value type="string">b</value>
|
||||
</variable>
|
||||
<variable doc="No change" multi="False" name="int" type="number">
|
||||
<check name="valid_not_equal" warnings_only="False">
|
||||
<param type="variable">rougail.general.int2</param>
|
||||
<param notraisepropertyerror="False" type="variable">rougail.general.int2</param>
|
||||
</check>
|
||||
<property>normal</property>
|
||||
</variable>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user