This commit is contained in:
Emmanuel Garette 2020-07-06 19:47:45 +02:00
parent 2e0e17705b
commit ef5297a4e4
297 changed files with 1560 additions and 3198 deletions

View File

@ -50,6 +50,7 @@ def mode_factory():
modes = mode_factory() modes = mode_factory()
# a CreoleObjSpace's attribute has some annotations # a CreoleObjSpace's attribute has some annotations
# that shall not be present in the exported (flatened) XML # that shall not be present in the exported (flatened) XML
ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace', ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace',
@ -74,7 +75,7 @@ KEY_TYPE = {'variable': 'symlink',
TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable') TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable')
TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable') TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable')
TYPE_PARAM_FILL = ('string', 'eole', 'number', 'context', 'variable') TYPE_PARAM_FILL = ('string', 'number', 'variable')
CONVERSION = {'number': int} CONVERSION = {'number': int}
ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action') ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action')
@ -84,52 +85,73 @@ FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie'
class ServiceAnnotator: class ServiceAnnotator:
"""Manage service's object """Manage service's object
for example::
<services>
<service name="test">
<service_access service='ntp'>
<port protocol='udp' service_accesslist='ntp_udp'>123</port>
</service_access>
</service>
</services>
""" """
def __init__(self, objectspace): def __init__(self, objectspace):
self.space = objectspace.space self.space = objectspace.space
self.paths = objectspace.paths self.paths = objectspace.paths
self.objectspace = objectspace self.objectspace = objectspace
"""for example::
<service_access service='ntp'>
<port protocol='udp' service_accesslist='ntp_udp'>123</port>
<tcpwrapper>ntpd</tcpwrapper>
</service_access>
"""
self.grouplist_conditions = {} self.grouplist_conditions = {}
self.convert_services() self.convert_services()
def convert_services(self): def convert_services(self):
if hasattr(self.space, 'services'): if not hasattr(self.space, 'services'):
if hasattr(self.space.services, 'service'): return
subelts = dict() if not hasattr(self.space.services, 'service'):
del self.space.services
return
for idx, service in enumerate(self.space.services.service.values()): for idx, service in enumerate(self.space.services.service.values()):
service_name = f'service{idx}'
family = self.objectspace.family() family = self.objectspace.family()
family.name = 'service{}'.format(idx) family.name = service_name
family.doc = service.name family.doc = service.name
family.family = OrderedDict() family.mode = None
self.convert_service_to_family(family.name, family.family, service) family.family = self.convert_service_to_family(f'services.{service_name}',
service,
)
setattr(self.space.services, family.name, family) setattr(self.space.services, family.name, family)
del self.space.services.service del self.space.services.service
else:
del self.space.services
def convert_service_to_family(self, service_name, service_family, service): def convert_service_to_family(self,
subpath,
service,
):
services = {}
for elttype, values in vars(service).items(): for elttype, values in vars(service).items():
if elttype in ['name', 'index', 'method']: if elttype == 'name' or elttype in ERASED_ATTRIBUTES:
continue continue
eltname = elttype + 's'
family = self.objectspace.family() family = self.objectspace.family()
family.name = elttype + 's' family.name = eltname
family.mode = None
if isinstance(values, dict): if isinstance(values, dict):
values = list(values.values()) values = list(values.values())
family.family = self.convert_subelement_service(elttype, family.family = self.make_group_from_elts(elttype,
values, values,
'services.{}.{}'.format(service_name, family.name)) f'{subpath}.{eltname}',
family.mode = None )
service_family[family.name] = family services[family.name] = family
return services
def convert_subelement_service(self, name, elts, path): def make_group_from_elts(self,
name,
elts,
path,
):
"""Splits each objects into a group (and `OptionDescription`, in tiramisu terms)
and build elements and its attributes (the `Options` in tiramisu terms)
"""
families = [] families = []
new_elts = self._reorder_elts(name, elts, True) new_elts = self._reorder_elts(name,
elts,
)
for index, elt_info in enumerate(new_elts): for index, elt_info in enumerate(new_elts):
elt = elt_info['elt'] elt = elt_info['elt']
elt_name = elt_info['elt_name'] elt_name = elt_info['elt_name']
@ -151,10 +173,6 @@ class ServiceAnnotator:
if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES: if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES:
continue continue
value = getattr(elt, key) value = getattr(elt, key)
if isinstance(value, list):
continue
if key == 'service':
value = value.name
if key == listname: if key == listname:
self.objectspace.list_conditions.setdefault(listname, self.objectspace.list_conditions.setdefault(listname,
{}).setdefault( {}).setdefault(
@ -165,23 +183,27 @@ class ServiceAnnotator:
true_key = elt_name true_key = elt_name
else: else:
true_key = key true_key = key
if true_key in self.objectspace.booleans_attributs: if key in self.objectspace.booleans_attributs:
type_ = 'boolean' type_ = 'boolean'
else: else:
type_ = 'string' type_ = 'string'
dtd_key_type = true_key + '_type' dtd_key_type = true_key + '_type'
if hasattr(elt, dtd_key_type): if hasattr(elt, dtd_key_type):
type_ = KEY_TYPE[getattr(elt, dtd_key_type)] type_ = KEY_TYPE[getattr(elt, dtd_key_type)]
multi = isinstance(value, list) multi = isinstance(value, list)
variables.append(self._generate_element(elt_name, variables.append(self._generate_element(key,
key,
value, value,
type_, type_,
subpath, subpath,
multi)) multi,
))
# FIXME ne devrait pas etre True par défaut # FIXME ne devrait pas etre True par défaut
variables.append(self._generate_element(name, 'activate', True, 'boolean', subpath)) # devrait etre un calcule
variables.append(self._generate_element('activate',
True,
'boolean',
subpath,
))
family = self.objectspace.family() family = self.objectspace.family()
family.name = '{}{}'.format(name, index) family.name = '{}{}'.format(name, index)
family.variable = variables family.variable = variables
@ -193,48 +215,39 @@ class ServiceAnnotator:
families.append(family) families.append(family)
return families return families
def _generate_element(self, eltname, name, value, type_, subpath, multi=False): def _generate_element(self,
var_data = {'name': name, 'doc': '', 'value': value, key,
'auto_freeze': False, 'mode': None, 'multi': multi} value,
values = None type_,
if type_ == 'string': subpath,
values = self.objectspace.forced_choice_option.get(eltname, {}).get(name) multi=False,
if values is not None: ):
type_ = 'choice'
var_data['type'] = type_
variable = self.objectspace.variable() variable = self.objectspace.variable()
variable.mandatory = True variable.name = key
for key, value in var_data.items(): if type_ != 'symlink':
if key == 'value': variable.doc = key
if value is None: variable.multi = multi
continue variable.mode = None
variable.hidden = True
variable.type = type_
if value is not None:
if type_ == 'symlink': if type_ == 'symlink':
key = 'opt' variable.opt = value
else: else:
# Value is a list of objects
if not multi: if not multi:
val = self.objectspace.value() val = self.objectspace.value()
val.name = value val.name = value
value = [val] value = [val]
else: else:
# value is a list of objects
value_list = [] value_list = []
for valiter in value: for val_iter in value:
val = self.objectspace.value() val = self.objectspace.value()
val.name = valiter.name val.name = val_iter.name
value_list.append(val) value_list.append(val)
value = value_list value = value_list
if key == 'doc' and type_ == 'symlink': variable.value = value
continue path = f'{subpath}.{key}'
setattr(variable, key, value)
if values is not None:
choices = []
for value in values:
choice = self.objectspace.choice()
choice.name = value
choices.append(choice)
variable.choice = choices
path = '{}.{}'.format(subpath, name)
self.paths.add_variable('services', self.paths.add_variable('services',
path, path,
'service', 'service',
@ -243,10 +256,32 @@ class ServiceAnnotator:
) )
return variable return variable
def _update_override(self, file_, index, service_path): def _reorder_elts(self,
self._update_file(file_, index, service_path) name,
elts,
):
"""Reorders by index the elts
"""
new_elts = {}
# reorder elts by index
for elt in elts:
new_elts.setdefault(elt.index, []).append(elt)
idxes = list(new_elts.keys())
idxes.sort()
result_elts = []
for idx in idxes:
for elt in new_elts[idx]:
result_elts.append({'elt_name': name, 'elt': elt})
return result_elts
def _update_file(self, file_, index, service_path): def _update_override(self, *args):
self._update_file(*args)
def _update_file(self,
file_,
index,
service_path,
):
if not hasattr(file_, 'file_type') or file_.file_type == "UnicodeOption": if not hasattr(file_, 'file_type') or file_.file_type == "UnicodeOption":
if not hasattr(file_, 'source'): if not hasattr(file_, 'source'):
file_.source = basename(file_.name) file_.source = basename(file_.name)
@ -254,139 +289,6 @@ class ServiceAnnotator:
raise CreoleDictConsistencyError(_('attribute source mandatory for file with variable name ' raise CreoleDictConsistencyError(_('attribute source mandatory for file with variable name '
'for {}').format(file_.name)) 'for {}').format(file_.name))
def _reorder_elts(self, name, elts, duplicate_list):
"""Reorders by index the elts
"""
dict_elts = OrderedDict()
# reorder elts by index
new_elts = {}
not_indexed = []
for elt in elts:
idx = elt.index
new_elts.setdefault(idx, []).append(elt)
idxes = list(new_elts.keys())
idxes.sort()
elts = not_indexed
for idx in idxes:
elts.extend(new_elts[idx])
for idx, elt in enumerate(elts):
elt_added = False
for key in dir(elt):
if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES:
continue
value = getattr(elt, key)
if not elt_added:
eltname = elt.name
dict_elts.setdefault(eltname, []).append({'elt_name': name, 'elt': elt})
result_elts = []
for elt in dict_elts.values():
result_elts.extend(elt)
return result_elts
def make_group_from_elts(self, name, elts, path, duplicate_list):
"""Splits each objects into a group (and `OptionDescription`, in tiramisu terms)
and build elements and its attributes (the `Options` in tiramisu terms)
"""
families = []
new_elts = self._reorder_elts(name, elts, duplicate_list)
for index, elt_info in enumerate(new_elts):
elt = elt_info['elt']
elt_name = elt_info['elt_name']
# try to launch _update_xxxx() function
update_elt = '_update_' + elt_name
if hasattr(self, update_elt):
getattr(self, update_elt)(elt, index, path)
variables = []
subpath = '{}.{}{}'.format(path, name, index)
listname = '{}list'.format(name)
activate_path = '.'.join([subpath, 'activate'])
if elt in self.grouplist_conditions:
# FIXME transformer le activate qui disparait en boolean
self.objectspace.list_conditions.setdefault(listname,
{}).setdefault(self.grouplist_conditions[elt],
[]).append(activate_path)
for key in dir(elt):
if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES:
continue
value = getattr(elt, key)
if isinstance(value, list) and duplicate_list:
# FIXME plusieurs fichier si calculé !
continue
if key == listname:
self.objectspace.list_conditions.setdefault(listname,
{}).setdefault(
value,
[]).append(activate_path)
continue
if key in self.objectspace.booleans_attributs:
type_ = 'boolean'
else:
type_ = 'string'
dtd_key_type = key + '_type'
if hasattr(elt, dtd_key_type):
type_ = KEY_TYPE[getattr(elt, dtd_key_type)]
multi = isinstance(value, list)
variables.append(self._generate_element(elt_name,
key,
value,
type_,
subpath,
multi))
# FIXME ne devrait pas etre True par défaut
variables.append(self._generate_element(name, 'activate', True, 'boolean', subpath))
family = self.objectspace.family()
family.name = '{}{}'.format(name, index)
family.variable = variables
family.mode = None
self.paths.add_family('services',
subpath,
family,
)
families.append(family)
return families
class ActionAnnotator(ServiceAnnotator):
def __init__(self, objectspace):
self.space = objectspace.space
self.paths = objectspace.paths
self.objectspace = objectspace
self.grouplist_conditions = {}
self.convert_family_action()
def convert_family_action(self):
if hasattr(self.space, 'family_action'):
actions = self.objectspace.family()
actions.name = 'actions'
actions.mode = None
actions.family = []
self.space.actions = actions
namespaces = []
for name, actions in self.space.family_action.items():
subpath = 'actions.{}'.format(normalize_family(name))
for action in actions.action:
namespace = action.namespace
if namespace in namespaces:
raise CreoleDictConsistencyError(_('only one action allow for {}'
'').format(namespace))
namespaces.append(namespace)
action.name = action.namespace
new_actions = self.make_group_from_elts('action', actions.action, subpath, False)
family = self.objectspace.family()
family.name = actions.name
family.family = new_actions
family.mode = None
variables = []
for key, value in vars(actions).items():
if key not in ERASED_FAMILY_ACTION_ATTRIBUTES:
variables.append(self._generate_element('action', key, value, 'string',
subpath))
family.variable = variables
self.space.actions.family.append(family)
del self.space.family_action
class SpaceAnnotator(object): class SpaceAnnotator(object):
"""Transformations applied on a CreoleObjSpace instance """Transformations applied on a CreoleObjSpace instance
@ -415,7 +317,7 @@ class SpaceAnnotator(object):
self.filter_condition() self.filter_condition()
self.convert_valid_enums() self.convert_valid_enums()
self.convert_check() self.convert_check()
self.convert_autofill() self.convert_fill()
self.remove_empty_families() self.remove_empty_families()
self.change_variable_mode() self.change_variable_mode()
self.change_family_mode() self.change_family_mode()
@ -471,6 +373,12 @@ class SpaceAnnotator(object):
leader_space.variable = [] leader_space.variable = []
leader_space.name = leader_name leader_space.name = leader_name
leader_space.hidden = variable.hidden leader_space.hidden = variable.hidden
if variable.hidden:
leader_is_hidden = True
variable.frozen = True
variable.force_default_on_freeze = True
else:
leader_is_hidden = False
variable.hidden = None variable.hidden = None
if hasattr(group, 'description'): if hasattr(group, 'description'):
leader_space.doc = group.description leader_space.doc = group.description
@ -490,7 +398,7 @@ class SpaceAnnotator(object):
leader_name, leader_name,
) )
leader_space.path = leader_fullname leader_space.path = leader_fullname
return leader_is_hidden
def manage_follower(self, def manage_follower(self,
namespace: str, namespace: str,
@ -499,10 +407,14 @@ class SpaceAnnotator(object):
leader_name: str, leader_name: str,
follower_names: List[str], follower_names: List[str],
leader_space: 'Leadership', leader_space: 'Leadership',
leader_is_hidden: bool,
) -> None: ) -> None:
if variable.name != follower_names[0]: if variable.name != follower_names[0]:
raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0])) raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0]))
follower_names.remove(variable.name) follower_names.remove(variable.name)
if leader_is_hidden:
variable.frozen = True
variable.force_default_on_freeze = True
# followers are multi # followers are multi
if not variable.multi: if not variable.multi:
raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name)) raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name))
@ -538,6 +450,7 @@ class SpaceAnnotator(object):
leader_name, leader_name,
follower_names, follower_names,
leader_space, leader_space,
leader_is_hidden,
) )
ori_leader_family.variable.pop(variable.name) ori_leader_family.variable.pop(variable.name)
if follower_names == []: if follower_names == []:
@ -546,7 +459,7 @@ class SpaceAnnotator(object):
elif variable.name == leader_name: elif variable.name == leader_name:
# it's a leader # it's a leader
leader_space = self.objectspace.Leadership() leader_space = self.objectspace.Leadership()
self.manage_leader(leader_space, leader_is_hidden = self.manage_leader(leader_space,
leader_family_name, leader_family_name,
leader_name, leader_name,
namespace, namespace,
@ -611,7 +524,7 @@ class SpaceAnnotator(object):
variable.mode = modes_level[0] variable.mode = modes_level[0]
# if the variable is mandatory and doesn't have any value # if the variable is mandatory and doesn't have any value
# then the variable's mode is set to 'basic' # then the variable's mode is set to 'basic'
has_value = hasattr(variable, 'value') has_value = hasattr(variable, 'value') and variable.value != None
if (path not in self.has_calc and variable.mandatory is True and if (path not in self.has_calc and variable.mandatory is True and
(not has_value or is_follower) and variable.type != 'choice'): (not has_value or is_follower) and variable.type != 'choice'):
variable.mode = modes_level[0] variable.mode = modes_level[0]
@ -793,81 +706,64 @@ class SpaceAnnotator(object):
path = '{}.{}'.format(family.path, variable.name) path = '{}.{}'.format(family.path, variable.name)
self._annotate_variable(variable, family_mode, path) self._annotate_variable(variable, family_mode, path)
def get_variable(self, name): # pylint: disable=C0111 def convert_fill(self): # pylint: disable=C0111,R0912
return self.paths.get_variable_obj(name) if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'fill'):
return
def convert_autofill(self): # pylint: disable=C0111
if hasattr(self.space, 'constraints'):
self.convert_duplicate_autofill(self.space.constraints)
if 'auto' in vars(self.space.constraints):
self.convert_auto(self.space.constraints.auto, self.space)
if 'fill' in vars(self.space.constraints):
self.convert_fill(self.space.constraints.fill, self.space)
def convert_duplicate_autofill(self, constraints):
""" Remove duplicate auto or fill for a variable
This variable must be redefined
"""
fills = {}
# sort fill/auto by index # sort fill/auto by index
if 'fill' in vars(constraints): fills = {fill.index: fill for idx, fill in enumerate(self.space.constraints.fill)}
for idx, fill in enumerate(constraints.fill):
fills[fill.index] = {'idx': idx, 'fill': fill, 'type': 'fill'}
if 'auto' in vars(constraints):
for idx, fill in enumerate(constraints.auto):
fills[fill.index] = {'idx': idx, 'fill': fill, 'type': 'auto'}
indexes = list(fills.keys()) indexes = list(fills.keys())
indexes.sort() indexes.sort()
targets = {} targets = []
remove_autos = [] eosfunc = dir(self.eosfunc)
remove_fills = []
for idx in indexes: for idx in indexes:
fill = fills[idx]['fill'] fill = fills[idx]
redefine = bool(fill.redefine) # test if it's redefined calculation
if fill.target in targets: if fill.target in targets and not fill.redefine:
if redefine: raise CreoleDictConsistencyError(_(f"A fill already exists for the target: {fill.target}"))
if targets[fill.target][1] == 'auto': targets.append(fill.target)
remove_autos.append(targets[fill.target][0]) #
else: if not fill.name in eosfunc:
remove_fills.append(targets[fill.target][0]) raise CreoleDictConsistencyError(_('cannot find fill function {}').format(fill.name))
else:
raise CreoleDictConsistencyError(_("An auto or fill already exists "
"for the target: {}").format(
fill.target))
targets[fill.target] = (fills[idx]['idx'], fills[idx]['type'])
remove_autos.sort(reverse=True)
for idx in remove_autos:
constraints.auto.pop(idx)
remove_fills.sort(reverse=True)
for idx in remove_fills:
constraints.fill.pop(idx)
def convert_auto(self, auto_space, space): # pylint: disable=C0111 namespace = fill.namespace
for auto in auto_space: # let's replace the target by the path
if HIGH_COMPATIBILITY and auto.target in self.has_frozen_if_in_condition: fill.target = self.paths.get_variable_path(fill.target,
# if a variable has a 'frozen_if_in' condition namespace)
# then we change the 'auto' variable as a 'fill' variable
value = self.objectspace.value()
value.type = 'calculation'
value.name = fill.name
if hasattr(fill, 'param'):
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'))
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}"))
if param.type == 'variable':
try:
param.text, suffix = self.paths.get_variable_path(param.text,
namespace,
with_suffix=True)
if suffix:
param.suffix = suffix
except CreoleDictConsistencyError as err:
if param.optional is False:
raise err
param_to_delete.append(fill_idx)
continue continue
# an auto is a fill with "hidden" and "frozen" properties if param.hidden is True:
variable = self.get_variable(auto.target) param.transitive = False
if variable.auto_freeze: param.hidden = None
raise CreoleDictConsistencyError(_('variable with auto value ' param_to_delete.sort(reverse=True)
'cannot be auto_freeze').format(auto.target)) for param_idx in param_to_delete:
if variable.auto_save: fill.param.pop(param_idx)
raise CreoleDictConsistencyError(_('variable with auto value ' value.param = fill.param
'cannot be auto_save').format(auto.target)) variable = self.paths.get_variable_obj(fill.target)
leader = self.paths.get_leader(auto.target) variable.value = [value]
if leader is None or variable.name != leader: self.force_not_mandatory.append(fill.target)
variable.hidden = True self.has_calc.append(fill.target)
else: del self.space.constraints.fill
leadership = self.paths.get_family_obj(self.paths.get_variable_family_path(auto.target))
leadership.hidden = True
variable.frozen = True
variable.force_default_on_freeze = True
if 'fill' not in vars(space.constraints):
space.constraints.fill = []
space.constraints.fill.extend(auto_space)
del space.constraints.auto
def filter_separators(self): # pylint: disable=C0111,R0201 def filter_separators(self): # pylint: disable=C0111,R0201
# FIXME devrait etre dans la variable # FIXME devrait etre dans la variable
@ -991,7 +887,7 @@ class SpaceAnnotator(object):
for param_idx, param in enumerate(check.param): for param_idx, param in enumerate(check.param):
if hasattr(param, 'name') and param.name == 'checkval': if hasattr(param, 'name') and param.name == 'checkval':
try: try:
proposed_value_type = self.objectspace._convert_boolean(param.text) == False proposed_value_type = self.objectspace.convert_boolean(param.text) == False
remove_params.append(param_idx) remove_params.append(param_idx)
except TypeError as err: except TypeError as err:
raise CreoleDictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err)) raise CreoleDictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err))
@ -1080,97 +976,6 @@ class SpaceAnnotator(object):
variable.check.append(check_) variable.check.append(check_)
del self.space.constraints.check del self.space.constraints.check
def convert_fill(self, fill_space, space): # pylint: disable=C0111,R0912
fills = {}
# sort fill/auto by index
for idx, fill in enumerate(fill_space):
fills[fill.index] = {'idx': idx, 'fill': fill}
del fill.index
indexes = list(fills.keys())
indexes.sort()
del_idx = []
for idx in indexes:
fill = fills[idx]['fill']
variable = self.get_variable(fill.target)
if hasattr(variable, 'value'):
del variable.value
namespace = fill.namespace
# let's replace the target by the path
fill.target = self.paths.get_variable_path(fill.target, namespace)
if not fill.name in dir(self.eosfunc):
raise CreoleDictConsistencyError(_('cannot find fill function {}').format(fill.name))
#is_probe = not fill.name in self.eosfunc.func_on_zephir_context
if hasattr(fill, 'param'):
for param in fill.param:
if param.type not in TYPE_PARAM_FILL:
raise CreoleDictConsistencyError(_('cannot use {} type as a param '
'in a fill/auto').format(param.type))
if param.type == 'eole':
param.type = 'variable'
param_option_indexes = []
for fill_idx, param in enumerate(fill.param):
if not hasattr(param, 'text') and \
(param.type == 'variable' or param.type == 'number' or \
param.type == 'python'):
raise CreoleDictConsistencyError(_("All '{}' variables shall be set in "
"order to calculate {}").format(
param.type,
fill.target))
# if param.type == 'container':
# param.type = 'eole'
# param.text = 'container_ip_{}'.format(param.text)
if param.type == 'variable':
#if is_probe:
# raise CreoleDictConsistencyError(_('Function {0} used to calculate {1} '
# 'is executed on remote server, '
# 'so cannot depends to an '
# 'other variable'
# ).format(fill.name, fill.target))
# if HIGH_COMPATIBILITY and param.text.startswith('container_ip'):
# if param.optional is True:
# param_option_indexes.append(fill_idx)
try:
param.text, suffix = self.paths.get_variable_path(param.text,
namespace,
with_suffix=True)
if suffix:
param.suffix = suffix
except CreoleDictConsistencyError as err:
if param.optional is True:
param_option_indexes.append(fill_idx)
else:
raise err
param_option_indexes = list(set(param_option_indexes))
param_option_indexes.sort(reverse=True)
for param_idx in param_option_indexes:
fill.param.pop(param_idx)
self.has_calc.append(fill.target)
#if is_probe:
# variable.force_default_on_freeze = False
# self.objectspace.probe_variables.append(fill)
# del_idx.append(fills[idx]['idx'])
del_idx.sort(reverse=True)
for idx in del_idx:
space.constraints.fill.pop(idx)
for fill in space.constraints.fill:
variable = self.paths.get_variable_obj(fill.target)
value = self.objectspace.value()
value.type = 'calculation'
value.name = fill.name
if hasattr(fill, 'param'):
for param in fill.param:
if param.hidden is True:
param.transitive = False
param.hidden = None
value.param = fill.param
if not hasattr(variable, 'value'):
variable.value = []
variable.value.append(value)
self.force_not_mandatory.append(fill.target)
del space.constraints.fill
def filter_targets(self): # pylint: disable=C0111 def filter_targets(self): # pylint: disable=C0111
for condition_idx, condition in enumerate(self.space.constraints.condition): for condition_idx, condition in enumerate(self.space.constraints.condition):
namespace = condition.namespace namespace = condition.namespace
@ -1228,15 +1033,14 @@ class SpaceAnnotator(object):
if target.type in ['variable', 'family']: if target.type in ['variable', 'family']:
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
if target.type == 'variable': if target.type == 'variable':
variable = self.get_variable(name) variable = self.paths.get_variable_obj(name)
else: else:
variable = self.paths.get_family_obj(name) variable = self.paths.get_family_obj(name)
if condition.name in ['disabled_if_in']: if condition.name in ['disabled_if_in']:
variable.disabled = True variable.disabled = True
if condition.name in ['mandatory_if_in']: if condition.name in ['mandatory_if_in']:
variable.mandatory = True variable.mandatory = True
if condition.name in ['disabled_if_in', 'disabled_if_not_in', if condition.name in ['frozen_if_in', 'frozen_if_not_in']:
'frozen_if_in', 'frozen_if_not_in']:
variable.hidden = False variable.hidden = False
if HIGH_COMPATIBILITY: if HIGH_COMPATIBILITY:
fallback_variables.append(name) fallback_variables.append(name)
@ -1249,15 +1053,14 @@ class SpaceAnnotator(object):
if listvars: if listvars:
for listvar in listvars: for listvar in listvars:
try: try:
variable = self.get_variable(listvar) variable = self.paths.get_variable_obj(listvar)
except CreoleDictConsistencyError: except CreoleDictConsistencyError:
variable = self.paths.get_family_obj(listvar) variable = self.paths.get_family_obj(listvar)
if condition.name in ['disabled_if_in']: if condition.name in ['disabled_if_in']:
variable.disabled = True variable.disabled = True
if condition.name in ['mandatory_if_in']: if condition.name in ['mandatory_if_in']:
variable.mandatory = True variable.mandatory = True
if condition.name in ['disabled_if_in', 'disabled_if_not_in', if condition.name in ['frozen_if_in', 'frozen_if_not_in']:
'frozen_if_in', 'frozen_if_not_in']:
variable.hidden = False variable.hidden = False
fallback_lists.append(listvar) fallback_lists.append(listvar)
remove_conditions.append(idx) remove_conditions.append(idx)
@ -1283,7 +1086,7 @@ class SpaceAnnotator(object):
if listvar in fallback_lists: if listvar in fallback_lists:
continue continue
try: try:
variable = self.get_variable(listvar) variable = self.paths.get_variable_obj(listvar)
type_ = 'variable' type_ = 'variable'
except CreoleDictConsistencyError: except CreoleDictConsistencyError:
variable = self.paths.get_family_obj(listvar) variable = self.paths.get_family_obj(listvar)
@ -1347,7 +1150,7 @@ class SpaceAnnotator(object):
else: else:
name = target.name name = target.name
if target.type == 'variable': if target.type == 'variable':
variable = self.get_variable(name) variable = self.paths.get_variable_obj(name)
else: else:
variable = self.paths.get_family_obj(name) variable = self.paths.get_family_obj(name)
if condition.name == 'disabled_if_not_in': if condition.name == 'disabled_if_not_in':
@ -1362,8 +1165,6 @@ class SpaceAnnotator(object):
variable.mandatory = True variable.mandatory = True
force_remove_targets.setdefault(condition.name, force_remove_targets.setdefault(condition.name,
[]).append(target.name) []).append(target.name)
elif HIGH_COMPATIBILITY and condition.name == 'disabled_if_in':
variable.hidden = False
remove_conditions.append(condition_idx) remove_conditions.append(condition_idx)
remove_conditions = list(set(remove_conditions)) remove_conditions = list(set(remove_conditions))
remove_conditions.sort(reverse=True) remove_conditions.sort(reverse=True)
@ -1382,14 +1183,13 @@ class SpaceAnnotator(object):
else: else:
name = target.name name = target.name
if target.type == 'variable': if target.type == 'variable':
variable = self.get_variable(name) variable = self.paths.get_variable_obj(name)
else: else:
variable = self.paths.get_family_obj(name) variable = self.paths.get_family_obj(name)
if name in fallback_variables: if name in fallback_variables:
remove_targets.append(target_idx) remove_targets.append(target_idx)
continue continue
if condition.name in ['disabled_if_in', 'disabled_if_not_in', if condition.name in ['frozen_if_in', 'frozen_if_not_in']:
'frozen_if_in', 'frozen_if_not_in']:
variable.hidden = False variable.hidden = False
if condition.name in ['mandatory_if_in', 'mandatory_if_not_in']: if condition.name in ['mandatory_if_in', 'mandatory_if_not_in']:
variable.mandatory = False variable.mandatory = False
@ -1463,7 +1263,7 @@ class SpaceAnnotator(object):
else: else:
name = target.name name = target.name
if target.type == 'variable': if target.type == 'variable':
variable = self.get_variable(name) variable = self.paths.get_variable_obj(name)
else: else:
variable = self.paths.get_family_obj(name) variable = self.paths.get_family_obj(name)
if not hasattr(variable, 'property'): if not hasattr(variable, 'property'):

View File

@ -37,17 +37,12 @@
<!-- root element --> <!-- root element -->
<!-- =============== --> <!-- =============== -->
<!ELEMENT rougail (services | family_action | variables | constraints | help)*> <!ELEMENT rougail (services | variables | constraints | help)*>
<!-- ============== --> <!-- ============== -->
<!-- files element --> <!-- files element -->
<!-- ============== --> <!-- ============== -->
<!ELEMENT family_action (action)>
<!ATTLIST family_action name CDATA #REQUIRED>
<!ATTLIST family_action description CDATA #IMPLIED>
<!ATTLIST family_action color CDATA #IMPLIED>
<!ATTLIST family_action image CDATA #IMPLIED>
<!ELEMENT action ((input* | profile* | ewtapp* | tag* | saltaction*)*)> <!ELEMENT action ((input* | profile* | ewtapp* | tag* | saltaction*)*)>
<!ATTLIST action type (form|custom|external|reader|apache) "custom"> <!ATTLIST action type (form|custom|external|reader|apache) "custom">
<!ATTLIST action title CDATA #REQUIRED> <!ATTLIST action title CDATA #REQUIRED>
@ -81,10 +76,6 @@
<!ATTLIST port portlist CDATA #IMPLIED > <!ATTLIST port portlist CDATA #IMPLIED >
<!ATTLIST port protocol (tcp|udp) "tcp"> <!ATTLIST port protocol (tcp|udp) "tcp">
<!ELEMENT tcpwrapper (#PCDATA)>
<!ATTLIST tcpwrapper tcpwrapper_type (UnicodeOption|SymLinkOption|variable) "UnicodeOption">
<!ATTLIST tcpwrapper tcpwrapperlist CDATA #IMPLIED >
<!ELEMENT ip (#PCDATA)> <!ELEMENT ip (#PCDATA)>
<!ATTLIST ip iplist CDATA #IMPLIED > <!ATTLIST ip iplist CDATA #IMPLIED >
<!ATTLIST ip ip_type (NetworkOption|SymLinkOption|variable) "NetworkOption"> <!ATTLIST ip ip_type (NetworkOption|SymLinkOption|variable) "NetworkOption">
@ -93,9 +84,6 @@
<!ATTLIST ip netmask_type (NetmaskOption|SymLinkOption|variable) "NetmaskOption"> <!ATTLIST ip netmask_type (NetmaskOption|SymLinkOption|variable) "NetmaskOption">
<!ATTLIST ip netmask CDATA "255.255.255.255"> <!ATTLIST ip netmask CDATA "255.255.255.255">
<!ELEMENT package (#PCDATA)>
<!ATTLIST package packagelist CDATA #IMPLIED >
<!ELEMENT file EMPTY> <!ELEMENT file EMPTY>
<!ATTLIST file name CDATA #REQUIRED > <!ATTLIST file name CDATA #REQUIRED >
<!ATTLIST file file_type (UnicodeOption|SymLinkOption|variable) "UnicodeOption"> <!ATTLIST file file_type (UnicodeOption|SymLinkOption|variable) "UnicodeOption">
@ -106,8 +94,6 @@
<!ATTLIST file owner CDATA "root"> <!ATTLIST file owner CDATA "root">
<!ATTLIST file group CDATA "root"> <!ATTLIST file group CDATA "root">
<!ATTLIST file filelist CDATA #IMPLIED > <!ATTLIST file filelist CDATA #IMPLIED >
<!ATTLIST file mkdir (True|False) "False">
<!ATTLIST file rm (True|False) "False">
<!ATTLIST file redefine (True|False) "False"> <!ATTLIST file redefine (True|False) "False">
<!ATTLIST file templating (True|False) "True"> <!ATTLIST file templating (True|False) "True">
@ -158,7 +144,7 @@
<!ELEMENT value (#PCDATA)> <!ELEMENT value (#PCDATA)>
<!ELEMENT constraints ((fill* | check* | condition* | auto* | group*)*)> <!ELEMENT constraints ((fill* | check* | condition* | group*)*)>
<!ELEMENT fill (param*)> <!ELEMENT fill (param*)>
<!ATTLIST fill name CDATA #REQUIRED> <!ATTLIST fill name CDATA #REQUIRED>
<!ATTLIST fill target CDATA #REQUIRED> <!ATTLIST fill target CDATA #REQUIRED>
@ -168,10 +154,6 @@
<!ATTLIST check target CDATA #REQUIRED> <!ATTLIST check target CDATA #REQUIRED>
<!ATTLIST check level (error|warning) "error"> <!ATTLIST check level (error|warning) "error">
<!ELEMENT auto ((param)*)>
<!ATTLIST auto name CDATA #REQUIRED>
<!ATTLIST auto target CDATA #REQUIRED>
<!ELEMENT condition ((target | param)+ )> <!ELEMENT condition ((target | param)+ )>
<!ATTLIST condition name CDATA #REQUIRED> <!ATTLIST condition name CDATA #REQUIRED>
<!ATTLIST condition source CDATA #REQUIRED> <!ATTLIST condition source CDATA #REQUIRED>

View File

@ -25,17 +25,16 @@ has to be moved in family2. The visit procedure changes the varable1's object sp
""" """
from collections import OrderedDict from collections import OrderedDict
from lxml.etree import Element, SubElement # pylint: disable=E0611 from lxml.etree import Element, SubElement # pylint: disable=E0611
from json import dump
from .i18n import _ from .i18n import _
from .xmlreflector import XMLReflector, HIGH_COMPATIBILITY from .xmlreflector import XMLReflector, HIGH_COMPATIBILITY
from .annotator import ERASED_ATTRIBUTES, ActionAnnotator, ServiceAnnotator, SpaceAnnotator from .annotator import ERASED_ATTRIBUTES, ServiceAnnotator, SpaceAnnotator
from .utils import normalize_family from .utils import normalize_family
from .error import CreoleOperationError, SpaceObjShallNotBeUpdated, CreoleDictConsistencyError from .error import CreoleOperationError, SpaceObjShallNotBeUpdated, CreoleDictConsistencyError
from .path import Path
# CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type # CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type
FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables', 'family_action') FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables')
# CreoleObjSpace's elements that shall be forced to the UnRedefinable type # CreoleObjSpace's elements that shall be forced to the UnRedefinable type
FORCE_UNREDEFINABLES = ('value', 'input', 'profile', 'ewtapp', 'tag', 'saltaction') FORCE_UNREDEFINABLES = ('value', 'input', 'profile', 'ewtapp', 'tag', 'saltaction')
# CreoleObjSpace's elements that shall be set to the UnRedefinable type # CreoleObjSpace's elements that shall be set to the UnRedefinable type
@ -48,16 +47,17 @@ CONVERT_PROPERTIES = {'auto_save': ['force_store_value'], 'auto_freeze': ['force
RENAME_ATTIBUTES = {'description': 'doc'} RENAME_ATTIBUTES = {'description': 'doc'}
INCOMPATIBLE_ATTRIBUTES = [['multi', 'submulti']] INCOMPATIBLE_ATTRIBUTES = [['multi', 'submulti']]
FORCED_TEXT_ELTS_AS_NAME = ('choice', 'property')
#TYPE_TARGET_CONDITION = ('variable', 'family') #TYPE_TARGET_CONDITION = ('variable', 'family')
# _____________________________________________________________________________ # _____________________________________________________________________________
# special types definitions for the Object Space's internal representation # special types definitions for the Object Space's internal representation
class RootCreoleObject(object): class RootCreoleObject:
"" ""
class CreoleObjSpace(object): class CreoleObjSpace:
"""DOM XML reflexion free internal representation of a Creole Dictionary """DOM XML reflexion free internal representation of a Creole Dictionary
""" """
choice = type('Choice', (RootCreoleObject,), OrderedDict()) choice = type('Choice', (RootCreoleObject,), OrderedDict())
@ -78,80 +78,258 @@ class CreoleObjSpace(object):
def __init__(self, dtdfilename): # pylint: disable=R0912 def __init__(self, dtdfilename): # pylint: disable=R0912
self.index = 0 self.index = 0
class ObjSpace(object): # pylint: disable=R0903 class ObjSpace: # pylint: disable=R0903
""" """
Base object space Base object space
""" """
self.space = ObjSpace() self.space = ObjSpace()
self.paths = Path()
self.xmlreflector = XMLReflector() self.xmlreflector = XMLReflector()
self.xmlreflector.parse_dtd(dtdfilename) self.xmlreflector.parse_dtd(dtdfilename)
self.redefine_variables = None self.redefine_variables = None
self.probe_variables = []
# ['variable', 'separator', 'family'] # ['variable', 'separator', 'family']
self.forced_text_elts = set() self.forced_text_elts = set()
self.forced_text_elts_as_name = set(['choice', 'property']) self.forced_text_elts_as_name = set(FORCED_TEXT_ELTS_AS_NAME)
self.forced_choice_option = {}
self.paths = Path()
self.list_conditions = {} self.list_conditions = {}
self.booleans_attributs = [] self.booleans_attributs = []
for elt in self.xmlreflector.dtd.iterelements(): self.make_object_space_class()
def make_object_space_class(self):
"""Create Rougail ObjectSpace class types, it enables us to create objects like:
File(), Variable(), Ip(), Family(), Constraints()... and so on.
Creole ObjectSpace is an object's reflexion of the XML elements"""
for dtd_elt in self.xmlreflector.dtd.iterelements():
attrs = {} attrs = {}
clstype = self.UnRedefinable if dtd_elt.name in FORCE_REDEFINABLES:
atomic = True
forced_text_elt = False
if elt.type == 'mixed':
forced_text_elt = True
if elt.name == 'service':
self.parse_dtd_right_left_elt(elt.content)
for attr in elt.iterattributes():
atomic = False
if attr.default_value:
if attr.default_value == 'True':
default_value = True
elif attr.default_value == 'False':
default_value = False
else:
default_value = attr.default_value
attrs[attr.name] = default_value
if not attr.name.endswith('_type'):
values = list(attr.itervalues())
if values != []:
self.forced_choice_option.setdefault(elt.name, {})[attr.name] = values
if attr.name == 'redefine':
clstype = self.Redefinable clstype = self.Redefinable
if attr.name == 'name' and forced_text_elt is True: else:
self.forced_text_elts.add(elt.name) clstype = self.UnRedefinable
atomic = dtd_elt.name not in FORCE_UNREDEFINABLES and dtd_elt.name not in FORCE_REDEFINABLES
forced_text_elt = dtd_elt.type == 'mixed'
for dtd_attr in dtd_elt.iterattributes():
atomic = False
if set(dtd_attr.itervalues()) == set(['True', 'False']):
# it's a boolean
self.booleans_attributs.append(dtd_attr.name)
if dtd_attr.default_value:
# set default value for this attribute
default_value = dtd_attr.default_value
if dtd_attr.name in self.booleans_attributs:
default_value = self.convert_boolean(dtd_attr.default_value)
attrs[dtd_attr.name] = default_value
if dtd_attr.name == 'redefine':
# has a redefine attribute, so it's a Redefinable object
clstype = self.Redefinable
if dtd_attr.name == 'name' and forced_text_elt:
# child.text should be transform has a "name" attribute
self.forced_text_elts.add(dtd_elt.name)
forced_text_elt = False forced_text_elt = False
if set(attr.itervalues()) == set(['True', 'False']):
self.booleans_attributs.append(attr.name)
if forced_text_elt is True: if forced_text_elt is True:
self.forced_text_elts_as_name.add(elt.name) self.forced_text_elts_as_name.add(dtd_elt.name)
if atomic:
if elt.name in FORCE_REDEFINABLES: # has any attribute so it's an Atomic object
clstype = self.Redefinable
elif elt.name in FORCE_UNREDEFINABLES:
clstype = self.UnRedefinable
elif atomic:
clstype = self.Atom clstype = self.Atom
# Creole ObjectSpace class types, it enables us to create objects like: # create ObjectSpace object
# Service_restriction(), Ip(), Interface(), Host(), Fstab(), Package(), Disknod(), setattr(self, dtd_elt.name, type(dtd_elt.name.capitalize(), (clstype,), attrs))
# File(), Variables(), Family(), Variable(), Separators(), Separator(), Value(),
# Constraints()... and so on. Creole ObjectSpace is an object's reflexion of
# the XML elements
setattr(self, elt.name, type(elt.name.capitalize(), (clstype,), attrs))
def parse_dtd_right_left_elt(self, elt): def create_or_populate_from_xml(self,
if elt.right.type == 'or': namespace,
self.parse_dtd_right_left_elt(elt.right) xmlfolders):
"""Parses a bunch of XML files
populates the CreoleObjSpace
"""
for xmlfile, document in self.xmlreflector.load_xml_from_folders(xmlfolders):
self.redefine_variables = []
self.xml_parse_document(document,
self.space,
namespace,
)
def _convert_boolean(self, value): # pylint: disable=R0201 def xml_parse_document(self,
document,
space,
namespace,
):
"""Parses a Creole XML file
populates the CreoleObjSpace
"""
family_names = []
for child in document:
# this index enables us to reorder objects
self.index += 1
# doesn't proceed the XML commentaries
if not isinstance(child.tag, str):
continue
if child.tag == 'family':
if child.attrib['name'] in family_names:
raise CreoleDictConsistencyError(_('Family {} is set several times').format(child.attrib['name']))
family_names.append(child.attrib['name'])
if child.tag == 'variables':
child.attrib['name'] = namespace
if HIGH_COMPATIBILITY and child.tag == 'value' and child.text == None:
# FIXME should not be here
continue
# creole objects creation
try:
creoleobj = self.generate_creoleobj(child,
space,
namespace,
)
except SpaceObjShallNotBeUpdated:
continue
self.set_text_to_obj(child,
creoleobj,
)
self.set_xml_attributes_to_obj(child,
creoleobj,
)
self.creoleobj_tree_visitor(child,
creoleobj,
namespace,
)
self.fill_creoleobj_path_attribute(space,
child,
namespace,
document,
creoleobj,
)
self.add_to_tree_structure(creoleobj,
space,
child,
)
if list(child) != []:
self.xml_parse_document(child,
creoleobj,
namespace,
)
def generate_creoleobj(self,
child,
space,
namespace,
):
"""
instanciates or creates Creole Object Subspace objects
"""
creoleobj = getattr(self, child.tag)()
if isinstance(creoleobj, self.Redefinable):
creoleobj = self.create_or_update_redefinable_object(child.attrib,
space,
child,
namespace,
)
elif isinstance(creoleobj, self.Atom) and child.tag in vars(space):
# instanciates an object from the CreoleObjSpace's builtins types
# example : child.tag = constraints -> a self.Constraints() object is created
# this Atom instance has to be a singleton here
# we do not re-create it, we reuse it
creoleobj = getattr(space, child.tag)
self.create_tree_structure(space,
child,
creoleobj,
)
return creoleobj
def create_or_update_redefinable_object(self,
subspace,
space,
child,
namespace,
):
"""Creates or retrieves the space object that corresponds
to the `child` XML object
Two attributes of the `child` XML object are important:
- with the `redefine` boolean flag attribute we know whether
the corresponding space object shall be created or updated
- `True` means that the corresponding space object shall be updated
- `False` means that the corresponding space object shall be created
- with the `exists` boolean flag attribute we know whether
the corresponding space object shall be created
(or nothing -- that is the space object isn't modified)
- `True` means that the corresponding space object shall be created
- `False` means that the corresponding space object is not updated
In the special case `redefine` is True and `exists` is False,
we create the corresponding space object if it doesn't exist
and we update it if it exists.
:return: the corresponding space object of the `child` XML object
"""
if child.tag in self.forced_text_elts_as_name:
name = child.text
else:
name = subspace['name']
if self.is_already_exists(name,
space,
child,
namespace,
):
default_redefine = child.tag in FORCE_REDEFINABLES
redefine = self.convert_boolean(subspace.get('redefine', default_redefine))
exists = self.convert_boolean(subspace.get('exists', True))
if redefine is True:
return self.translate_in_space(name,
space,
child,
namespace,
)
elif exists is False:
raise SpaceObjShallNotBeUpdated()
raise CreoleDictConsistencyError(_(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'))
def create_tree_structure(self,
space,
child,
creoleobj,
): # pylint: disable=R0201
"""
Builds the tree structure of the object space here
we set services attributes in order to be populated later on
for example::
space = Family()
space.variable = OrderedDict()
another example:
space = Variable()
space.value = list()
"""
if child.tag not in vars(space):
if isinstance(creoleobj, self.Redefinable):
setattr(space, child.tag, OrderedDict())
elif isinstance(creoleobj, self.UnRedefinable):
setattr(space, child.tag, [])
elif not isinstance(creoleobj, self.Atom): # pragma: no cover
raise CreoleOperationError(_("Creole object {} "
"has a wrong type").format(type(creoleobj)))
def is_already_exists(self, name, space, child, namespace):
if isinstance(space, self.family): # pylint: disable=E1101
if namespace != 'creole':
name = space.path + '.' + name
return self.paths.path_is_defined(name)
if child.tag == 'family':
norm_name = normalize_family(name)
else:
norm_name = name
return norm_name in getattr(space, child.tag, {})
def convert_boolean(self, value): # pylint: disable=R0201
"""Boolean coercion. The Creole XML may contain srings like `True` or `False` """Boolean coercion. The Creole XML may contain srings like `True` or `False`
""" """
if isinstance(value, bool): if isinstance(value, bool):
@ -163,20 +341,14 @@ class CreoleObjSpace(object):
else: else:
raise TypeError(_('{} is not True or False').format(value)) # pragma: no cover raise TypeError(_('{} is not True or False').format(value)) # pragma: no cover
def _is_already_exists(self, name, space, child, namespace): def translate_in_space(self,
if isinstance(space, self.family): # pylint: disable=E1101 name,
if namespace != 'creole': family,
name = space.path + '.' + name variable,
return self.paths.path_is_defined(name) namespace,
if child.tag in ['family', 'family_action']: ):
norm_name = normalize_family(name)
else:
norm_name = name
return norm_name in getattr(space, child.tag, {})
def _translate_in_space(self, name, family, variable, namespace):
if not isinstance(family, self.family): # pylint: disable=E1101 if not isinstance(family, self.family): # pylint: disable=E1101
if variable.tag in ['family', 'family_action']: if variable.tag == 'family':
norm_name = normalize_family(name) norm_name = normalize_family(name)
else: else:
norm_name = name norm_name = name
@ -213,6 +385,7 @@ class CreoleObjSpace(object):
remove_checks.sort(reverse=True) remove_checks.sort(reverse=True)
for idx in remove_checks: for idx in remove_checks:
self.space.constraints.check.pop(idx) # pylint: disable=E1101 self.space.constraints.check.pop(idx) # pylint: disable=E1101
def remove_condition(self, name): # pylint: disable=C0111 def remove_condition(self, name): # pylint: disable=C0111
for idx, condition in enumerate(self.space.constraints.condition): # pylint: disable=E1101 for idx, condition in enumerate(self.space.constraints.condition): # pylint: disable=E1101
remove_targets = [] remove_targets = []
@ -225,101 +398,14 @@ class CreoleObjSpace(object):
for idx in remove_targets: for idx in remove_targets:
del condition.target[idx] del condition.target[idx]
def create_or_update_space_object(self, subspace, space, child, namespace): def add_to_tree_structure(self,
"""Creates or retrieves the space object that corresponds creoleobj,
to the `child` XML object space,
child,
Two attributes of the `child` XML object are important: ): # pylint: disable=R0201
- with the `redefine` boolean flag attribute we know whether
the corresponding space object shall be created or updated
- `True` means that the corresponding space object shall be updated
- `False` means that the corresponding space object shall be created
- with the `exists` boolean flag attribute we know whether
the corresponding space object shall be created
(or nothing -- that is the space object isn't modified)
- `True` means that the corresponding space object shall be created
- `False` means that the corresponding space object is not updated
In the special case `redefine` is True and `exists` is False,
we create the corresponding space object if it doesn't exist
and we update it if it exists.
:return: the corresponding space object of the `child` XML object
"""
if child.tag in self.forced_text_elts_as_name:
name = child.text
else:
name = subspace['name']
if self._is_already_exists(name, space, child, namespace):
if child.tag in FORCE_REDEFINABLES:
redefine = self._convert_boolean(subspace.get('redefine', True))
else:
redefine = self._convert_boolean(subspace.get('redefine', False))
exists = self._convert_boolean(subspace.get('exists', True))
if redefine is True:
return self._translate_in_space(name, space, child, namespace)
elif exists is False:
raise SpaceObjShallNotBeUpdated()
else:
raise CreoleDictConsistencyError(_('Already present in another XML file, {} '
'cannot be re-created').format(name))
else:
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)()
else:
raise CreoleDictConsistencyError(_('Redefined object: '
'{} does not exist yet').format(name))
def generate_creoleobj(self, child, space, namespace):
"""
instanciates or creates Creole Object Subspace objects
"""
if issubclass(getattr(self, child.tag), self.Redefinable):
creoleobj = self.create_or_update_space_object(child.attrib, space, child, namespace)
else:
# instanciates an object from the CreoleObjSpace's builtins types
# example : child.tag = constraints -> a self.Constraints() object is created
creoleobj = getattr(self, child.tag)()
# this Atom instance has to be a singleton here
# we do not re-create it, we reuse it
if isinstance(creoleobj, self.Atom) and child.tag in vars(space):
creoleobj = getattr(space, child.tag)
self.create_tree_structure(space, child, creoleobj)
return creoleobj
def create_tree_structure(self, space, child, creoleobj): # pylint: disable=R0201
"""
Builds the tree structure of the object space here
we set services attributes in order to be populated later on
for example::
space = Family()
space.variable = OrderedDict()
another example:
space = Variable()
space.value = list()
"""
if child.tag not in vars(space):
if isinstance(creoleobj, self.Redefinable):
setattr(space, child.tag, OrderedDict())
elif isinstance(creoleobj, self.UnRedefinable):
setattr(space, child.tag, [])
elif isinstance(creoleobj, self.Atom):
pass
else: # pragma: no cover
raise CreoleOperationError(_("Creole object {} "
"has a wrong type").format(type(creoleobj)))
def _add_to_tree_structure(self, creoleobj, space, child): # pylint: disable=R0201
if isinstance(creoleobj, self.Redefinable): if isinstance(creoleobj, self.Redefinable):
name = creoleobj.name name = creoleobj.name
if child.tag == 'family' or child.tag == 'family_action': if child.tag == 'family':
name = normalize_family(name) name = normalize_family(name)
getattr(space, child.tag)[name] = creoleobj getattr(space, child.tag)[name] = creoleobj
elif isinstance(creoleobj, self.UnRedefinable): elif isinstance(creoleobj, self.UnRedefinable):
@ -327,7 +413,10 @@ class CreoleObjSpace(object):
else: else:
setattr(space, child.tag, creoleobj) setattr(space, child.tag, creoleobj)
def _set_text_to_obj(self, child, creoleobj): def set_text_to_obj(self,
child,
creoleobj,
):
if child.text is None: if child.text is None:
text = None text = None
else: else:
@ -338,28 +427,24 @@ class CreoleObjSpace(object):
else: else:
creoleobj.text = text creoleobj.text = text
def _set_xml_attributes_to_obj(self, child, creoleobj): def set_xml_attributes_to_obj(self,
redefine = self._convert_boolean(child.attrib.get('redefine', False)) child,
creoleobj,
):
redefine = self.convert_boolean(child.attrib.get('redefine', False))
has_value = hasattr(creoleobj, 'value') has_value = hasattr(creoleobj, 'value')
if HIGH_COMPATIBILITY and has_value: if HIGH_COMPATIBILITY and has_value:
has_value = len(child) != 1 or child[0].text != None has_value = len(child) != 1 or child[0].text != None
if (redefine is True and child.tag == 'variable' and has_value if redefine is True and child.tag == 'variable' and has_value and len(child) != 0:
and len(child) != 0):
del creoleobj.value del creoleobj.value
for attr, val in child.attrib.items(): for attr, val in child.attrib.items():
if redefine and attr in UNREDEFINABLE: if redefine and attr in UNREDEFINABLE:
# UNREDEFINABLE concerns only 'variable' node so we can fix name # UNREDEFINABLE concerns only 'variable' node so we can fix name
# to child.attrib['name'] # to child.attrib['name']
name = child.attrib['name'] name = child.attrib['name']
raise CreoleDictConsistencyError(_("cannot redefine attribute {} for variable {}").format(attr, name)) raise CreoleDictConsistencyError(_(f'cannot redefine attribute {attr} for variable {name}'))
if isinstance(getattr(creoleobj, attr, None), bool): if attr in self.booleans_attributs:
if val == 'False': val = self.convert_boolean(val)
val = False
elif val == 'True':
val = True
else: # pragma: no cover
raise CreoleOperationError(_('value for {} must be True or False, '
'not {}').format(attr, val))
if not (attr == 'name' and getattr(creoleobj, 'name', None) != None): if not (attr == 'name' and getattr(creoleobj, 'name', None) != None):
setattr(creoleobj, attr, val) setattr(creoleobj, attr, val)
keys = list(vars(creoleobj).keys()) keys = list(vars(creoleobj).keys())
@ -371,60 +456,28 @@ class CreoleObjSpace(object):
raise CreoleDictConsistencyError(_('those attributes are incompatible {}').format(incompatible)) raise CreoleDictConsistencyError(_('those attributes are incompatible {}').format(incompatible))
found = True found = True
def creoleobj_tree_visitor(self,
def _creoleobj_tree_visitor(self, child, creoleobj, namespace): child,
creoleobj,
namespace,
):
"""Creole object tree manipulations """Creole object tree manipulations
""" """
if child.tag == 'variable' and child.attrib.get('remove_check', False): if child.tag == 'variable':
if child.attrib.get('remove_check', False):
self.remove_check(creoleobj.name) self.remove_check(creoleobj.name)
if child.tag == 'variable' and child.attrib.get('remove_condition', False): if child.attrib.get('remove_condition', False):
self.remove_condition(creoleobj.name) self.remove_condition(creoleobj.name)
if child.tag in ['auto', 'fill', 'check']: if child.tag in ['fill', 'check']:
variable_name = child.attrib['target'] # if variable is a redefine in current dictionary
# XXX not working with variable not in creole and in leader/followers # XXX not working with variable not in creole and in leader/followers
if variable_name in self.redefine_variables: creoleobj.redefine = child.attrib['target'] in self.redefine_variables
creoleobj.redefine = True
else:
creoleobj.redefine = False
if not hasattr(creoleobj, 'index'): if not hasattr(creoleobj, 'index'):
creoleobj.index = self.index creoleobj.index = self.index
if child.tag in ['auto', 'fill', 'condition', 'check', 'action']: if child.tag in ['fill', 'condition', 'check', 'action']:
creoleobj.namespace = namespace creoleobj.namespace = namespace
def xml_parse_document(self, document, space, namespace, is_in_family=False): def fill_creoleobj_path_attribute(self,
"""Parses a Creole XML file
populates the CreoleObjSpace
"""
family_names = []
for child in document:
# this index enables us to reorder the 'fill' and 'auto' objects
self.index += 1
# doesn't proceed the XML commentaries
if not isinstance(child.tag, str):
continue
if child.tag == 'family':
is_in_family = True
if child.attrib['name'] in family_names:
raise CreoleDictConsistencyError(_('Family {} is set several times').format(child.attrib['name']))
family_names.append(child.attrib['name'])
if child.tag == 'variables':
child.attrib['name'] = namespace
if HIGH_COMPATIBILITY and child.tag == 'value' and child.text == None:
continue
# creole objects creation
try:
creoleobj = self.generate_creoleobj(child, space, namespace)
except SpaceObjShallNotBeUpdated:
continue
self._set_text_to_obj(child, creoleobj)
self._set_xml_attributes_to_obj(child, creoleobj)
self._creoleobj_tree_visitor(child, creoleobj, namespace)
self._fill_creoleobj_path_attribute(space, child, namespace, document, creoleobj)
self._add_to_tree_structure(creoleobj, space, child)
if list(child) != []:
self.xml_parse_document(child, creoleobj, namespace, is_in_family)
def _fill_creoleobj_path_attribute(self,
space, space,
child, child,
namespace, namespace,
@ -433,7 +486,8 @@ class CreoleObjSpace(object):
): # pylint: disable=R0913 ): # pylint: disable=R0913
"""Fill self.paths attributes """Fill self.paths attributes
""" """
if not isinstance(space, self.help): # pylint: disable=E1101 if isinstance(space, self.help): # pylint: disable=E1101
return
if child.tag == 'variable': if child.tag == 'variable':
family_name = normalize_family(document.attrib['name']) family_name = normalize_family(document.attrib['name'])
self.paths.add_variable(namespace, self.paths.add_variable(namespace,
@ -448,7 +502,7 @@ class CreoleObjSpace(object):
self.redefine_variables.append(namespace + '.' + family_name + '.' + self.redefine_variables.append(namespace + '.' + family_name + '.' +
child.attrib['name']) child.attrib['name'])
if child.tag == 'family': elif child.tag == 'family':
family_name = normalize_family(child.attrib['name']) family_name = normalize_family(child.attrib['name'])
if namespace != 'creole': if namespace != 'creole':
family_name = namespace + '.' + family_name family_name = namespace + '.' + family_name
@ -458,26 +512,7 @@ class CreoleObjSpace(object):
) )
creoleobj.path = self.paths.get_family_path(family_name, namespace) creoleobj.path = self.paths.get_family_path(family_name, namespace)
def create_or_populate_from_xml(self, namespace, xmlfolders, from_zephir=None):
"""Parses a bunch of XML files
populates the CreoleObjSpace
"""
documents = self.xmlreflector.load_xml_from_folders(xmlfolders, from_zephir)
for xmlfile, document in documents:
try:
self.redefine_variables = []
self.xml_parse_document(document, self.space, namespace)
except Exception as err:
#print(_('error in XML file {}').format(xmlfile))
raise err
def populate_from_zephir(self, namespace, xmlfile):
self.redefine_variables = []
document = self.xmlreflector.parse_xmlfile(xmlfile, from_zephir=True, zephir2=True)
self.xml_parse_document(document, self.space, namespace)
def space_visitor(self, eosfunc_file): # pylint: disable=C0111 def space_visitor(self, eosfunc_file): # pylint: disable=C0111
ActionAnnotator(self)
ServiceAnnotator(self) ServiceAnnotator(self)
SpaceAnnotator(self, eosfunc_file) SpaceAnnotator(self, eosfunc_file)
@ -486,42 +521,13 @@ class CreoleObjSpace(object):
:param filename: the full XML filename :param filename: the full XML filename
""" """
xml = Element('creole') xml = Element('rougail')
self._xml_export(xml, self.space) self._xml_export(xml, self.space)
if not force_no_save: if not force_no_save:
self.xmlreflector.save_xmlfile(filename, xml) self.xmlreflector.save_xmlfile(filename, xml)
return xml return xml
def save_probes(self, filename, force_no_save=False): def get_attributes(self, space): # pylint: disable=R0201
"""Save an XML output on disk
:param filename: the full XML filename
"""
ret = {}
for variable in self.probe_variables:
args = []
kwargs = {}
if hasattr(variable, 'param'):
for param in variable.param:
list_param = list(vars(param).keys())
if 'index' in list_param:
list_param.remove('index')
if list_param == ['text']:
args.append(param.text)
elif list_param == ['text', 'name']:
kwargs[param.name] = param.text
else:
print(vars(param))
raise Exception('hu?')
ret[variable.target] = {'function': variable.name,
'args': args,
'kwargs': kwargs}
if not force_no_save:
with open(filename, 'w') as fhj:
dump(ret, fhj)
return ret
def _get_attributes(self, space): # pylint: disable=R0201
for attr in dir(space): for attr in dir(space):
if not attr.startswith('_'): if not attr.startswith('_'):
yield attr yield attr
@ -549,13 +555,13 @@ class CreoleObjSpace(object):
child_node.attrib['name'] = name child_node.attrib['name'] = name
else: else:
child_node = SubElement(node, name) child_node = SubElement(node, name)
for subname in self._get_attributes(space): for subname in self.get_attributes(space):
subspace = getattr(space, subname) subspace = getattr(space, subname)
self._sub_xml_export(subname, child_node, name, subspace, space) self._sub_xml_export(subname, child_node, name, subspace, space)
elif isinstance(space, self.Redefinable): elif isinstance(space, self.Redefinable):
child_node = SubElement(node, 'family') child_node = SubElement(node, 'family')
child_node.attrib['name'] = name child_node.attrib['name'] = name
for subname in self._get_attributes(space): for subname in self.get_attributes(space):
subspace = getattr(space, subname) subspace = getattr(space, subname)
self._sub_xml_export(subname, child_node, name, subspace, space) self._sub_xml_export(subname, child_node, name, subspace, space)
else: else:
@ -587,192 +593,6 @@ class CreoleObjSpace(object):
node.attrib[name] = str(space) node.attrib[name] = str(space)
def _xml_export(self, node, space, node_name='creole'): def _xml_export(self, node, space, node_name='creole'):
for name in self._get_attributes(space): for name in self.get_attributes(space):
subspace = getattr(space, name) subspace = getattr(space, name)
self._sub_xml_export(name, node, node_name, subspace, space) self._sub_xml_export(name, node, node_name, subspace, space)
class Path:
"""Helper class to handle the `path` attribute of a CreoleObjSpace
instance.
sample: path="creole.general.condition"
"""
def __init__(self):
self.variables = {}
self.families = {}
# Family
def add_family(self,
namespace: str,
name: str,
creoleobj: str,
) -> str: # pylint: disable=C0111
self.families[name] = dict(name=name,
namespace=namespace,
creoleobj=creoleobj,
)
def get_family_path(self,
name: str,
current_namespace: str,
) -> str: # pylint: disable=C0111
if current_namespace is None: # pragma: no cover
raise CreoleOperationError('current_namespace must not be None')
dico = self.families[normalize_family(name,
check_name=False,
allow_dot=True,
)]
if dico['namespace'] != 'creole' and current_namespace != dico['namespace']:
raise CreoleDictConsistencyError(_('A family located in the {} namespace '
'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace))
path = dico['name']
if dico['namespace'] is not None and '.' not in dico['name']:
path = '.'.join([dico['namespace'], path])
return path
def get_family_namespace(self,
name: str,
) -> str: # pylint: disable=C0111
dico = self.families[name]
if dico['namespace'] is None:
return dico['name']
return dico['namespace']
def get_family_obj(self,
name: str,
) -> 'Family': # pylint: disable=C0111
if name not in self.families:
raise CreoleDictConsistencyError(_('unknown family {}').format(name))
dico = self.families[name]
return dico['creoleobj']
# Leadership
def set_leader(self,
namespace: str,
leader_family_name: str,
name: str,
leader_name: str,
) -> None: # pylint: disable=C0111
if namespace != 'creole':
# need rebuild path and move object in new path
old_path = namespace + '.' + leader_family_name + '.' + name
dico = self._get_variable(old_path)
del self.variables[old_path]
new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name
self.add_variable(namespace,
new_path,
dico['family'],
False,
dico['creoleobj'],
)
name = new_path
dico = self._get_variable(name)
if dico['leader'] != None:
raise CreoleDictConsistencyError(_('Already defined leader {} for variable'
' {}'.format(dico['leader'], name)))
dico['leader'] = leader_name
def get_leader(self, name): # pylint: disable=C0111
return self._get_variable(name)['leader']
# Variable
def add_variable(self,
namespace: str,
name: str,
family: str,
is_dynamic: bool,
creoleobj,
) -> str: # pylint: disable=C0111
if namespace == 'creole' or '.' in name:
varname = name
else:
varname = '.'.join([namespace, family, name])
self.variables[varname] = dict(name=name,
family=family,
namespace=namespace,
leader=None,
is_dynamic=is_dynamic,
creoleobj=creoleobj)
def get_variable_name(self,
name,
): # pylint: disable=C0111
return self._get_variable(name)['name']
def get_variable_obj(self,
name:str,
) -> 'Variable': # pylint: disable=C0111
return self._get_variable(name)['creoleobj']
def get_variable_family_name(self,
name: str,
) -> str: # pylint: disable=C0111
return self._get_variable(name)['family']
def get_variable_family_path(self,
name: str,
) -> str: # pylint: disable=C0111
dico = self._get_variable(name)
list_path = [dico['namespace'], dico['family']]
if dico['leader'] is not None:
list_path.append(dico['leader'])
return '.'.join(list_path)
def get_variable_namespace(self,
name: str,
) -> str: # pylint: disable=C0111
return self._get_variable(name)['namespace']
def get_variable_path(self,
name: str,
current_namespace: str,
allow_source: str=False,
with_suffix: bool=False,
) -> str: # pylint: disable=C0111
if current_namespace is None: # pragma: no cover
raise CreoleOperationError('current_namespace must not be None')
if with_suffix:
dico, suffix = self._get_variable(name,
with_suffix=True,
)
else:
dico = self._get_variable(name)
if not allow_source:
if dico['namespace'] not in ['creole', 'services'] and current_namespace != dico['namespace']:
raise CreoleDictConsistencyError(_('A variable located in the {} namespace '
'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace))
if '.' in dico['name']:
value = dico['name']
else:
list_path = [dico['namespace'], dico['family']]
if dico['leader'] is not None:
list_path.append(dico['leader'])
list_path.append(dico['name'])
value = '.'.join(list_path)
if with_suffix:
return value, suffix
return value
def path_is_defined(self,
name: str,
) -> str: # pylint: disable=C0111
return name in self.variables
def _get_variable(self,
name: str,
with_suffix: bool=False,
) -> str:
if name not in self.variables:
if name.startswith('creole.'):
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))
if with_suffix:
return self.variables[name], None
return self.variables[name]

182
src/rougail/path.py Normal file
View File

@ -0,0 +1,182 @@
from .i18n import _
from .utils import normalize_family
from .error import CreoleOperationError, CreoleDictConsistencyError
class Path:
"""Helper class to handle the `path` attribute of a CreoleObjSpace
instance.
sample: path="creole.general.condition"
"""
def __init__(self):
self.variables = {}
self.families = {}
# Family
def add_family(self,
namespace: str,
name: str,
creoleobj: str,
) -> str: # pylint: disable=C0111
self.families[name] = dict(name=name,
namespace=namespace,
creoleobj=creoleobj,
)
def get_family_path(self,
name: str,
current_namespace: str,
) -> str: # pylint: disable=C0111
if current_namespace is None: # pragma: no cover
raise CreoleOperationError('current_namespace must not be None')
dico = self.families[normalize_family(name,
check_name=False,
allow_dot=True,
)]
if dico['namespace'] != 'creole' and current_namespace != dico['namespace']:
raise CreoleDictConsistencyError(_('A family located in the {} namespace '
'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace))
path = dico['name']
if dico['namespace'] is not None and '.' not in dico['name']:
path = '.'.join([dico['namespace'], path])
return path
def get_family_obj(self,
name: str,
) -> 'Family': # pylint: disable=C0111
if name not in self.families:
raise CreoleDictConsistencyError(_('unknown family {}').format(name))
dico = self.families[name]
return dico['creoleobj']
# Leadership
def set_leader(self,
namespace: str,
leader_family_name: str,
name: str,
leader_name: str,
) -> None: # pylint: disable=C0111
if namespace != 'creole':
# need rebuild path and move object in new path
old_path = namespace + '.' + leader_family_name + '.' + name
dico = self._get_variable(old_path)
del self.variables[old_path]
new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name
self.add_variable(namespace,
new_path,
dico['family'],
False,
dico['creoleobj'],
)
name = new_path
dico = self._get_variable(name)
if dico['leader'] != None:
raise CreoleDictConsistencyError(_('Already defined leader {} for variable'
' {}'.format(dico['leader'], name)))
dico['leader'] = leader_name
def get_leader(self, name): # pylint: disable=C0111
return self._get_variable(name)['leader']
# Variable
def add_variable(self,
namespace: str,
name: str,
family: str,
is_dynamic: bool,
creoleobj,
) -> str: # pylint: disable=C0111
if namespace == 'creole' or '.' in name:
varname = name
else:
varname = '.'.join([namespace, family, name])
self.variables[varname] = dict(name=name,
family=family,
namespace=namespace,
leader=None,
is_dynamic=is_dynamic,
creoleobj=creoleobj)
def get_variable_name(self,
name,
): # pylint: disable=C0111
return self._get_variable(name)['name']
def get_variable_obj(self,
name:str,
) -> 'Variable': # pylint: disable=C0111
return self._get_variable(name)['creoleobj']
def get_variable_family_name(self,
name: str,
) -> str: # pylint: disable=C0111
return self._get_variable(name)['family']
def get_variable_family_path(self,
name: str,
) -> str: # pylint: disable=C0111
dico = self._get_variable(name)
list_path = [dico['namespace'], dico['family']]
if dico['leader'] is not None:
list_path.append(dico['leader'])
return '.'.join(list_path)
def get_variable_namespace(self,
name: str,
) -> str: # pylint: disable=C0111
return self._get_variable(name)['namespace']
def get_variable_path(self,
name: str,
current_namespace: str,
allow_source: str=False,
with_suffix: bool=False,
) -> str: # pylint: disable=C0111
if current_namespace is None: # pragma: no cover
raise CreoleOperationError('current_namespace must not be None')
if with_suffix:
dico, suffix = self._get_variable(name,
with_suffix=True,
)
else:
dico = self._get_variable(name)
if not allow_source:
if dico['namespace'] not in ['creole', 'services'] and current_namespace != dico['namespace']:
raise CreoleDictConsistencyError(_('A variable located in the {} namespace '
'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace))
if '.' in dico['name']:
value = dico['name']
else:
list_path = [dico['namespace'], dico['family']]
if dico['leader'] is not None:
list_path.append(dico['leader'])
list_path.append(dico['name'])
value = '.'.join(list_path)
if with_suffix:
return value, suffix
return value
def path_is_defined(self,
name: str,
) -> str: # pylint: disable=C0111
return name in self.variables
def _get_variable(self,
name: str,
with_suffix: bool=False,
) -> str:
if name not in self.variables:
if name.startswith('creole.'):
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))
if with_suffix:
return self.variables[name], None
return self.variables[name]

View File

@ -35,23 +35,18 @@ class XMLReflector(object):
:returns: the root element tree object :returns: the root element tree object
""" """
# FIXME zephir2
# document = parse(BytesIO(xmlfile), XMLParser(remove_blank_text=True)) # document = parse(BytesIO(xmlfile), XMLParser(remove_blank_text=True))
document = parse(xmlfile) document = parse(xmlfile)
if not self.dtd.validate(document): if not self.dtd.validate(document):
raise CreoleDictConsistencyError(_("not a valid xml file: {}").format(xmlfile)) raise CreoleDictConsistencyError(_("not a valid xml file: {}").format(xmlfile))
return document.getroot() return document.getroot()
def load_xml_from_folders(self, xmlfolders, from_zephir): def load_xml_from_folders(self, xmlfolders):
"""Loads all the XML files located in the xmlfolders' list """Loads all the XML files located in the xmlfolders' list
:param xmlfolders: list of full folder's name :param xmlfolders: list of full folder's name
""" """
documents = [] documents = []
if from_zephir:
for idx, xmlfile in enumerate(xmlfolders):
documents.append(('generate_{}'.format(idx), self.parse_xmlfile(xmlfile, from_zephir=from_zephir)))
else:
if not isinstance(xmlfolders, list): if not isinstance(xmlfolders, list):
xmlfolders = [xmlfolders] xmlfolders = [xmlfolders]
for xmlfolder in xmlfolders: for xmlfolder in xmlfolders:

View File

@ -59,3 +59,7 @@ def cdrom_minormajor(*args, **kwargs):
def device_type(*args, **kwargs): def device_type(*args, **kwargs):
pass pass
def calc_list(*args, **kwargs):
return []

View File

@ -1,8 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family name="services"> <family name="services">
<family name="service0" doc="tata"> <family name="service0" doc="tata"/>
<property>basic</property>
</family> </family>
</family> </rougail>
</creole>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
@ -14,4 +14,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>expert</property> <property>expert</property>
@ -14,4 +14,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.without_type": "non"} {"creole.general.mode_conteneur_actif": "non", "creole.general.without_type": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
@ -21,4 +21,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif1": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
@ -26,4 +26,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -16,9 +16,9 @@
</variables> </variables>
<constraints> <constraints>
<auto name="calc_val" target="mode_conteneur_actif"> <fill name="calc_val" target="mode_conteneur_actif">
<param type="variable">mode_conteneur_actif1</param> <param type="variable">mode_conteneur_actif1</param>
</auto> </fill>
</constraints> </constraints>
<help/> <help/>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif1": "non"} {"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -16,8 +16,8 @@
</variables> </variables>
<constraints> <constraints>
<auto name="calc_val" target="mode_conteneur_actif"> <fill name="calc_val" target="mode_conteneur_actif">
</auto> </fill>
</constraints> </constraints>
<help/> <help/>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif1": "non"} {"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

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

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

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

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>basic</property> <property>basic</property>
@ -32,4 +32,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>basic</property> <property>basic</property>
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif1": "non"} {"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif1": "non"} {"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="Général" name="general"> <family doc="Général" name="general">
<property>normal</property> <property>normal</property>
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -20,4 +20,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif1": "non"} {"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -22,4 +22,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif1": "non"} {"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -18,4 +18,4 @@
<separator name="creole.general.mode_conteneur_actif">Établissement</separator> <separator name="creole.general.mode_conteneur_actif">Établissement</separator>
</separators> </separators>
</family> </family>
</creole> </rougail>

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -18,4 +18,4 @@
<separator name="creole.general.mode_conteneur_actif" never_hidden="True">Établissement</separator> <separator name="creole.general.mode_conteneur_actif" never_hidden="True">Établissement</separator>
</separators> </separators>
</family> </family>
</creole> </rougail>

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non", "creole.general.autosavevar": null}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.autosavevar": null} {"creole.general.mode_conteneur_actif": "non", "creole.general.autosavevar": null}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
@ -26,4 +26,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -18,4 +18,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -21,4 +21,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -44,4 +44,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -38,4 +38,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>basic</property> <property>basic</property>
@ -24,4 +24,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -34,4 +34,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -9,22 +9,22 @@
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="leader" type="string" description="leader" multi="True"/> <variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/> <variable name="follower1" type="string" description="follower1" multi="True" hidden="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/> <variable name="follower2" type="string" description="follower2" multi="True" hidden="True"/>
<variable name="follower3" type="string" description="follower3" multi="True"/> <variable name="follower3" type="string" description="follower3" multi="True" hidden="True"/>
</family> </family>
</variables> </variables>
<constraints> <constraints>
<auto name="calc_val" target="follower1"> <fill name="calc_val" target="follower1">
<param name="valeur">valfill</param> <param name="valeur">valfill</param>
</auto> </fill>
<auto name="calc_val" target="follower2"> <fill name="calc_val" target="follower2">
<param type="variable">follower1</param> <param type="variable">follower1</param>
</auto> </fill>
<auto name="calc_val" target="follower3"> <fill name="calc_val" target="follower3">
<param type="variable">leader</param> <param type="variable">leader</param>
</auto> </fill>
<group leader="leader"> <group leader="leader">
<follower>follower1</follower> <follower>follower1</follower>
<follower>follower2</follower> <follower>follower2</follower>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": []} {"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": [], "creole.general.leader.follower3": []}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -43,4 +43,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -9,18 +9,18 @@
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="leader" type="string" description="leader" multi="True"/> <variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/> <variable name="follower1" type="string" description="follower1" multi="True" hidden="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/> <variable name="follower2" type="string" description="follower2" multi="True" hidden="True"/>
</family> </family>
</variables> </variables>
<constraints> <constraints>
<auto name="calc_val" target="follower1"> <fill name="calc_val" target="follower1">
<param name="valeur">valfill</param> <param name="valeur">valfill</param>
</auto> </fill>
<auto name="calc_val" target="follower2"> <fill name="calc_val" target="follower2">
<param type="variable">leader</param> <param type="variable">leader</param>
</auto> </fill>
<group leader="leader"> <group leader="leader">
<follower>follower1</follower> <follower>follower1</follower>
<follower>follower2</follower> <follower>follower2</follower>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": []} {"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -34,4 +34,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -10,16 +10,16 @@
</variable> </variable>
</family> </family>
<family name="leadermode" mode="expert"> <family name="leadermode" mode="expert">
<variable name="leader" type="string" description="leader" multi="True"/> <variable name="leader" type="string" description="leader" multi="True" hidden="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/> <variable name="follower1" type="string" description="follower1" multi="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/> <variable name="follower2" type="string" description="follower2" multi="True"/>
</family> </family>
</variables> </variables>
<constraints> <constraints>
<auto name="calc_val" target="leader"> <fill name="calc_list" target="leader">
<param name="valeur">valfill</param> <param name="valeur">valfill</param>
</auto> </fill>
<group leader="leader"> <group leader="leader">
<follower>follower1</follower> <follower>follower1</follower>
<follower>follower2</follower> <follower>follower2</follower>

View File

@ -1 +1 @@
{"creole.general.mode_conteneur_actif": "non"} {"creole.general.mode_conteneur_actif": "non", "creole.leadermode.leader.leader": [], "creole.leadermode.leader.follower1": [], "creole.leadermode.leader.follower2": []}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>expert</property> <property>expert</property>
@ -19,17 +19,21 @@
<variable doc="leader" multi="True" name="leader" type="string"> <variable doc="leader" multi="True" name="leader" type="string">
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<value name="calc_val" type="calculation"> <value name="calc_list" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>force_default_on_freeze</property>
<property>frozen</property>
<property>expert</property> <property>expert</property>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>force_default_on_freeze</property>
<property>frozen</property>
<property>expert</property> <property>expert</property>
</variable> </variable>
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -28,4 +28,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="Général" name="general"> <family doc="Général" name="general">
<property>normal</property> <property>normal</property>
@ -28,4 +28,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>basic</property> <property>basic</property>
@ -30,4 +30,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -29,4 +29,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.nut_monitor_netmask.nut_monitor_netmask": [], "creole.general.nut_monitor_netmask.nut_monitor_host": []} {"creole.general.mode_conteneur_actif": "oui", "creole.general.nut_monitor_netmask.nut_monitor_netmask": [], "creole.general.nut_monitor_netmask.nut_monitor_host": []}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
@ -24,4 +24,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -41,4 +41,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -13,6 +13,9 @@
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice> <choice type="string">oui</choice>
<choice type="string">non</choice> <choice type="string">non</choice>
<property>force_default_on_freeze</property>
<property>frozen</property>
<property>hidden</property>
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property> <property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>
@ -21,6 +24,9 @@
<variable doc="No change" multi="False" name="mode_conteneur_actif2" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif2" type="choice">
<choice type="string">oui</choice> <choice type="string">oui</choice>
<choice type="string">non</choice> <choice type="string">non</choice>
<property>force_default_on_freeze</property>
<property>frozen</property>
<property>hidden</property>
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property> <property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>
@ -29,4 +35,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -11,6 +11,9 @@
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice> <choice type="string">oui</choice>
<choice type="string">non</choice> <choice type="string">non</choice>
<property>force_default_on_freeze</property>
<property>frozen</property>
<property>hidden</property>
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<property inverse="False" source="creole.general.condition" type="calculation">disabled</property> <property inverse="False" source="creole.general.condition" type="calculation">disabled</property>
@ -19,6 +22,9 @@
<variable doc="No change" multi="False" name="mode_conteneur_actif2" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif2" type="choice">
<choice type="string">oui</choice> <choice type="string">oui</choice>
<choice type="string">non</choice> <choice type="string">non</choice>
<property>force_default_on_freeze</property>
<property>frozen</property>
<property>hidden</property>
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<property inverse="False" source="creole.general.condition" type="calculation">disabled</property> <property inverse="False" source="creole.general.condition" type="calculation">disabled</property>
@ -27,4 +33,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -8,10 +8,10 @@
<variable name="condition" type="oui/non" description="No change"> <variable name="condition" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="mode_conteneur_actif" type="oui/non" description="No change" hidden="True"> <variable name="mode_conteneur_actif" type="oui/non" description="No change" >
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="mode_conteneur_actif2" type="oui/non" description="No change" hidden="True"> <variable name="mode_conteneur_actif2" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
</family> </family>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non"} {"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "creole.general2.mode_conteneur_actif3": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="Général" name="general"> <family doc="Général" name="general">
<property>normal</property> <property>normal</property>
@ -43,4 +43,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -8,10 +8,10 @@
<variable name="condition" type="oui/non" description="No change"> <variable name="condition" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="mode_conteneur_actif" type="oui/non" description="No change" hidden="True"> <variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="mode_conteneur_actif2" type="oui/non" description="No change" hidden="True"> <variable name="mode_conteneur_actif2" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
</family> </family>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -29,4 +29,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -8,10 +8,10 @@
<variable name="condition" type="oui/non" description="No change"> <variable name="condition" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="mode_conteneur_actif" type="oui/non" description="No change" hidden="True"> <variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
<variable name="mode_conteneur_actif2" type="oui/non" description="No change" hidden="True"> <variable name="mode_conteneur_actif2" type="oui/non" description="No change">
<value>non</value> <value>non</value>
</variable> </variable>
</family> </family>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -29,4 +29,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -0,0 +1,25 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change">
<value></value>
</variable>
<variable name="mode_conteneur_actif2" type="string" description="No change">
<value/>
</variable>
</family>
<separators/>
</variables>
<constraints>
</constraints>
<help/>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif2": null}

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="string">
<property>normal</property>
</variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif2" type="string">
<property>normal</property>
</variable>
</family>
<separators/>
</family>
</rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -33,4 +33,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -24,9 +24,9 @@
<target type="variable">mode_conteneur_actif</target> <target type="variable">mode_conteneur_actif</target>
<target type="variable">mode_conteneur_actif2</target> <target type="variable">mode_conteneur_actif2</target>
</condition> </condition>
<auto name="calc_val" target="mode_conteneur_actif"> <fill name="calc_val" target="mode_conteneur_actif">
<param>non</param> <param>non</param>
</auto> </fill>
</constraints> </constraints>
<help/> <help/>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -35,4 +35,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.condition": "tous"} {"creole.general.condition": "tous", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -40,4 +40,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1 +1 @@
{"creole.general.condition": "tous"} {"creole.general.condition": "tous", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non"}

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -34,4 +34,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -31,4 +31,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -24,4 +24,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -30,4 +30,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -25,4 +25,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -31,4 +31,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -27,4 +27,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -31,4 +31,4 @@
</leader> </leader>
</family> </family>
</family> </family>
</creole> </rougail>

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<creole> <rougail>
<family doc="" name="creole"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
@ -29,4 +29,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</creole> </rougail>

View File

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

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