Compare commits

..

3 Commits

Author SHA1 Message Date
58b3880e9b Delete changelog 2020-07-29 09:56:15 +02:00
413ab6dbb0 Add debian folder in packaging branch 2020-07-29 09:55:51 +02:00
534b5f4413 Do not include debian folder in code branch 2020-07-29 09:54:48 +02:00
488 changed files with 5597 additions and 4072 deletions

5
debian/changelog vendored
View File

@ -1,5 +0,0 @@
rougail (0.1) unstable; urgency=low
* first version
-- Cadoles <contact@cadoles.com> Tue, 31 Mar 2020 10:40:42 +0200

View File

@ -1,6 +1,5 @@
# coding: utf-8 # coding: utf-8
from copy import copy from copy import copy
from typing import List
from collections import OrderedDict from collections import OrderedDict
from os.path import join, basename from os.path import join, basename
@ -21,9 +20,25 @@ class Mode(object):
def __init__(self, name, level): def __init__(self, name, level):
self.name = name self.name = name
self.level = level self.level = level
def __cmp__(self, other):
return cmp(self.level, other.level)
def __eq__(self, other):
return self.level == other.level
def __ne__(self, other):
return self.level != other.level
def __gt__(self, other): def __gt__(self, other):
return other.level < self.level return other.level < self.level
def __ge__(self, other):
return not self.level < other.level
def __le__(self, other):
return not other.level < self.level
def mode_factory(): def mode_factory():
mode_obj = {} mode_obj = {}
@ -34,7 +49,6 @@ 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',
@ -57,84 +71,63 @@ KEY_TYPE = {'variable': 'symlink',
'URLOption': 'web_address', 'URLOption': 'web_address',
'FilenameOption': 'filename'} 'FilenameOption': 'filename'}
TYPE_PARAM_CHECK = ('string', 'python', 'variable') TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable')
TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'variable') TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable')
TYPE_PARAM_FILL = ('string', 'number', 'variable') TYPE_PARAM_FILL = ('string', 'eole', 'number', 'context', 'variable')
CONVERSION = {'number': int}
ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action')
FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie' FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie'
VARIABLE_NAMESPACE = 'rougail'
class ServiceAnnotator: class ServiceAnnotator:
"""Manage service's object """Manage service's object
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 gen_family(self,
name,
):
family = self.objectspace.family()
family.name = name
family.doc = name
family.mode = None
return family
def convert_services(self): def convert_services(self):
if not hasattr(self.space, 'services'): if hasattr(self.space, 'services'):
return if hasattr(self.space.services, 'service'):
if not hasattr(self.space.services, 'service'): subelts = dict()
del self.space.services for idx, service in enumerate(self.space.services.service.values()):
return family = self.objectspace.family()
self.space.services.hidden = True family.name = 'service{}'.format(idx)
families = {} family.doc = service.name
for idx, service_name in enumerate(self.space.services.service.keys()): family.family = OrderedDict()
service = self.space.services.service[service_name] self.convert_service_to_family(family.name, family.family, service)
new_service = self.objectspace.service() setattr(self.space.services, family.name, family)
for elttype, values in vars(service).items(): del self.space.services.service
if elttype == 'name' or elttype in ERASED_ATTRIBUTES: else:
setattr(new_service, elttype, values) del self.space.services
continue
eltname = elttype + 's'
family = self.gen_family(eltname)
if isinstance(values, dict):
values = list(values.values())
family.family = self.make_group_from_elts(service_name,
elttype,
values,
f'services.{service_name}.{eltname}',
)
setattr(new_service, elttype, family)
families[service_name] = new_service
self.space.services.service = families
def make_group_from_elts(self, def convert_service_to_family(self, service_name, service_family, service):
service_name, for elttype, values in vars(service).items():
name, if elttype in ['name', 'index']:
elts, continue
path, family = self.objectspace.family()
): family.name = elttype + 's'
"""Splits each objects into a group (and `OptionDescription`, in tiramisu terms) if isinstance(values, dict):
and build elements and its attributes (the `Options` in tiramisu terms) values = list(values.values())
""" family.family = self.convert_subelement_service(elttype,
values,
'services.{}.{}'.format(service_name, family.name))
family.mode = None
service_family[family.name] = family
def convert_subelement_service(self, name, elts, path):
families = [] families = []
new_elts = self._reorder_elts(name, new_elts = self._reorder_elts(name, elts, True)
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']
@ -142,19 +135,9 @@ class ServiceAnnotator:
# try to launch _update_xxxx() function # try to launch _update_xxxx() function
update_elt = '_update_' + elt_name update_elt = '_update_' + elt_name
if hasattr(self, update_elt): if hasattr(self, update_elt):
getattr(self, update_elt)(elt, getattr(self, update_elt)(elt, index, path)
index, variables = []
path, subpath = '{}.{}{}'.format(path, name, index)
service_name,
)
if hasattr(elt, 'source'):
c_name = elt.source
else:
c_name = elt.name
family = self.gen_family(c_name)
family.variable = []
subpath = '{}.{}'.format(path, c_name)
listname = '{}list'.format(name) listname = '{}list'.format(name)
activate_path = '.'.join([subpath, 'activate']) activate_path = '.'.join([subpath, 'activate'])
if elt in self.grouplist_conditions: if elt in self.grouplist_conditions:
@ -166,117 +149,228 @@ 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(
value, value,
[]).append(activate_path) []).append(activate_path)
continue continue
family.variable.append(self._generate_element(elt_name, if key == 'name':
key, true_key = elt_name
value, else:
elt, true_key = key
f'{subpath}.{key}' if true_key in self.objectspace.booleans_attributs:
)) type_ = 'boolean'
else:
type_ = 'string'
dtd_key_type = true_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 # FIXME ne devrait pas etre True par défaut
# devrait etre un calcule variables.append(self._generate_element(name, 'activate', True, 'boolean', subpath))
family.variable.append(self._generate_element(elt_name, family = self.objectspace.family()
'activate', family.name = '{}{}'.format(name, index)
True, family.variable = variables
elt, family.mode = None
activate_path, self.paths.append('family', subpath, 'services', creoleobj=family)
))
families.append(family) families.append(family)
return families return families
def _generate_element(self, def _generate_element(self, eltname, name, value, type_, subpath, multi=False):
elt_name, var_data = {'name': name, 'doc': '', 'value': value,
key, 'auto_freeze': False, 'mode': None, 'multi': multi}
value, values = None
elt, if type_ == 'string':
path, values = self.objectspace.forced_choice_option.get(eltname, {}).get(name)
): if values is not None:
type_ = 'choice'
var_data['type'] = type_
variable = self.objectspace.variable() variable = self.objectspace.variable()
variable.name = key variable.mandatory = True
variable.mode = None for key, value in var_data.items():
if key == 'name': if key == 'value':
true_key = elt_name if value is None:
else: continue
true_key = key if type_ == 'symlink':
dtd_key_type = true_key + '_type' key = 'opt'
if key == 'activate': else:
type_ = 'boolean' # Value is a list of objects
elif hasattr(elt, dtd_key_type): if not multi:
type_ = KEY_TYPE[getattr(elt, dtd_key_type)] val = self.objectspace.value()
elif key in self.objectspace.booleans_attributs: val.name = value
type_ = 'boolean' value = [val]
else: else:
type_ = 'string' value_list = []
variable.type = type_ for valiter in value:
if type_ == 'symlink': val = self.objectspace.value()
variable.opt = value val.name = valiter.name
else: value_list.append(val)
variable.doc = key value = value_list
val = self.objectspace.value() if key == 'doc' and type_ == 'symlink':
val.name = value continue
variable.value = [val] setattr(variable, key, value)
self.paths.add_variable('services', if values is not None:
path, choices = []
'service', for value in values:
False, choice = self.objectspace.choice()
variable, choice.name = value
) choices.append(choice)
variable.choice = choices
path = '{}.{}'.format(subpath, name)
self.paths.append('variable', path, 'services', 'service', variable)
return variable return variable
def _reorder_elts(self, def _update_file(self, file_, index, service_path):
name, if file_.file_type == "UnicodeOption":
elts,
):
"""Reorders by index the elts
"""
new_elts = {}
# reorder elts by index
for idx, elt in enumerate(elts):
new_elts.setdefault(idx, []).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_override(self,
file_,
index,
service_path,
service_name,
):
file_.name = f'/systemd/system/{service_name}.service.d/rougail.conf'
# retrieve default value from File object
for attr in ['owner', 'group', 'mode']:
setattr(file_, attr, getattr(self.objectspace.file, attr))
if not hasattr(file_, 'source'):
file_.source = f'{service_name}.service'
self._update_file(file_,
index,
service_path,
service_name,
)
def _update_file(self,
file_,
index,
service_path,
service_name,
):
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)
elif not hasattr(file_, 'source'): elif not hasattr(file_, 'source'):
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.append('family', subpath, 'services', creoleobj=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
@ -287,21 +381,25 @@ class SpaceAnnotator(object):
self.objectspace = objectspace self.objectspace = objectspace
self.valid_enums = {} self.valid_enums = {}
self.force_value = {} self.force_value = {}
self.has_calc = []
self.force_no_value = []
self.force_not_mandatory = [] self.force_not_mandatory = []
if eosfunc_file: if eosfunc_file:
self.eosfunc = imp.load_source('eosfunc', eosfunc_file) self.eosfunc = imp.load_source('eosfunc', eosfunc_file)
else: else:
self.eosfunc = None self.eosfunc = None
if HIGH_COMPATIBILITY: if HIGH_COMPATIBILITY:
self.has_hidden_if_in_condition = [] self.default_has_no_value = []
self.convert_variable() self.has_frozen_if_in_condition = []
self.default_variable_options()
self.variable_submulti()
self.convert_auto_freeze() self.convert_auto_freeze()
self.convert_groups() self.convert_groups()
self.filter_check() self.filter_check()
self.filter_condition() self.filter_condition()
self.convert_valid_enums() self.convert_valid_enums()
self.convert_check() self.convert_check()
self.convert_fill() self.convert_autofill()
self.remove_empty_families() self.remove_empty_families()
self.change_variable_mode() self.change_variable_mode()
self.change_family_mode() self.change_family_mode()
@ -311,7 +409,6 @@ class SpaceAnnotator(object):
self.convert_helps() self.convert_helps()
if hasattr(self.space, 'constraints'): if hasattr(self.space, 'constraints'):
del self.space.constraints.index del self.space.constraints.index
del self.space.constraints.namespace
if vars(self.space.constraints): if vars(self.space.constraints):
raise Exception('constraints again?') raise Exception('constraints again?')
del self.space.constraints del self.space.constraints
@ -319,19 +416,14 @@ class SpaceAnnotator(object):
def absolute_path_for_symlink_in_services(self): def absolute_path_for_symlink_in_services(self):
if not hasattr(self.space, 'services'): if not hasattr(self.space, 'services'):
return return
for family_name, family in vars(self.space.services).items(): families = vars(self.space.services).values()
if not isinstance(family, dict): for family in families:
continue if hasattr(family, 'family'):
for fam in family.values(): for fam in family.family.values():
for fam1_name, fam1 in vars(fam).items(): for fam1 in fam.family:
if fam1_name == 'name' or fam1_name in ERASED_ATTRIBUTES: for variable in fam1.variable:
continue
for fam2 in fam1.family:
for variable in fam2.variable:
if variable.type == 'symlink' and '.' not in variable.name: if variable.type == 'symlink' and '.' not in variable.name:
variable.opt = self.paths.get_variable_path(variable.opt, variable.opt = self.paths.get_variable_path(variable.opt, 'creole')
VARIABLE_NAMESPACE,
)
def convert_helps(self): def convert_helps(self):
# FIXME l'aide doit etre dans la variable! # FIXME l'aide doit etre dans la variable!
@ -348,119 +440,64 @@ class SpaceAnnotator(object):
variable.help = hlp.text variable.help = hlp.text
del self.space.help del self.space.help
def manage_leader(self,
leader_space: 'Leadership',
leader_family_name: str,
leader_name: str,
namespace: str,
variable: 'Variable',
group: 'Group',
leader_fullname: str,
) -> None:
# manage leader's variable
if variable.multi is not True:
raise CreoleDictConsistencyError(_('the variable {} in a group must be multi').format(variable.name))
leader_space.variable = []
leader_space.name = leader_name
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
if hasattr(group, 'description'):
leader_space.doc = group.description
else:
leader_space.doc = variable.description
leader_path = namespace + '.' + leader_family_name + '.' + leader_name
self.paths.add_family(namespace,
leader_path,
leader_space,
)
leader_family = self.space.variables[namespace].family[leader_family_name]
leader_family.variable[leader_name] = leader_space
leader_space.variable.append(variable)
self.paths.set_leader(namespace,
leader_family_name,
leader_name,
leader_name,
)
leader_space.path = leader_fullname
return leader_is_hidden
def manage_follower(self,
namespace: str,
leader_family_name: str,
variable: 'Variable',
leader_name: str,
follower_names: List[str],
leader_space: 'Leadership',
leader_is_hidden: bool,
) -> None:
if variable.name != follower_names[0]:
raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0]))
follower_names.remove(variable.name)
if leader_is_hidden:
variable.frozen = True
variable.force_default_on_freeze = True
# followers are multi
if not variable.multi:
raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name))
leader_space.variable.append(variable) # pylint: disable=E1101
self.paths.set_leader(namespace,
leader_family_name,
variable.name,
leader_name,
)
def convert_groups(self): # pylint: disable=C0111 def convert_groups(self): # pylint: disable=C0111
if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'group'): if hasattr(self.space, 'constraints'):
for group in self.space.constraints.group: if hasattr(self.space.constraints, 'group'):
leader_fullname = group.leader for group in self.space.constraints.group:
follower_names = list(group.follower.keys()) leader_fullname = group.master
leader_family_name = self.paths.get_variable_family_name(leader_fullname) follower_names = list(group.slave.keys())
namespace = self.paths.get_variable_namespace(leader_fullname) leader_family_name = self.paths.get_variable_family_name(leader_fullname)
leader_name = self.paths.get_variable_name(leader_fullname) namespace = self.paths.get_variable_namespace(leader_fullname)
ori_leader_family = self.space.variables[namespace].family[leader_family_name] leader_name = self.paths.get_variable_name(leader_fullname)
has_a_leader = False leader_family = self.space.variables[namespace].family[leader_family_name]
for variable in list(ori_leader_family.variable.values()): leader_path = namespace + '.' + leader_family_name
if isinstance(variable, self.objectspace.Leadership): is_leader = False
# append follower to an existed leadership for variable in list(leader_family.variable.values()):
if variable.name == leader_name: if isinstance(variable, self.objectspace.Leadership):
leader_space = variable # append follower to an existed leadership
has_a_leader = True if variable.name == leader_name:
leader_space = variable
is_leader = True
else:
if is_leader:
if variable.name == follower_names[0]:
# followers are multi
if not variable.multi:
raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name))
follower_names.remove(variable.name)
leader_family.variable.pop(variable.name)
leader_space.variable.append(variable) # pylint: disable=E1101
if namespace == 'creole':
variable_fullpath = variable.name
else:
variable_fullpath = leader_path + '.' + variable.name
self.paths.set_leader(variable_fullpath, leader_name)
if follower_names == []:
break
else:
raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0]))
if is_leader is False and variable.name == leader_name:
leader_space = self.objectspace.Leadership()
leader_space.variable = []
leader_space.name = leader_name
leader_space.hidden = variable.hidden
if hasattr(group, 'description'):
leader_space.doc = group.description
else:
leader_space.doc = variable.description
variable.hidden = None
self.paths.append('family', leader_path + '.' + leader_name, namespace, creoleobj=leader_space)
# manage leader's variable
if variable.multi is not True:
raise CreoleDictConsistencyError(_('the variable {} in a group must be multi').format(variable.name))
leader_family.variable[leader_name] = leader_space
leader_space.variable.append(variable) # pylint: disable=E1101
self.paths.set_leader(leader_fullname, leader_name)
leader_space.path = leader_fullname
is_leader = True
else: else:
if has_a_leader: raise CreoleDictConsistencyError(_('cannot found followers {}').format(follower_names))
# it's a follower del self.space.constraints.group
self.manage_follower(namespace,
leader_family_name,
variable,
leader_name,
follower_names,
leader_space,
leader_is_hidden,
)
ori_leader_family.variable.pop(variable.name)
if follower_names == []:
# no more follower
break
elif variable.name == leader_name:
# it's a leader
leader_space = self.objectspace.Leadership()
leader_is_hidden = self.manage_leader(leader_space,
leader_family_name,
leader_name,
namespace,
variable,
group,
leader_fullname,
)
has_a_leader = True
else:
raise CreoleDictConsistencyError(_('cannot found followers {}').format(follower_names))
del self.space.constraints.group
def remove_empty_families(self): # pylint: disable=C0111,R0201 def remove_empty_families(self): # pylint: disable=C0111,R0201
if hasattr(self.space, 'variables'): if hasattr(self.space, 'variables'):
@ -507,35 +544,53 @@ class SpaceAnnotator(object):
varpath = self.paths.get_variable_path(family.dynamic, namespace) varpath = self.paths.get_variable_path(family.dynamic, namespace)
family.dynamic = varpath family.dynamic = varpath
def annotate_variable(self, variable, family_mode, path, is_follower=False): def _annotate_variable(self, variable, family_mode, path, is_follower=False):
if (HIGH_COMPATIBILITY and variable.type == 'choice' and variable.mode != modes_level[-1] and variable.mandatory is True and path in self.default_has_no_value):
variable.mode = modes_level[0]
if variable.type == 'choice' and is_follower and family_mode == modes_level[0] and variable.mandatory is True:
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')
if variable.mandatory is True and (not has_value or is_follower): if (path not in self.has_calc and variable.mandatory is True and
(not has_value or is_follower) and variable.type != 'choice'):
variable.mode = modes_level[0] variable.mode = modes_level[0]
if variable.mode != None and modes[variable.mode] < modes[family_mode] and (not is_follower or variable.mode != modes_level[0]): if has_value:
variable.mode = family_mode if not HIGH_COMPATIBILITY or (not path.startswith('creole.services.') \
if has_value and path not in self.force_not_mandatory: and path not in self.force_no_value and path not in self.force_not_mandatory):
variable.mandatory = True variable.mandatory = True
if variable.hidden is True: if variable.hidden is True:
variable.frozen = True variable.frozen = True
if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable): if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable):
variable.force_default_on_freeze = True variable.force_default_on_freeze = True
if variable.name == 'frozen' and not variable.auto_save is True:
variable.force_default_on_freeze = True
if variable.mode != None and not is_follower and modes[variable.mode] < modes[family_mode]:
variable.mode = family_mode
if variable.mode != None and variable.mode != modes_level[0] and modes[variable.mode] < modes[family_mode]:
variable.mode = family_mode
def convert_variable(self): def default_variable_options(self):
if not hasattr(self.space, 'variables'): if hasattr(self.space, 'variables'):
return for families in self.space.variables.values():
for families in self.space.variables.values(): if hasattr(families, 'family'):
if hasattr(families, 'family'): for family in families.family.values():
for family in families.family.values(): if hasattr(family, 'variable'):
if hasattr(family, 'variable'): for variable in family.variable.values():
for variable in family.variable.values(): if not hasattr(variable, 'type'):
if not hasattr(variable, 'type'): variable.type = 'string'
variable.type = 'string' if variable.type != 'symlink' and not hasattr(variable, 'description'):
if variable.type != 'symlink' and not hasattr(variable, 'description'): variable.description = variable.name
variable.description = variable.name
if variable.submulti: def variable_submulti(self):
variable.multi = 'submulti' if hasattr(self.space, 'variables'):
for families in self.space.variables.values():
if hasattr(families, 'family'):
for family in families.family.values():
if hasattr(family, 'variable'):
for variable in family.variable.values():
if variable.submulti:
variable.multi = 'submulti'
def convert_auto_freeze(self): # pylint: disable=C0111 def convert_auto_freeze(self): # pylint: disable=C0111
if hasattr(self.space, 'variables'): if hasattr(self.space, 'variables'):
@ -546,7 +601,7 @@ class SpaceAnnotator(object):
for variable in family.variable.values(): for variable in family.variable.values():
if variable.auto_freeze: if variable.auto_freeze:
new_condition = self.objectspace.condition() new_condition = self.objectspace.condition()
new_condition.name = 'auto_hidden_if_not_in' new_condition.name = 'auto_frozen_if_in'
new_condition.namespace = variables.name new_condition.namespace = variables.name
new_condition.source = FREEZE_AUTOFREEZE_VARIABLE new_condition.source = FREEZE_AUTOFREEZE_VARIABLE
new_param = self.objectspace.param() new_param = self.objectspace.param()
@ -554,7 +609,7 @@ class SpaceAnnotator(object):
new_condition.param = [new_param] new_condition.param = [new_param]
new_target = self.objectspace.target() new_target = self.objectspace.target()
new_target.type = 'variable' new_target.type = 'variable'
if variables.name == VARIABLE_NAMESPACE: if variables.name == 'creole':
path = variable.name path = variable.name
else: else:
path = variable.namespace + '.' + family.name + '.' + variable.name path = variable.namespace + '.' + family.name + '.' + variable.name
@ -565,37 +620,31 @@ class SpaceAnnotator(object):
self.space.constraints.condition.append(new_condition) self.space.constraints.condition.append(new_condition)
def _set_valid_enum(self, variable, values, type_): def _set_valid_enum(self, variable, values, type_):
variable.mandatory = True if isinstance(values, list):
variable.choice = [] variable.mandatory = True
choices = [] variable.choice = []
for value in values: choices = []
choice = self.objectspace.choice() for value in values:
try: choice = self.objectspace.choice()
if type_ in CONVERSION: choice.name = str(value)
choice.name = CONVERSION[type_](value) choices.append(choice.name)
else: choice.type = type_
choice.name = str(value) variable.choice.append(choice)
except: if not variable.choice:
raise CreoleDictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"')) raise CreoleDictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name))
choices.append(choice.name) if hasattr(variable, 'value'):
choice.type = type_ for value in variable.value:
variable.choice.append(choice) value.type = type_
if not variable.choice: if value.name not in choices:
raise CreoleDictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name)) raise CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
if hasattr(variable, 'value'): else:
for value in variable.value: new_value = self.objectspace.value()
value.type = type_ new_value.name = values[0]
if type_ in CONVERSION: new_value.type = type_
cvalue = CONVERSION[type_](value.name) variable.value = [new_value]
else:
cvalue = value.name
if cvalue not in choices:
raise CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
else: else:
new_value = self.objectspace.value() # probe choice
new_value.name = values[0] variable.choice = values
new_value.type = type_
variable.value = [new_value]
variable.type = 'choice' variable.type = 'choice'
def _convert_valid_enum(self, variable, path): def _convert_valid_enum(self, variable, path):
@ -659,7 +708,7 @@ class SpaceAnnotator(object):
else: else:
is_follower = False is_follower = False
path = '{}.{}.{}'.format(family.path, variable.name, follower.name) path = '{}.{}.{}'.format(family.path, variable.name, follower.name)
self.annotate_variable(follower, family_mode, path, is_follower) self._annotate_variable(follower, family_mode, path, is_follower)
# leader's mode is minimum level # leader's mode is minimum level
if modes[variable.variable[0].mode] > modes[follower.mode]: if modes[variable.variable[0].mode] > modes[follower.mode]:
follower.mode = variable.variable[0].mode follower.mode = variable.variable[0].mode
@ -672,64 +721,83 @@ class SpaceAnnotator(object):
if variable.auto_freeze is True and variable.mode != modes_level[-1]: if variable.auto_freeze is True and variable.mode != modes_level[-1]:
variable.mode = modes_level[0] variable.mode = modes_level[0]
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 convert_fill(self): # pylint: disable=C0111,R0912 def get_variable(self, name): # pylint: disable=C0111
if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'fill'): return self.paths.get_variable_obj(name)
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
fills = {fill.index: fill for idx, fill in enumerate(self.space.constraints.fill)} if 'fill' in vars(constraints):
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 = {}
eosfunc = dir(self.eosfunc) remove_autos = []
remove_fills = []
for idx in indexes: for idx in indexes:
fill = fills[idx] fill = fills[idx]['fill']
# test if it's redefined calculation redefine = bool(fill.redefine)
if fill.target in targets and not fill.redefine: if fill.target in targets:
raise CreoleDictConsistencyError(_(f"A fill already exists for the target: {fill.target}")) if redefine:
targets.append(fill.target) if targets[fill.target][1] == 'auto':
# remove_autos.append(targets[fill.target][0])
if not fill.name in eosfunc: else:
raise CreoleDictConsistencyError(_('cannot find fill function {}').format(fill.name)) remove_fills.append(targets[fill.target][0])
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)
namespace = fill.namespace def convert_auto(self, auto_space, space): # pylint: disable=C0111
# let's replace the target by the path for auto in auto_space:
fill.target = self.paths.get_variable_path(fill.target, if HIGH_COMPATIBILITY and auto.target in self.has_frozen_if_in_condition:
namespace) # if a variable has a 'frozen_if_in' condition
# then we change the 'auto' variable as a 'fill' variable
value = self.objectspace.value() continue
value.type = 'calculation' # an auto is a fill with "hidden" and "frozen" properties
value.name = fill.name variable = self.get_variable(auto.target)
if hasattr(fill, 'param'): if variable.auto_freeze:
param_to_delete = [] raise CreoleDictConsistencyError(_('variable with auto value '
for fill_idx, param in enumerate(fill.param): 'cannot be auto_freeze').format(auto.target))
if param.type not in TYPE_PARAM_FILL: if variable.auto_save:
raise CreoleDictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto')) raise CreoleDictConsistencyError(_('variable with auto value '
if param.type != 'string' and not hasattr(param, 'text'): 'cannot be auto_save').format(auto.target))
raise CreoleDictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}")) leader = self.paths.get_leader(auto.target)
if param.type == 'variable': if leader is None or variable.name != leader:
try: variable.hidden = True
param.text, suffix = self.paths.get_variable_path(param.text, else:
namespace, leadership = self.paths.get_family_obj(self.paths.get_variable_family_path(auto.target))
with_suffix=True) leadership.hidden = True
if suffix: variable.frozen = True
param.suffix = suffix variable.force_default_on_freeze = True
except CreoleDictConsistencyError as err: if 'fill' not in vars(space.constraints):
if param.optional is False: space.constraints.fill = []
raise err space.constraints.fill.extend(auto_space)
param_to_delete.append(fill_idx) del space.constraints.auto
continue
if param.hidden is True:
param.transitive = False
param.hidden = None
param_to_delete.sort(reverse=True)
for param_idx in param_to_delete:
fill.param.pop(param_idx)
value.param = fill.param
variable = self.paths.get_variable_obj(fill.target)
variable.value = [value]
del self.space.constraints.fill
def filter_separators(self): # pylint: disable=C0111,R0201 def filter_separators(self): # pylint: disable=C0111,R0201
# FIXME devrait etre dans la variable # FIXME devrait etre dans la variable
@ -759,8 +827,8 @@ class SpaceAnnotator(object):
raise CreoleDictConsistencyError(_('Cannot load {}').format(param.text)) raise CreoleDictConsistencyError(_('Cannot load {}').format(param.text))
elif param.type == 'python': elif param.type == 'python':
try: try:
#values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}})
values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}}) values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}})
#FIXME : eval('[str(i) for i in range(3, 13)]', {'eosfunc': eosfunc, '__builtins__': {'range': range, 'str': str}})
except NameError: except NameError:
raise CreoleDictConsistencyError(_('The function {} is unknown').format(param.text)) raise CreoleDictConsistencyError(_('The function {} is unknown').format(param.text))
if not isinstance(values, list): if not isinstance(values, list):
@ -773,54 +841,87 @@ class SpaceAnnotator(object):
values = param.text values = param.text
return values return values
def check_check(self): def filter_check(self): # pylint: disable=C0111
# valid param in check
if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'check'):
return
space = self.space.constraints.check
remove_indexes = [] remove_indexes = []
functions = dir(self.eosfunc) for check_idx, check in enumerate(space):
functions.extend(['valid_enum', 'valid_in_network', 'valid_differ']) namespace = check.namespace
for check_idx, check in enumerate(self.space.constraints.check):
if not check.name in functions:
raise CreoleDictConsistencyError(_('cannot find check function {}').format(check.name))
if hasattr(check, 'param'): if hasattr(check, 'param'):
param_option_indexes = [] param_option_indexes = []
for idx, param in enumerate(check.param): for idx, param in enumerate(check.param):
if param.type not in TYPE_PARAM_CHECK: if param.type not in TYPE_PARAM_CHECK:
raise CreoleDictConsistencyError(_('cannot use {} type as a param in check for {}').format(param.type, check.target)) raise CreoleDictConsistencyError(_('cannot use {} type as a param in check for {}').format(param.type, check.target))
if param.type == 'variable' and not self.paths.path_is_defined(param.text): if param.type == 'eole':
if param.optional is True: param.type = 'variable'
param_option_indexes.append(idx) if param.type == 'variable':
else: # if HIGH_COMPATIBILITY and param.text.startswith('container_ip'):
raise CreoleDictConsistencyError(_(f'unknown param {param.text} in check')) # if param.optional is True:
# param_option_indexes.append(idx)
try:
param.text = self.paths.get_variable_path(param.text, namespace)
except CreoleDictConsistencyError as err:
if param.optional is True:
param_option_indexes.append(idx)
else:
raise err
param_option_indexes = list(set(param_option_indexes)) param_option_indexes = list(set(param_option_indexes))
param_option_indexes.sort(reverse=True) param_option_indexes.sort(reverse=True)
for idx in param_option_indexes: for idx in param_option_indexes:
check.param.pop(idx) check.param.pop(idx)
if check.param == []: if not HIGH_COMPATIBILITY and check.param == []:
remove_indexes.append(check_idx) remove_indexes.append(check_idx)
remove_indexes.sort(reverse=True) remove_indexes.sort(reverse=True)
for idx in remove_indexes: for idx in remove_indexes:
del self.space.constraints.check[idx] del space[idx]
variables = {}
def check_replace_text(self): for index, check in enumerate(space):
for check_idx, check in enumerate(self.space.constraints.check): namespace = check.namespace
if hasattr(check, 'param'): if HIGH_COMPATIBILITY:
namespace = check.namespace if not self.paths.path_is_defined(check.target):
for idx, param in enumerate(check.param): continue
if param.type == 'variable': check.is_in_leadership = self.paths.get_leader(check.target) != None
param.text = self.paths.get_variable_path(param.text, namespace)
check.is_in_leadership = self.paths.get_leader(check.target) != None
# let's replace the target by the path # let's replace the target by the path
check.target = self.paths.get_variable_path(check.target, namespace) check.target = self.paths.get_variable_path(check.target, namespace)
if check.target not in variables:
def check_valid_enum(self): variables[check.target] = []
variables[check.target].append((index, check))
# remove check already set for a variable
remove_indexes = [] remove_indexes = []
for idx, check in enumerate(self.space.constraints.check): for checks in variables.values():
names = {}
for idx, check in checks:
if HIGH_COMPATIBILITY and check.name == 'valid_enum':
redefine = True
else:
redefine = False
#redefine = bool(check.redefine)
if redefine and check.name in names:
remove_indexes.append(names[check.name])
del names[check.name]
names[check.name] = idx
del check.index
remove_indexes.sort(reverse=True)
for idx in remove_indexes:
del space[idx]
remove_indexes = []
functions = dir(self.eosfunc)
functions.extend(['valid_enum', 'valid_in_network', 'valid_differ'])
for idx, check in enumerate(space):
if not check.name in functions:
raise CreoleDictConsistencyError(_('cannot find check function {}').format(check.name))
#is_probe = not check.name in self.eosfunc.func_on_zephir_context
#if is_probe:
# raise CreoleDictConsistencyError(_('cannot have a check with probe function ({})').format(check.name))
if check.name == 'valid_enum': if check.name == 'valid_enum':
proposed_value_type = False proposed_value_type = False
remove_params = [] remove_params = []
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))
@ -835,30 +936,30 @@ class SpaceAnnotator(object):
'for valid_enum for variable {}' 'for valid_enum for variable {}'
'').format(check.target)) '').format(check.target))
param = check.param[0] param = check.param[0]
if check.target in self.valid_enums:
raise CreoleDictConsistencyError(_('valid_enum already set for {}'
'').format(check.target))
if proposed_value_type: if proposed_value_type:
if param.type == 'variable': if param.type == 'variable':
try: try:
values = self.load_params_in_validenum(param) values = self.load_params_in_validenum(param)
except NameError as err: except NameError as err:
raise CreoleDictConsistencyError(_('cannot load value for variable {}: {}').format(check.target, err)) raise CreoleDictConsistencyError(_('cannot load value for variable {}: {}').format(check.target, err))
add_default_value = not check.is_in_leadership add_value = True
if add_default_value and values: if HIGH_COMPATIBILITY and check.is_in_leadership:
add_value = False
if add_value and values:
self.force_value[check.target] = values[0] self.force_value[check.target] = values[0]
else: else:
if check.target in self.valid_enums:
raise CreoleDictConsistencyError(_('valid_enum already set for {}'
'').format(check.target))
values = self.load_params_in_validenum(param) values = self.load_params_in_validenum(param)
self.valid_enums[check.target] = {'type': param.type, self.valid_enums[check.target] = {'type': param.type,
'values': values} 'values': values}
remove_indexes.append(idx) remove_indexes.append(idx)
remove_indexes.sort(reverse=True) remove_indexes.sort(reverse=True)
for idx in remove_indexes: for idx in remove_indexes:
del self.space.constraints.check[idx] del space[idx]
def check_change_warning(self):
#convert level to "warnings_only" and hidden to "transitive" #convert level to "warnings_only" and hidden to "transitive"
for check in self.space.constraints.check: for check in space:
if check.level == 'warning': if check.level == 'warning':
check.warnings_only = True check.warnings_only = True
else: else:
@ -870,14 +971,6 @@ class SpaceAnnotator(object):
check.transitive = False check.transitive = False
param.hidden = None param.hidden = None
def filter_check(self): # pylint: disable=C0111
# valid param in check
if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'check'):
return
self.check_check()
self.check_replace_text()
self.check_valid_enum()
self.check_change_warning()
if not self.space.constraints.check: if not self.space.constraints.check:
del self.space.constraints.check del self.space.constraints.check
@ -917,11 +1010,103 @@ 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 = self.paths.get_variable_path(param.text, namespace)
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
del_idx = []
for idx, target in enumerate(condition.target): for idx, target in enumerate(condition.target):
if target.type == 'variable': if target.type == 'variable':
if (hasattr(target, 'optional') and target.optional is True and
not self.paths.path_is_defined(target.name)):
del_idx.append(idx)
continue
if condition.source == target.name: if condition.source == target.name:
raise CreoleDictConsistencyError(_('target name and source name must be different: {}').format(condition.source)) raise CreoleDictConsistencyError(_('target name and source name must be different: {}').format(condition.source))
target.name = self.paths.get_variable_path(target.name, namespace) target.name = self.paths.get_variable_path(target.name, namespace)
@ -930,8 +1115,84 @@ class SpaceAnnotator(object):
target.name = self.paths.get_family_path(target.name, namespace) target.name = self.paths.get_family_path(target.name, namespace)
except KeyError: except KeyError:
raise CreoleDictConsistencyError(_('cannot found family {}').format(target.name)) raise CreoleDictConsistencyError(_('cannot found family {}').format(target.name))
del_idx = list(set(del_idx))
del_idx.sort(reverse=True)
for idx in del_idx:
condition.target.pop(idx)
def convert_xxxlist_to_variable(self): # pylint: disable=C0111 def filter_condition_servicelist(self):
# automatic generation of the service_access lists
# and the service_restriction lists from the servicelist
for condition in self.space.constraints.condition:
if hasattr(condition, 'target'):
new_targets = []
for target in condition.target:
if target.type == 'servicelist':
new_target = copy(target)
new_target.type = 'service_accesslist'
new_target.name = '___auto_{}'.format(new_target.name)
new_targets.append(new_target)
new_target = copy(target)
new_target.type = 'service_restrictionlist'
new_target.name = '___auto_{}'.format(new_target.name)
new_targets.append(new_target)
condition.target.extend(new_targets)
def check_condition_without_target(self):
for condition in self.space.constraints.condition:
if not hasattr(condition, 'target'):
raise CreoleDictConsistencyError(_('target is mandatory in condition'))
def check_condition_fallback_not_exists(self, fallback_variables, fallback_lists):
# a condition with a fallback **and** the source variable doesn't exist
remove_conditions = []
for idx, condition in enumerate(self.space.constraints.condition):
if (hasattr(condition, 'fallback') and condition.fallback is True and
not self.paths.path_is_defined(condition.source)):
for target in condition.target:
if target.type in ['variable', 'family']:
name = target.name.split('.')[-1]
if target.type == 'variable':
variable = self.get_variable(name)
else:
variable = self.paths.get_family_obj(name)
if condition.name in ['disabled_if_in']:
variable.disabled = True
if condition.name in ['mandatory_if_in']:
variable.mandatory = True
if condition.name in ['disabled_if_in', 'disabled_if_not_in',
'frozen_if_in', 'frozen_if_not_in']:
variable.hidden = False
if HIGH_COMPATIBILITY:
fallback_variables.append(name)
else:
listname = target.type
if not listname.endswith('list'):
raise Exception('not yet implemented')
listvars = self.objectspace.list_conditions.get(listname,
{}).get(target.name)
if listvars:
for listvar in listvars:
try:
variable = self.get_variable(listvar)
except CreoleDictConsistencyError:
variable = self.paths.get_family_obj(listvar)
if condition.name in ['disabled_if_in']:
variable.disabled = True
if condition.name in ['mandatory_if_in']:
variable.mandatory = True
if condition.name in ['disabled_if_in', 'disabled_if_not_in',
'frozen_if_in', 'frozen_if_not_in']:
variable.hidden = False
fallback_lists.append(listvar)
remove_conditions.append(idx)
remove_conditions = list(set(remove_conditions))
remove_conditions.sort(reverse=True)
for idx in remove_conditions:
self.space.constraints.condition.pop(idx)
def convert_xxxlist_to_variable(self, fallback_lists): # pylint: disable=C0111
# transform *list to variable or family # transform *list to variable or family
for condition_idx, condition in enumerate(self.space.constraints.condition): for condition_idx, condition in enumerate(self.space.constraints.condition):
new_targets = [] new_targets = []
@ -945,8 +1206,14 @@ class SpaceAnnotator(object):
{}).get(target.name) {}).get(target.name)
if listvars: if listvars:
for listvar in listvars: for listvar in listvars:
variable = self.paths.get_variable_obj(listvar) if listvar in fallback_lists:
type_ = 'variable' continue
try:
variable = self.get_variable(listvar)
type_ = 'variable'
except CreoleDictConsistencyError:
variable = self.paths.get_family_obj(listvar)
type_ = 'family'
new_target = self.objectspace.target() new_target = self.objectspace.target()
new_target.type = type_ new_target.type = type_
new_target.name = listvar new_target.name = listvar
@ -960,71 +1227,25 @@ class SpaceAnnotator(object):
condition.target.extend(new_targets) condition.target.extend(new_targets)
def check_condition(self): def check_condition(self):
# if condition.name == 'hidden_if_in':
# condition.name = 'disabled_if_in'
# elif condition.name == 'hidden_if_not_in':
# condition.name = 'disabled_if_not_in'
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
if condition.name not in ['disabled_if_in', 'disabled_if_not_in', 'hidden_if_in', 'auto_hidden_if_not_in', if condition.name not in ['disabled_if_in', 'disabled_if_not_in', 'frozen_if_in', 'auto_frozen_if_in',
'hidden_if_not_in', 'mandatory_if_in', 'mandatory_if_not_in']: 'frozen_if_not_in', 'mandatory_if_in', 'mandatory_if_not_in']:
raise CreoleDictConsistencyError(_(f'unknown condition {condition.name}')) raise CreoleDictConsistencyError(_('unknown condition {}').format(condition.name))
def check_params(self): def check_params(self):
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
for param in condition.param: for param in condition.param:
if param.type not in TYPE_PARAM_CONDITION: if param.type not in TYPE_PARAM_CONDITION:
raise CreoleDictConsistencyError(_(f'cannot use {param.type} type as a param in a condition')) raise CreoleDictConsistencyError(_('cannot use {} type as a param '
'in a condition').format(param.type))
if param.type == 'eole':
param.type = 'variable'
def check_target(self): def check_choice_option_condition(self, force_remove_targets):
for condition in self.space.constraints.condition:
if not hasattr(condition, 'target'):
raise CreoleDictConsistencyError(_('target is mandatory in condition'))
for target in condition.target:
if target.type.endswith('list') and condition.name not in ['disabled_if_in', 'disabled_if_not_in']:
raise CreoleDictConsistencyError(_(f'target in condition for {target.type} not allow in {condition.name}'))
def check_condition_fallback_optional(self):
# a condition with a fallback **and** the source variable doesn't exist
remove_conditions = []
for idx, condition in enumerate(self.space.constraints.condition):
remove_targets = []
if condition.fallback is True and not self.paths.path_is_defined(condition.source):
for target in condition.target:
if target.type in ['variable', 'family']:
if target.name.startswith(VARIABLE_NAMESPACE + '.'):
name = target.name.split('.')[-1]
else:
name = target.name
if target.type == 'variable':
variable = self.paths.get_variable_obj(name)
else:
variable = self.paths.get_family_obj(name)
if condition.name == 'disabled_if_in':
variable.disabled = True
if condition.name == 'mandatory_if_in':
variable.mandatory = True
if condition.name == 'hidden_if_in':
variable.hidden = True
else:
listname = target.type
listvars = self.objectspace.list_conditions.get(listname,
{}).get(target.name, None)
if listvars is not None:
for listvar in listvars:
variable = self.paths.get_variable_obj(listvar)
if condition.name in ['disabled_if_in']:
variable.value[0].name = False
del self.objectspace.list_conditions[listname][target.name]
remove_conditions.append(idx)
for idx, target in enumerate(condition.target):
if target.optional is True and not self.paths.path_is_defined(target.name):
remove_targets.append(idx)
remove_targets = list(set(remove_targets))
remove_targets.sort(reverse=True)
for idx in remove_targets:
condition.target.pop(idx)
remove_conditions = list(set(remove_conditions))
remove_conditions.sort(reverse=True)
for idx in remove_conditions:
self.space.constraints.condition.pop(idx)
def check_choice_option_condition(self):
# remove condition for ChoiceOption that don't have param # remove condition for ChoiceOption that don't have param
remove_conditions = [] remove_conditions = []
for condition_idx, condition in enumerate(self.space.constraints.condition): for condition_idx, condition in enumerate(self.space.constraints.condition):
@ -1046,54 +1267,69 @@ class SpaceAnnotator(object):
for idx in remove_param: for idx in remove_param:
del condition.param[idx] del condition.param[idx]
if condition.param == []: if condition.param == []:
remove_targets = []
for target in condition.target: for target in condition.target:
if target.name.startswith(f'{VARIABLE_NAMESPACE}.'): if target.name.startswith('creole.'):
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
else: else:
name = target.name name = target.name
if target.type == 'variable': if target.type == 'variable':
variable = self.paths.get_variable_obj(name) variable = self.get_variable(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':
variable.disabled = True variable.disabled = True
elif condition.name == 'hidden_if_not_in': force_remove_targets.setdefault(condition.name,
[]).append(target.name)
elif condition.name == 'frozen_if_not_in':
variable.hidden = True variable.hidden = True
force_remove_targets.setdefault(condition.name,
[]).append(target.name)
elif condition.name == 'mandatory_if_not_in': elif condition.name == 'mandatory_if_not_in':
variable.mandatory = True variable.mandatory = True
remove_targets = list(set(remove_targets)) force_remove_targets.setdefault(condition.name,
remove_targets.sort(reverse=True) []).append(target.name)
for target_idx in remove_targets: elif HIGH_COMPATIBILITY and condition.name == 'disabled_if_in':
condition.target.pop(target_idx) 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)
for idx in remove_conditions: for idx in remove_conditions:
self.space.constraints.condition.pop(idx) self.space.constraints.condition.pop(idx)
def manage_variable_property(self): def manage_variable_property(self, force_remove_targets, fallback_variables):
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
remove_targets = []
#parse each variable and family #parse each variable and family
for target_idx, target in enumerate(condition.target): for target_idx, target in enumerate(condition.target):
if target.name.startswith(f'{VARIABLE_NAMESPACE}.'): if target.name in force_remove_targets.get(condition.name, []):
remove_targets.append(target_idx)
if target.name.startswith('creole.'):
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
else: else:
name = target.name name = target.name
if target.type == 'variable': if target.type == 'variable':
variable = self.paths.get_variable_obj(name) variable = self.get_variable(name)
else: else:
variable = self.paths.get_family_obj(name) variable = self.paths.get_family_obj(name)
if condition.name in ['hidden_if_in', 'hidden_if_not_in']: if name in fallback_variables:
remove_targets.append(target_idx)
continue
if condition.name in ['disabled_if_in', 'disabled_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
if HIGH_COMPATIBILITY and condition.name in ['hidden_if_in', if HIGH_COMPATIBILITY and condition.name in ['frozen_if_in',
'hidden_if_not_in']: 'frozen_if_not_in']:
self.has_hidden_if_in_condition.append(name) self.has_frozen_if_in_condition.append(name)
if condition.name in ['mandatory_if_in', 'mandatory_if_not_in']: if condition.name in ['mandatory_if_in', 'mandatory_if_not_in']:
self.force_not_mandatory.append(target.name) self.force_not_mandatory.append(target.name)
remove_targets = list(set(remove_targets))
remove_targets.sort(reverse=True)
for target_idx in remove_targets:
condition.target.pop(target_idx)
def remove_condition_with_empty_target(self): def remove_condition_with_empty_target(self):
remove_conditions = [] remove_conditions = []
for condition_idx, condition in enumerate(self.space.constraints.condition): for condition_idx, condition in enumerate(self.space.constraints.condition):
@ -1107,37 +1343,53 @@ class SpaceAnnotator(object):
def filter_condition(self): # pylint: disable=C0111 def filter_condition(self): # pylint: disable=C0111
if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'condition'): if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'condition'):
return return
fallback_variables = []
fallback_lists = []
force_remove_targets = {}
self.check_condition() self.check_condition()
self.check_params() self.check_params()
self.check_target() self.check_condition_without_target()
self.check_condition_fallback_optional() self.filter_condition_servicelist()
self.check_condition_fallback_not_exists(fallback_variables, fallback_lists)
self.filter_targets() self.filter_targets()
self.convert_xxxlist_to_variable() self.convert_xxxlist_to_variable(fallback_lists)
self.check_choice_option_condition() self.check_choice_option_condition(force_remove_targets)
self.manage_variable_property() self.manage_variable_property(force_remove_targets, fallback_variables)
self.remove_condition_with_empty_target() self.remove_condition_with_empty_target()
for condition in self.space.constraints.condition: for condition in self.space.constraints.condition:
inverse = condition.name.endswith('_if_not_in') if condition.name == 'disabled_if_in':
if condition.name.startswith('disabled_if_'):
actions = ['disabled'] actions = ['disabled']
elif condition.name.startswith('hidden_if_'): inverse = False
elif condition.name == 'disabled_if_not_in':
actions = ['disabled']
inverse = True
elif condition.name == 'frozen_if_in':
actions = ['frozen', 'hidden', 'force_default_on_freeze'] actions = ['frozen', 'hidden', 'force_default_on_freeze']
elif condition.name.startswith('mandatory_if_'): inverse = False
elif condition.name == 'frozen_if_not_in':
actions = ['frozen', 'hidden', 'force_default_on_freeze']
inverse = True
elif condition.name == 'mandatory_if_in':
actions = ['mandatory'] actions = ['mandatory']
elif condition.name == 'auto_hidden_if_not_in': inverse = False
elif condition.name == 'mandatory_if_not_in':
actions = ['mandatory']
inverse = True
elif condition.name == 'auto_frozen_if_in':
actions = ['auto_frozen'] actions = ['auto_frozen']
inverse = True
for param in condition.param: for param in condition.param:
if hasattr(param, 'text'): if hasattr(param, 'text'):
param = param.text param = param.text
else: else:
param = None param = None
for target in condition.target: for target in condition.target:
if target.name.startswith(f'{VARIABLE_NAMESPACE}.'): if target.name.startswith('creole.'):
name = target.name.split('.')[-1] name = target.name.split('.')[-1]
else: else:
name = target.name name = target.name
if target.type == 'variable': if target.type == 'variable':
variable = self.paths.get_variable_obj(name) variable = self.get_variable(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

@ -13,7 +13,7 @@
# Forked by: # Forked by:
# Cadoles (http://www.cadoles.com) # Cadoles (http://www.cadoles.com)
# Copyright (C) 2019-2020 # Copyright (C) 2019
# distribued with GPL-2 or later license # distribued with GPL-2 or later license
@ -37,22 +37,54 @@
<!-- root element --> <!-- root element -->
<!-- =============== --> <!-- =============== -->
<!ELEMENT rougail (services | variables | constraints | help)*> <!ELEMENT rougail (services | family_action | 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*)*)>
<!ATTLIST action type (form|custom|external|reader|apache) "custom">
<!ATTLIST action title CDATA #REQUIRED>
<!ATTLIST action description CDATA #REQUIRED>
<!ATTLIST action rewrite CDATA #IMPLIED>
<!ATTLIST action image CDATA #IMPLIED>
<!ATTLIST action actionlist CDATA #IMPLIED>
<!-- for apache action -->
<!ATTLIST action apache_path CDATA #IMPLIED>
<!ATTLIST action apache_path_type (FilenameOption|SymLinkOption|variable) "FilenameOption">
<!-- for external action -->
<!ATTLIST action url CDATA #IMPLIED>
<!ATTLIST action url_type (URLOption|SymLinkOption|variable) "URLOption">
<!-- for form action -->
<!ATTLIST action save (True|False) "False">
<!ELEMENT services (service*)> <!ELEMENT services (service*)>
<!ELEMENT service ((port* | tcpwrapper* | ip* | interface* | package* | file* | digitalcertificate* | override*)*) > <!ELEMENT service ((port* | tcpwrapper* | ip* | interface* | package* | file* | digitalcertificate*)*) >
<!ATTLIST service name CDATA #REQUIRED> <!ATTLIST service name CDATA #REQUIRED>
<!ATTLIST service method (systemd|upstart|apache|network) "systemd">
<!ELEMENT input (#PCDATA)>
<!ELEMENT profile (#PCDATA)>
<!ELEMENT ewtapp (#PCDATA)>
<!ELEMENT tag (#PCDATA)>
<!ELEMENT saltaction (#PCDATA)>
<!ELEMENT port (#PCDATA)> <!ELEMENT port (#PCDATA)>
<!ATTLIST port port_type (PortOption|SymLinkOption|variable) "PortOption"> <!ATTLIST port port_type (PortOption|SymLinkOption|variable) "PortOption">
<!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">
@ -61,6 +93,9 @@
<!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">
@ -71,8 +106,9 @@
<!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">
<!ELEMENT digitalcertificate EMPTY> <!ELEMENT digitalcertificate EMPTY>
<!ATTLIST digitalcertificate name CDATA #REQUIRED > <!ATTLIST digitalcertificate name CDATA #REQUIRED >
@ -82,15 +118,12 @@
<!ATTLIST digitalcertificate type CDATA #REQUIRED > <!ATTLIST digitalcertificate type CDATA #REQUIRED >
<!ATTLIST digitalcertificate ca CDATA #REQUIRED > <!ATTLIST digitalcertificate ca CDATA #REQUIRED >
<!ELEMENT override EMPTY>
<!ATTLIST override source CDATA #IMPLIED >
<!ATTLIST override templating (True|False) "True">
<!ELEMENT variables (family*, separators*)> <!ELEMENT variables (family*, separators*)>
<!ELEMENT family (#PCDATA | variable)*> <!ELEMENT family (#PCDATA | variable)*>
<!ATTLIST family name CDATA #REQUIRED> <!ATTLIST family name CDATA #REQUIRED>
<!ATTLIST family description CDATA #IMPLIED> <!ATTLIST family description CDATA #IMPLIED>
<!ATTLIST family mode (basic|normal|expert) "basic"> <!ATTLIST family mode (basic|normal|expert) "basic">
<!ATTLIST family icon CDATA #IMPLIED>
<!ATTLIST family hidden (True|False) "False"> <!ATTLIST family hidden (True|False) "False">
<!ATTLIST family dynamic CDATA #IMPLIED> <!ATTLIST family dynamic CDATA #IMPLIED>
@ -116,10 +149,11 @@
<!ELEMENT separator (#PCDATA)> <!ELEMENT separator (#PCDATA)>
<!ATTLIST separator name CDATA #REQUIRED> <!ATTLIST separator name CDATA #REQUIRED>
<!ATTLIST separator never_hidden CDATA #IMPLIED>
<!ELEMENT value (#PCDATA)> <!ELEMENT value (#PCDATA)>
<!ELEMENT constraints ((fill* | check* | condition* | group*)*)> <!ELEMENT constraints ((fill* | check* | condition* | auto* | 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>
@ -129,13 +163,17 @@
<!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>
<!ATTLIST condition fallback (True|False) "False"> <!ATTLIST condition fallback (True|False) "False">
<!ELEMENT group (follower+)> <!ELEMENT group (slave+)>
<!ATTLIST group leader CDATA #REQUIRED> <!ATTLIST group master CDATA #REQUIRED>
<!ATTLIST group description CDATA #IMPLIED> <!ATTLIST group description CDATA #IMPLIED>
<!ELEMENT param (#PCDATA)> <!ELEMENT param (#PCDATA)>
@ -145,9 +183,9 @@
<!ATTLIST param optional (True|False) "False"> <!ATTLIST param optional (True|False) "False">
<!ELEMENT target (#PCDATA)> <!ELEMENT target (#PCDATA)>
<!ATTLIST target type (family|variable|filelist|iplist|portlist) "variable"> <!ATTLIST target type (family|variable|filelist|iplist|portlist|tcpwrapperlist|packagelist|actionlist) "variable">
<!ATTLIST target optional (True|False) "False"> <!ATTLIST target optional (True|False) "False">
<!ELEMENT follower (#PCDATA)> <!ELEMENT slave (#PCDATA)>
<!ELEMENT help ((variable* | family*)*)> <!ELEMENT help ((variable* | family*)*)>

View File

@ -34,7 +34,3 @@ class CreoleDictConsistencyError(Exception):
"""It's not only that the Creole XML is valid against the Creole DTD """It's not only that the Creole XML is valid against the Creole DTD
it's that it is not consistent. it's that it is not consistent.
""" """
class CreoleLoaderError(Exception):
pass

View File

@ -24,7 +24,7 @@ import sys
import locale import locale
# Application Name # Application Name
APP_NAME = 'rougail' APP_NAME = 'creole'
# Traduction dir # Traduction dir
APP_DIR = os.path.join(sys.prefix, 'share') APP_DIR = os.path.join(sys.prefix, 'share')
@ -44,8 +44,8 @@ mo_location = LOCALE_DIR
gettext.find(APP_NAME, mo_location) gettext.find(APP_NAME, mo_location)
gettext.textdomain(APP_NAME) gettext.textdomain(APP_NAME)
#gettext.bind_textdomain_codeset(APP_NAME, "UTF-8") gettext.bind_textdomain_codeset(APP_NAME, "UTF-8")
#gettext.translation(APP_NAME, fallback=True) gettext.translation(APP_NAME, fallback=True)
t = gettext.translation(APP_NAME, fallback=True) t = gettext.translation(APP_NAME, fallback=True)

View File

@ -1,26 +1,31 @@
"""loader """creole loader
flattened XML specific flattened XML specific
""" """
from os.path import join, isfile from os.path import join, isfile, isdir
from lxml.etree import DTD from os import listdir
import imp #from ast import literal_eval
from lxml.etree import parse, DTD
from tiramisu import (StrOption, OptionDescription, DynOptionDescription, PortOption, from tiramisu import (StrOption, OptionDescription, DynOptionDescription, PortOption,
IntOption, ChoiceOption, BoolOption, SymLinkOption, IPOption, IntOption, ChoiceOption, BoolOption, SymLinkOption, IPOption,
NetworkOption, NetmaskOption, DomainnameOption, BroadcastOption, NetworkOption, NetmaskOption, DomainnameOption, BroadcastOption,
URLOption, EmailOption, FilenameOption, UsernameOption, DateOption, URLOption, EmailOption, FilenameOption, UsernameOption, DateOption,
PasswordOption, BoolOption, MACOption, Leadership, submulti, PasswordOption, BoolOption, MACOption, Leadership, submulti,
Params, ParamSelfOption, ParamOption, ParamDynOption, ParamValue, Calculation, calc_value) Params, ParamSelfOption, ParamOption, ParamValue, Calculation, calc_value,
groups, owners)
from tiramisu.error import ConfigError
from .config import dtdfilename from .config import dtdfilename
from .i18n import _ from .i18n import _
#For compatibility
from .xmlreflector import HIGH_COMPATIBILITY
#from . import eosfunc
from .objspace import CreoleObjSpace
from .utils import normalize_family from .utils import normalize_family
from .annotator import VARIABLE_NAMESPACE import imp
from .error import CreoleLoaderError
FUNC_TO_DICT = ['valid_not_equal'] FUNC_TO_DICT = ['valid_not_equal']
KNOWN_TAGS = ['family', 'variable', 'separators', 'leader', 'property']
class ConvertDynOptionDescription(DynOptionDescription): class ConvertDynOptionDescription(DynOptionDescription):
@ -31,11 +36,19 @@ class ConvertDynOptionDescription(DynOptionDescription):
check_name=False) check_name=False)
class CreoleLoaderError(Exception):
pass
def convert_tiramisu_value(value, obj): def convert_tiramisu_value(value, obj):
""" """
convertit les variables dans le bon type si nécessaire convertit les variables dans le bon type si nécessaire
""" """
if value is None:
return value
def _convert_boolean(value): def _convert_boolean(value):
if isinstance(value, bool):
return value
prop = {'True': True, prop = {'True': True,
'False': False, 'False': False,
'None': None} 'None': None}
@ -43,9 +56,10 @@ def convert_tiramisu_value(value, obj):
raise Exception('unknown value {} while trying to cast {} to boolean'.format(value, obj)) raise Exception('unknown value {} while trying to cast {} to boolean'.format(value, obj))
return prop[value] return prop[value]
if value is None: func = {IntOption: int, StrOption: str, PortOption: str,
return value DomainnameOption: str, EmailOption: str, URLOption: str,
func = {IntOption: int, IPOption: str, NetmaskOption: str, NetworkOption: str,
BroadcastOption: str, FilenameOption: str,
BoolOption: _convert_boolean}.get(obj, None) BoolOption: _convert_boolean}.get(obj, None)
if func is None: if func is None:
return value return value
@ -60,7 +74,7 @@ CONVERT_OPTION = {'number': dict(opttype=IntOption),
'string': dict(opttype=StrOption), 'string': dict(opttype=StrOption),
'password': dict(opttype=PasswordOption), 'password': dict(opttype=PasswordOption),
'mail': dict(opttype=EmailOption), 'mail': dict(opttype=EmailOption),
'boolean': dict(opttype=BoolOption, initkwargs={'default': True}), 'boolean': dict(opttype=BoolOption),
'symlink': dict(opttype=SymLinkOption), 'symlink': dict(opttype=SymLinkOption),
'filename': dict(opttype=FilenameOption), 'filename': dict(opttype=FilenameOption),
'date': dict(opttype=DateOption), 'date': dict(opttype=DateOption),
@ -83,15 +97,18 @@ CONVERT_OPTION = {'number': dict(opttype=IntOption),
} }
class Elt: class Elt(object):
def __init__(self, attrib): def __init__(self, attrib):
self.attrib = attrib self.attrib = attrib
class PopulateTiramisuObjects: class PopulateTiramisuObjects(object):
def __init__(self): def __init__(self):
self.storage = ElementStorage() self.storage = ElementStorage()
self.booleans = [] self.booleans = []
self.force_store_values = set()
self.separators = {}
self.groups = {}
def parse_dtd(self, dtdfilename): def parse_dtd(self, dtdfilename):
"""Loads the Creole DTD """Loads the Creole DTD
@ -110,111 +127,129 @@ class PopulateTiramisuObjects:
if set(attr.itervalues()) == set(['True', 'False']): if set(attr.itervalues()) == set(['True', 'False']):
self.booleans.append(attr.name) self.booleans.append(attr.name)
def get_root_family(self): def make_tiramisu_objects(self, xmlroot, creolefunc_file):
family = Family(Elt({'name': 'baseoption', elt = Elt({'name': 'baseoption'})
'doc': 'baseoption'}), if creolefunc_file is None:
self.booleans, self.eosfunc = None
self.storage, else:
self.eosfunc, self.eosfunc = imp.load_source('eosfunc', creolefunc_file)
) family = Family(elt, self.booleans, self.storage, self.eosfunc)
self.storage.add('.', family) self.storage.add('.', family)
elts = {}
for elt in xmlroot:
elts.setdefault(elt.tag, []).append(elt)
list_elts = list(elts.keys())
if 'family' in list_elts:
list_elts.remove('family')
list_elts.insert(0, 'family')
for elt in list_elts:
xmlelts_ = elts[elt]
if elt == 'family':
xmlelts = []
actions = None
# `creole` family has to be loaded before any other family
# because `extra` family could use `creole` variables.
# `actions` family has to be loaded at the very end
# because it may use `creole` or `extra` variables
for xml in xmlelts_:
if xml.attrib['name'] == 'creole':
xmlelts.insert(0, xml)
elif xml.attrib['name'] == 'actions':
actions = xml
else:
xmlelts.append(xml)
if actions is not None:
xmlelts.append(actions)
else:
xmlelts = xmlelts_
for xmlelt in xmlelts:
if xmlelt.tag != 'family':
raise CreoleLoaderError(_('unknown tag {}').format(xmlelt.tag))
self._iter_family(xmlelt, family)
def _populate_variable(self, elt, subpath, is_follower, is_leader):
variable = Variable(elt, self.booleans, self.storage, is_follower, is_leader, self.eosfunc)
path = self._build_path(subpath, elt)
properties = variable.attrib.get('properties', [])
if 'force_store_value' in properties or "auto_freeze" in properties:
self.force_store_values.add(path)
self.storage.add(path, variable)
return variable
def _populate_family(self, elt, subpath):
if subpath is None:
force_icon = False
else:
force_icon = not subpath.startswith('containers') and not subpath.startswith('actions')
family = Family(elt, self.booleans, self.storage, self.eosfunc, force_icon)
path = self._build_path(subpath, elt)
self.storage.add(path, family)
return family return family
def reorder_family(self, xmlroot): def _build_path(self, subpath, elt):
xmlelts = [] if subpath is None:
for xmlelt in xmlroot: subpath = elt.attrib['name']
# VARIABLE_NAMESPACE family has to be loaded before any other family else:
# because `extra` family could use `VARIABLE_NAMESPACE` variables. subpath += '.' + elt.attrib['name']
if xmlelt.attrib['name'] == VARIABLE_NAMESPACE: return subpath
xmlelts.insert(0, xmlelt)
def _iter_leader(self, leader, subpath):
subpath = self._build_path(subpath, leader)
family = Family(leader, self.booleans, self.storage, self.eosfunc)
family.set_leader()
self.storage.add(subpath, family)
leader_name = None
for var in leader:
if var.tag == 'property':
self._parse_properties(family, var)
elif var.tag == 'variable':
if leader_name is None:
leader_name = var.attrib['name']
self.groups[leader_name] = []
else:
self.groups[leader_name].append(var.attrib['name'])
self._iter_family(var, family, subpath=subpath)
else: else:
xmlelts.append(xmlelt) raise CreoleLoaderError(_('unknown tag {}').format(var.tag))
return xmlelts return family
def make_tiramisu_objects(self, xmlroot, eosfunc): def _iter_family(self, child, family, subpath=None):
self.eosfunc = imp.load_source('eosfunc', eosfunc) if child.tag not in ['family', 'variable', 'separators', 'leader', 'property']:
family = self.get_root_family()
for xmlelt in self.reorder_family(xmlroot):
self.iter_family(xmlelt,
family,
None,
)
def iter_family(self,
child,
family,
subpath,
):
if child.tag not in KNOWN_TAGS:
raise CreoleLoaderError(_('unknown tag {}').format(child.tag)) raise CreoleLoaderError(_('unknown tag {}').format(child.tag))
if child.tag in ['family', 'leader']: if child.tag == 'family':
self.populate_family(family, old_family = family
child, family = self._populate_family(child, subpath)
subpath, if old_family is not None:
) old_family.add(family)
if len(child) != 0:
subpath = self._build_path(subpath, child)
for c in child:
self._iter_family(c, family, subpath=subpath)
elif child.tag == 'leader':
leader = self._iter_leader(child, subpath)
family.add(leader)
elif child.tag == 'separators': elif child.tag == 'separators':
self.parse_separators(child) self._parse_separators(child)
elif child.tag == 'variable': elif child.tag == 'variable':
self.populate_variable(child, subpath, family) if family is None:
raise CreoleLoaderError(_('variable without family'))
is_follower = False
is_leader = False
if family.is_leader:
if child.attrib['name'] != family.attrib['name']:
is_follower = True
else:
is_leader = True
variable = self._populate_variable(child, subpath, is_follower, is_leader)
family.add(variable)
elif child.tag == 'property': elif child.tag == 'property':
self.parse_properties(family, child) self._parse_properties(family, child)
else: else:
raise Exception('unknown tag {}'.format(child.tag)) raise Exception('unknown tag {}'.format(child.tag))
def populate_family(self, def _parse_properties(self, family, child):
parent_family,
elt,
subpath,
):
path = self.build_path(subpath,
elt,
)
family = Family(elt,
self.booleans,
self.storage,
self.eosfunc,
)
self.storage.add(path, family)
if elt.tag == 'leader':
family.set_leader()
parent_family.add(family)
if len(elt) != 0:
for child in elt:
self.iter_family(child,
family,
path,
)
def parse_separators(self,
separators,
):
for separator in separators:
elt = self.storage.get(separator.attrib['name'])
elt.add_information('separator', separator.text)
def populate_variable(self, elt, subpath, family):
is_follower = False
is_leader = False
if family.is_leader:
if elt.attrib['name'] != family.attrib['name']:
is_follower = True
else:
is_leader = True
path = self.build_path(subpath,
elt,
)
variable = Variable(elt,
self.booleans,
self.storage,
is_follower,
is_leader,
self.eosfunc,
)
self.storage.add(path, variable)
family.add(variable)
def parse_properties(self, family, child):
if child.get('type') == 'calculation': if child.get('type') == 'calculation':
kwargs = {'condition': child.attrib['source'], kwargs = {'condition': child.attrib['source'],
'expected': ParamValue(child.attrib.get('expected'))} 'expected': ParamValue(child.attrib.get('expected'))}
@ -224,13 +259,17 @@ class PopulateTiramisuObjects:
else: else:
family.attrib['properties'].append(child.text) family.attrib['properties'].append(child.text)
def build_path(self, def _parse_separators(self, separators):
subpath, for separator in separators:
elt, elt = self.storage.get(separator.attrib['name'])
): never_hidden = separator.attrib.get('never_hidden')
if subpath is None: if never_hidden == 'True':
return elt.attrib['name'] never_hidden = True
return subpath + '.' + elt.attrib['name'] else:
never_hidden = None
info = (separator.text, never_hidden)
self.separators[separator.attrib['name']] = info
elt.add_information('separator', info)
class ElementStorage: class ElementStorage:
@ -242,6 +281,10 @@ class ElementStorage:
raise CreoleLoaderError(_('path already loaded {}').format(path)) raise CreoleLoaderError(_('path already loaded {}').format(path))
self.paths[path] = elt self.paths[path] = elt
def add_information(self, path, name, information):
elt = self.get(path)
elt.add_information(name, information)
def get(self, path): def get(self, path):
if path not in self.paths: if path not in self.paths:
raise CreoleLoaderError(_('there is no element for path {}').format(path)) raise CreoleLoaderError(_('there is no element for path {}').format(path))
@ -269,121 +312,112 @@ class Variable(Common):
self.option = None self.option = None
self.informations = {} self.informations = {}
self.attrib = {} self.attrib = {}
convert_option = CONVERT_OPTION[elt.attrib['type']] self.attrib['properties'] = []
if 'initkwargs' in convert_option:
self.attrib.update(convert_option['initkwargs'])
if elt.attrib['type'] != 'symlink':
self.attrib['properties'] = []
self.attrib['validators'] = [] self.attrib['validators'] = []
self.eosfunc = eosfunc self.eosfunc = eosfunc
self.storage = storage self.storage = storage
self.booleans = booleans is_submulti = False
self.populate_attrib(elt)
self.is_follower = is_follower
self.is_leader = is_leader
self.object_type = convert_option['opttype']
self.populate_choice(elt)
for child in elt:
self.populate_property(child)
self.populate_value(child)
self.populate_check(child)
if elt.attrib['type'] == 'symlink':
self.attrib['opt'] = storage.get(self.attrib['opt'])
def populate_attrib(self,
elt,
):
for key, value in elt.attrib.items(): for key, value in elt.attrib.items():
if key == 'multi' and elt.attrib['type'] == 'symlink': if key in booleans:
continue
if key == 'multi' and value == 'submulti':
value = submulti
elif key in self.booleans:
if value == 'True': if value == 'True':
value = True value = True
elif value == 'False': elif value == 'False':
value = False value = False
elif key == 'multi' and value == 'submulti':
is_submulti = True
value = submulti
else: else:
raise CreoleLoaderError(_('unknown value {} for {}').format(value, key)) raise CreoleLoaderError(_('unknown value {} for {}').format(value, key))
if key in ['help', 'test']: if key in ['help', 'test']:
self.add_information(key, value) self.add_information(key, value)
elif key != 'type': elif key == 'type':
pass
else:
self.attrib[key] = value self.attrib[key] = value
convert_option = CONVERT_OPTION[elt.attrib['type']]
def populate_choice(self, self.object_type = convert_option['opttype']
elt,
):
if elt.attrib['type'] == 'choice': if elt.attrib['type'] == 'choice':
values = [] if self.attrib.get('choice'):
for child in elt: self.attrib['values'] = getattr(self.eosfunc, self.attrib.get('choice'))
if child.tag == 'choice':
value = child.text
if child.attrib['type'] == 'number':
value = int(value)
values.append(value)
self.attrib['values'] = tuple(values)
def populate_property(self, child):
if child.tag == 'property':
if child.get('type') == 'calculation':
kwargs = {'condition': child.attrib['source'],
'expected': ParamValue(child.attrib.get('expected'))}
if child.attrib['inverse'] == 'True':
kwargs['reverse_condition'] = ParamValue(True)
self.attrib['properties'].append((ParamValue(child.text), kwargs))
else: else:
self.attrib['properties'].append(child.text) self.attrib['values'] = []
for child in elt:
def populate_value(self, child): if child.tag == 'choice':
if child.tag == 'value': value = child.text
if child.attrib.get('type') == 'calculation': if 'type' in child.attrib and child.attrib['type'] == 'number':
if child.text is not None and child.text.strip(): value = int(value)
self.attrib['default'] = (child.text.strip(),) if value is None:
value = u''
self.attrib['values'].append(value)
self.attrib['values'] = tuple(self.attrib['values'])
for child in elt:
if child.tag == 'property':
if child.get('type') == 'calculation':
kwargs = {'condition': child.attrib['source'],
'expected': ParamValue(child.attrib.get('expected'))}
if child.attrib['inverse'] == 'True':
kwargs['reverse_condition'] = ParamValue(True)
self.attrib['properties'].append((ParamValue(child.text), kwargs))
else: else:
params = [] self.attrib['properties'].append(child.text)
for param in child: elif child.tag == 'value':
params.append(self.parse_param(param)) if child.attrib.get('type') == 'calculation':
self.attrib['default'] = (child.attrib['name'], params, False) if child.text is not None and child.text.strip():
else: self.attrib['default'] = (child.text.strip(),)
if "type" in child.attrib:
type_ = CONVERT_OPTION[child.attrib['type']]['opttype']
else:
type_ = self.object_type
if self.attrib['multi'] is True and not self.is_follower:
if 'default' not in self.attrib:
self.attrib['default'] = []
value = convert_tiramisu_value(child.text, type_)
self.attrib['default'].append(value)
if 'default_multi' not in self.attrib and not self.is_leader:
self.attrib['default_multi'] = value
elif self.attrib['multi'] == submulti:
if 'default' not in self.attrib:
self.attrib['default'] = []
value = convert_tiramisu_value(child.text, type_)
if not self.is_follower:
if not isinstance(value, list):
dvalue = [value]
else:
dvalue = value
self.attrib['default'].append(dvalue)
if value and 'default_multi' not in self.attrib and not self.is_leader:
self.attrib['default_multi'] = []
if not self.is_leader:
self.attrib['default_multi'].append(value)
else:
value = convert_tiramisu_value(child.text, type_)
if self.is_follower:
self.attrib['default_multi'] = value
else: else:
self.attrib['default'] = value params = []
for param in child:
def populate_check(self, child): params.append(self.parse_param(param))
if child.tag == 'check': self.attrib['default'] = (child.attrib['name'], params, False)
params = [] else:
for param in child: if "type" in child.attrib:
params.append(self.parse_param(param)) type_ = CONVERT_OPTION[child.attrib['type']]['opttype']
#check.params = params else:
self.attrib['validators'].append((child.attrib['name'], params, child.attrib['warnings_only'])) type_ = self.object_type
if self.attrib['multi'] is True and not is_follower:
if 'default' not in self.attrib:
self.attrib['default'] = []
value = convert_tiramisu_value(child.text, type_)
self.attrib['default'].append(value)
if 'default_multi' not in self.attrib and not is_leader:
self.attrib['default_multi'] = value
elif self.attrib['multi'] == submulti:
if 'default' not in self.attrib:
self.attrib['default'] = []
value = convert_tiramisu_value(child.text, type_)
if not isinstance(value, list) and not is_follower:
value = [value]
self.attrib['default'].append(value)
if 'default_multi' not in self.attrib and not is_leader:
self.attrib['default_multi'] = value
else:
if 'default' in self.attrib:
raise CreoleLoaderError(_('default value already set for {}'
'').format(self.attrib['path']))
value = convert_tiramisu_value(child.text, type_)
if value is None: # and (elt.attrib['type'] != 'choice' or value not in self.attrib['values']):
value = u''
if is_follower:
self.attrib['default_multi'] = value
else:
self.attrib['default'] = value
elif child.tag == 'choice':
# already load
pass
elif child.tag == 'check':
params = []
for param in child:
params.append(self.parse_param(param))
#check.params = params
self.attrib['validators'].append((child.attrib['name'], params, child.attrib['warnings_only']))
else:
raise Exception('unknown tag {}'.format(child.tag))
if 'initkwargs' in convert_option:
self.attrib.update(convert_option['initkwargs'])
if elt.attrib['type'] == 'symlink':
del self.attrib['properties']
del self.attrib['multi']
self.attrib['opt'] = storage.get(self.attrib['opt'])
def parse_param(self, param): def parse_param(self, param):
name = param.attrib.get('name', '') name = param.attrib.get('name', '')
@ -397,7 +431,7 @@ class Variable(Common):
transitive = False transitive = False
else: else:
raise CreoleLoaderError(_('unknown transitive boolean {}').format(transitive)) raise CreoleLoaderError(_('unknown transitive boolean {}').format(transitive))
value = [param.text, transitive, param.attrib.get('suffix')] value = [param.text, transitive]
elif param.attrib['type'] == 'number': elif param.attrib['type'] == 'number':
value = int(param.text) value = int(param.text)
else: else:
@ -428,21 +462,10 @@ class Variable(Common):
if len(value) == 3: if len(value) == 3:
for param in value[1]: for param in value[1]:
if isinstance(param[1], list): if isinstance(param[1], list):
option = self.storage.get(param[1][0]).get()
param_kwargs = {'notraisepropertyerror': param[1][1]}
if value[0] in FUNC_TO_DICT: if value[0] in FUNC_TO_DICT:
param_kwargs['todict'] = True param_value = ParamOption(self.storage.get(param[1][0]).get(), notraisepropertyerror=param[1][1], todict=True)
if not param[1][2]:
param_value = ParamOption(option,
**param_kwargs,
)
else: else:
family = '.'.join(param[1][0].split('.', 3)[:2]) param_value = ParamOption(self.storage.get(param[1][0]).get(), notraisepropertyerror=param[1][1])
param_value = ParamDynOption(option,
param[1][2],
self.storage.get(family).get(),
**param_kwargs,
)
else: else:
param_value = ParamValue(param[1]) param_value = ParamValue(param[1])
if not param[0]: if not param[0]:
@ -477,7 +500,7 @@ class Variable(Common):
import traceback import traceback
traceback.print_exc() traceback.print_exc()
name = self.attrib['name'] name = self.attrib['name']
raise CreoleLoaderError(_('cannot create option "{}": {}').format(name, err)) raise CreoleLoaderError(_('cannot create option {}: {}').format(name, err))
for key, value in self.informations.items(): for key, value in self.informations.items():
option.impl_set_information(key, value) option.impl_set_information(key, value)
self.option = option self.option = option
@ -485,25 +508,42 @@ class Variable(Common):
class Family(Common): class Family(Common):
def __init__(self, def __init__(self, elt, booleans, storage, eosfunc, force_icon=False):
elt,
booleans,
storage,
eosfunc,
):
self.option = None self.option = None
self.attrib = {} self.attrib = {}
self.is_leader = False self.is_leader = False
self.informations = {} if force_icon:
self.informations = {'icon': None}
else:
self.informations = {}
self.children = [] self.children = []
self.storage = storage self.storage = storage
self.eosfunc = eosfunc self.eosfunc = eosfunc
self.attrib['properties'] = [] self.attrib['properties'] = []
for key, value in elt.attrib.items(): for key, value in elt.attrib.items():
if key == 'help': if key in booleans:
if value == 'True':
value = True
elif value == 'False':
value = False
else:
raise CreoleLoaderError(_('unknown value {} for {}').format(value, key))
if key == 'icon':
self.add_information('icon', value)
continue
elif key == 'hidden':
if value:
self.attrib['properties'].append(key)
elif key == 'mode':
self.attrib['properties'].append(value)
elif key == 'help':
self.add_information(key, value) self.add_information(key, value)
elif key == 'type':
pass
else: else:
self.attrib[key] = value self.attrib[key] = value
if 'doc' not in self.attrib:
self.attrib['doc'] = u''
def add(self, child): def add(self, child):
self.children.append(child) self.children.append(child)
@ -534,11 +574,13 @@ class Family(Common):
else: else:
option = Leadership(**self.attrib) option = Leadership(**self.attrib)
except Exception as err: except Exception as err:
print(self.attrib) raise CreoleLoaderError(_('cannot create optiondescription {}: {}').format(self.attrib['name'], err))
raise CreoleLoaderError(_('cannot create optiondescription "{}": {}').format(self.attrib['name'], err))
for key, value in self.informations.items(): for key, value in self.informations.items():
option.impl_set_information(key, value) option.impl_set_information(key, value)
self.option = option self.option = option
#if self.is_leader:
# self.option.impl_set_group_type(groups.leader)
return self.option return self.option

View File

@ -4,11 +4,11 @@ as an input and outputs a human readable flatened XML
Sample usage:: Sample usage::
>>> from rougail.objspace import CreoleObjSpace >>> from creole.objspace import CreoleObjSpace
>>> eolobj = CreoleObjSpace('/usr/share/rougail/rougail.dtd') >>> eolobj = CreoleObjSpace('/usr/share/creole/creole.dtd')
>>> eolobj.create_or_populate_from_xml('rougail', ['/usr/share/eole/rougail/dicos']) >>> eolobj.create_or_populate_from_xml('creole', ['/usr/share/eole/creole/dicos'])
>>> eolobj.space_visitor() >>> eolobj.space_visitor()
>>> eolobj.save('/tmp/rougail_flatened_output.xml') >>> eolobj.save('/tmp/creole_flatened_output.xml')
The CreoleObjSpace The CreoleObjSpace
@ -25,18 +25,19 @@ 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, VARIABLE_NAMESPACE, ServiceAnnotator, SpaceAnnotator from .annotator import ERASED_ATTRIBUTES, ActionAnnotator, 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 'slave', that shall be forced to the Redefinable type
FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables') FORCE_REDEFINABLES = ('family', 'slave', 'service', 'disknod', 'variables', 'family_action')
# CreoleObjSpace's elements that shall be forced to the UnRedefinable type # CreoleObjSpace's elements that shall be forced to the UnRedefinable type
FORCE_UNREDEFINABLES = ('value',) FORCE_UNREDEFINABLES = ('value', '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
UNREDEFINABLE = ('submulti', 'multi', 'type') UNREDEFINABLE = ('submulti', 'multi', 'type')
@ -47,26 +48,16 @@ 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', 'value', 'target')
CONVERT_EXPORT = {'Leadership': 'leader', #TYPE_TARGET_CONDITION = ('variable', 'family')
'Separators': 'separators',
'Variable': 'variable',
'Value': 'value',
'Property': 'property',
'Choice': 'choice',
'Param': 'param',
'Separator': 'separator',
'Check': 'check',
}
# _____________________________________________________________________________ # _____________________________________________________________________________
# special types definitions for the Object Space's internal representation # special types definitions for the Object Space's internal representation
class RootCreoleObject: class RootCreoleObject(object):
"" ""
class CreoleObjSpace: class CreoleObjSpace(object):
"""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())
@ -87,174 +78,149 @@ class CreoleObjSpace:
def __init__(self, dtdfilename): # pylint: disable=R0912 def __init__(self, dtdfilename): # pylint: disable=R0912
self.index = 0 self.index = 0
class ObjSpace: # pylint: disable=R0903 class ObjSpace(object): # 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.check_removed = None self.probe_variables = []
self.condition_removed = None
# ['variable', 'separator', 'family'] # ['variable', 'separator', 'family']
self.forced_text_elts = set() self.forced_text_elts = set()
self.forced_text_elts_as_name = set(FORCED_TEXT_ELTS_AS_NAME) self.forced_text_elts_as_name = set(['choice', 'property'])
self.forced_choice_option = {}
self.paths = Path()
self.list_conditions = {} self.list_conditions = {}
self.booleans_attributs = [] self.booleans_attributs = []
self.make_object_space_class() for elt in self.xmlreflector.dtd.iterelements():
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 = {}
if dtd_elt.name in FORCE_REDEFINABLES: clstype = self.UnRedefinable
clstype = self.Redefinable atomic = True
else: forced_text_elt = False
clstype = self.UnRedefinable if elt.type == 'mixed':
atomic = dtd_elt.name not in FORCE_UNREDEFINABLES and dtd_elt.name not in FORCE_REDEFINABLES forced_text_elt = True
forced_text_elt = dtd_elt.type == 'mixed' if elt.name == 'service':
for dtd_attr in dtd_elt.iterattributes(): self.parse_dtd_right_left_elt(elt.content)
for attr in elt.iterattributes():
atomic = False atomic = False
if set(dtd_attr.itervalues()) == set(['True', 'False']): if attr.default_value:
# it's a boolean if attr.default_value == 'True':
self.booleans_attributs.append(dtd_attr.name) default_value = True
if dtd_attr.default_value: elif attr.default_value == 'False':
# set default value for this attribute default_value = False
default_value = dtd_attr.default_value else:
if dtd_attr.name in self.booleans_attributs: default_value = attr.default_value
default_value = self.convert_boolean(dtd_attr.default_value) attrs[attr.name] = default_value
attrs[dtd_attr.name] = default_value if not attr.name.endswith('_type'):
if dtd_attr.name == 'redefine': values = list(attr.itervalues())
# has a redefine attribute, so it's a Redefinable object if values != []:
self.forced_choice_option.setdefault(elt.name, {})[attr.name] = values
if attr.name == 'redefine':
clstype = self.Redefinable clstype = self.Redefinable
if dtd_attr.name == 'name' and forced_text_elt: if attr.name == 'name' and forced_text_elt is True:
# child.text should be transform has a "name" attribute self.forced_text_elts.add(elt.name)
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(dtd_elt.name) self.forced_text_elts_as_name.add(elt.name)
if atomic:
# has any attribute so it's an Atomic object if elt.name in FORCE_REDEFINABLES:
clstype = self.Redefinable
elif elt.name in FORCE_UNREDEFINABLES:
clstype = self.UnRedefinable
elif atomic:
clstype = self.Atom clstype = self.Atom
# create ObjectSpace object # Creole ObjectSpace class types, it enables us to create objects like:
setattr(self, dtd_elt.name, type(dtd_elt.name.capitalize(), (clstype,), attrs)) # Service_restriction(), Ip(), Interface(), Host(), Fstab(), Package(), Disknod(),
# 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 create_or_populate_from_xml(self, def parse_dtd_right_left_elt(self, elt):
namespace, if elt.right.type == 'or':
xmlfolders): self.parse_dtd_right_left_elt(elt.right)
"""Parses a bunch of XML files
populates the CreoleObjSpace
"""
for xmlfile, document in self.xmlreflector.load_xml_from_folders(xmlfolders):
self.redefine_variables = []
self.check_removed = []
self.condition_removed = []
self.xml_parse_document(document,
self.space,
namespace,
)
def xml_parse_document(self, def _convert_boolean(self, value): # pylint: disable=R0201
document, """Boolean coercion. The Creole XML may contain srings like `True` or `False`
space,
namespace,
):
"""Parses a Creole XML file
populates the CreoleObjSpace
""" """
family_names = [] if isinstance(value, bool):
for child in document: return value
# this index enables us to reorder objects if value == 'True':
self.index += 1 return True
# doesn't proceed the XML commentaries elif value == 'False':
if not isinstance(child.tag, str): return False
continue else:
if child.tag == 'family': raise TypeError(_('{} is not True or False').format(value)) # pragma: no cover
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
# variable objects creation
try:
variableobj = self.generate_variableobj(child,
space,
namespace,
)
except SpaceObjShallNotBeUpdated:
continue
self.set_text_to_obj(child,
variableobj,
)
self.set_xml_attributes_to_obj(child,
variableobj,
)
self.variableobj_tree_visitor(child,
variableobj,
namespace,
)
self.fill_variableobj_path_attribute(space,
child,
namespace,
document,
variableobj,
)
self.add_to_tree_structure(variableobj,
space,
child,
)
if list(child) != []:
self.xml_parse_document(child,
variableobj,
namespace,
)
def generate_variableobj(self, def _is_already_exists(self, name, space, child, namespace):
child, if isinstance(space, self.family): # pylint: disable=E1101
space, if namespace != 'creole':
namespace, name = space.path + '.' + name
): return self.paths.path_is_defined(name)
""" if child.tag in ['family', 'family_action']:
instanciates or creates Creole Object Subspace objects norm_name = normalize_family(name)
""" else:
variableobj = getattr(self, child.tag)() norm_name = name
if isinstance(variableobj, self.Redefinable): return norm_name in getattr(space, child.tag, {})
variableobj = self.create_or_update_redefinable_object(child.attrib,
space,
child,
namespace,
)
elif isinstance(variableobj, 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
variableobj = getattr(space, child.tag)
self.create_tree_structure(space,
child,
variableobj,
)
return variableobj
def create_or_update_redefinable_object(self, def _translate_in_space(self, name, family, variable, namespace):
subspace, if not isinstance(family, self.family): # pylint: disable=E1101
space, if variable.tag in ['family', 'family_action']:
child, norm_name = normalize_family(name)
namespace, else:
): norm_name = name
return getattr(family, variable.tag)[norm_name]
if namespace == 'creole':
path = name
else:
path = family.path + '.' + name
old_family_name = self.paths.get_variable_family_name(path)
if normalize_family(family.name) == old_family_name:
return getattr(family, variable.tag)[name]
old_family = self.space.variables['creole'].family[old_family_name] # pylint: disable=E1101
variable_obj = old_family.variable[name]
del old_family.variable[name]
if 'variable' not in vars(family):
family.variable = OrderedDict()
family.variable[name] = variable_obj
self.paths.append('variable', name, namespace, family.name, variable_obj)
return variable_obj
def remove_check(self, name): # pylint: disable=C0111
if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'check'):
remove_checks = []
for idx, check in enumerate(self.space.constraints.check): # pylint: disable=E1101
if hasattr(check, 'target') and check.target == name:
remove_checks.append(idx)
remove_checks = list(set(remove_checks))
remove_checks.sort(reverse=True)
for idx in remove_checks:
self.space.constraints.check.pop(idx) # pylint: disable=E1101
def remove_condition(self, name): # pylint: disable=C0111
for idx, condition in enumerate(self.space.constraints.condition): # pylint: disable=E1101
remove_targets = []
if hasattr(condition, 'target'):
for target_idx, target in enumerate(condition.target):
if target.name == name:
remove_targets.append(target_idx)
remove_targets = list(set(remove_targets))
remove_targets.sort(reverse=True)
for idx in remove_targets:
del condition.target[idx]
def create_or_update_space_object(self, subspace, space, child, namespace):
"""Creates or retrieves the space object that corresponds """Creates or retrieves the space object that corresponds
to the `child` XML object to the `child` XML object
@ -283,34 +249,46 @@ class CreoleObjSpace:
name = child.text name = child.text
else: else:
name = subspace['name'] name = subspace['name']
if self.is_already_exists(name, if self._is_already_exists(name, space, child, namespace):
space, if child.tag in FORCE_REDEFINABLES:
child, redefine = self._convert_boolean(subspace.get('redefine', True))
namespace, else:
): redefine = self._convert_boolean(subspace.get('redefine', False))
default_redefine = child.tag in FORCE_REDEFINABLES exists = self._convert_boolean(subspace.get('exists', True))
redefine = self.convert_boolean(subspace.get('redefine', default_redefine))
exists = self.convert_boolean(subspace.get('exists', True))
if redefine is True: if redefine is True:
return self.translate_in_space(name, return self._translate_in_space(name, space, child, namespace)
space,
child,
namespace,
)
elif exists is False: elif exists is False:
raise SpaceObjShallNotBeUpdated() raise SpaceObjShallNotBeUpdated()
raise CreoleDictConsistencyError(_(f'Already present in another XML file, {name} cannot be re-created')) else:
redefine = self.convert_boolean(subspace.get('redefine', False)) raise CreoleDictConsistencyError(_('Already present in another XML file, {} '
exists = self.convert_boolean(subspace.get('exists', False)) 'cannot be re-created').format(name))
if redefine is False or exists is True: else:
return getattr(self, child.tag)() redefine = self._convert_boolean(subspace.get('redefine', False))
raise CreoleDictConsistencyError(_(f'Redefined object: {name} does not exist yet')) 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 create_tree_structure(self, def generate_creoleobj(self, child, space, namespace):
space, """
child, instanciates or creates Creole Object Subspace objects
variableobj, """
): # pylint: disable=R0201 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 Builds the tree structure of the object space here
we set services attributes in order to be populated later on we set services attributes in order to be populated later on
@ -323,144 +301,63 @@ class CreoleObjSpace:
space.value = list() space.value = list()
""" """
if child.tag not in vars(space): if child.tag not in vars(space):
if isinstance(variableobj, self.Redefinable): if isinstance(creoleobj, self.Redefinable):
setattr(space, child.tag, OrderedDict()) setattr(space, child.tag, OrderedDict())
elif isinstance(variableobj, self.UnRedefinable): elif isinstance(creoleobj, self.UnRedefinable):
setattr(space, child.tag, []) setattr(space, child.tag, [])
elif not isinstance(variableobj, self.Atom): # pragma: no cover elif isinstance(creoleobj, self.Atom):
pass
else: # pragma: no cover
raise CreoleOperationError(_("Creole object {} " raise CreoleOperationError(_("Creole object {} "
"has a wrong type").format(type(variableobj))) "has a wrong type").format(type(creoleobj)))
def is_already_exists(self, name, space, child, namespace): def _add_to_tree_structure(self, creoleobj, space, child): # pylint: disable=R0201
if isinstance(space, self.family): # pylint: disable=E1101 if isinstance(creoleobj, self.Redefinable):
if namespace != VARIABLE_NAMESPACE: name = creoleobj.name
name = space.path + '.' + name if child.tag == 'family' or child.tag == 'family_action':
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`
"""
if isinstance(value, bool):
return value
if value == 'True':
return True
elif value == 'False':
return False
else:
raise TypeError(_('{} is not True or False').format(value)) # pragma: no cover
def translate_in_space(self,
name,
family,
variable,
namespace,
):
if not isinstance(family, self.family): # pylint: disable=E1101
if variable.tag == 'family':
norm_name = normalize_family(name)
else:
norm_name = name
return getattr(family, variable.tag)[norm_name]
if namespace == VARIABLE_NAMESPACE:
path = name
else:
path = family.path + '.' + name
old_family_name = self.paths.get_variable_family_name(path)
if normalize_family(family.name) == old_family_name:
return getattr(family, variable.tag)[name]
old_family = self.space.variables[VARIABLE_NAMESPACE].family[old_family_name] # pylint: disable=E1101
variable_obj = old_family.variable[name]
del old_family.variable[name]
if 'variable' not in vars(family):
family.variable = OrderedDict()
family.variable[name] = variable_obj
self.paths.add_variable(namespace,
name,
family.name,
False,
variable_obj,
)
return variable_obj
def remove_check(self, name): # pylint: disable=C0111
if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'check'):
remove_checks = []
for idx, check in enumerate(self.space.constraints.check): # pylint: disable=E1101
if hasattr(check, 'target') and check.target == name:
remove_checks.append(idx)
remove_checks = list(set(remove_checks))
remove_checks.sort(reverse=True)
for idx in remove_checks:
self.space.constraints.check.pop(idx) # pylint: disable=E1101
def remove_condition(self, name): # pylint: disable=C0111
for idx, condition in enumerate(self.space.constraints.condition): # pylint: disable=E1101
remove_targets = []
if hasattr(condition, 'target'):
for target_idx, target in enumerate(condition.target):
if target.name == name:
remove_targets.append(target_idx)
remove_targets = list(set(remove_targets))
remove_targets.sort(reverse=True)
for idx in remove_targets:
del condition.target[idx]
def add_to_tree_structure(self,
variableobj,
space,
child,
): # pylint: disable=R0201
if isinstance(variableobj, self.Redefinable):
name = variableobj.name
if child.tag == 'family':
name = normalize_family(name) name = normalize_family(name)
getattr(space, child.tag)[name] = variableobj getattr(space, child.tag)[name] = creoleobj
elif isinstance(variableobj, self.UnRedefinable): elif isinstance(creoleobj, self.UnRedefinable):
getattr(space, child.tag).append(variableobj) getattr(space, child.tag).append(creoleobj)
else: else:
setattr(space, child.tag, variableobj) setattr(space, child.tag, creoleobj)
def set_text_to_obj(self, def _set_text_to_obj(self, child, creoleobj):
child,
variableobj,
):
if child.text is None: if child.text is None:
text = None text = None
else: else:
text = child.text.strip() text = child.text.strip()
if text: if text:
if child.tag in self.forced_text_elts_as_name: if child.tag in self.forced_text_elts_as_name:
variableobj.name = text creoleobj.name = text
else: else:
variableobj.text = text creoleobj.text = text
def set_xml_attributes_to_obj(self, def _set_xml_attributes_to_obj(self, child, creoleobj):
child, redefine = self._convert_boolean(child.attrib.get('redefine', False))
variableobj, has_value = hasattr(creoleobj, 'value')
):
redefine = self.convert_boolean(child.attrib.get('redefine', False))
has_value = hasattr(variableobj, '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 and len(child) != 0: if (redefine is True and child.tag == 'variable' and has_value
del variableobj.value and len(child) != 0):
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(_(f'cannot redefine attribute {attr} for variable {name}')) raise CreoleDictConsistencyError(_("cannot redefine attribute {} for variable {}").format(attr, name))
if attr in self.booleans_attributs: if isinstance(getattr(creoleobj, attr, None), bool):
val = self.convert_boolean(val) if val == 'False':
if not (attr == 'name' and getattr(variableobj, 'name', None) != None): val = False
setattr(variableobj, attr, val) elif val == 'True':
keys = list(vars(variableobj).keys()) 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):
setattr(creoleobj, attr, val)
keys = list(vars(creoleobj).keys())
for incompatible in INCOMPATIBLE_ATTRIBUTES: for incompatible in INCOMPATIBLE_ATTRIBUTES:
found = False found = False
for inc in incompatible: for inc in incompatible:
@ -469,68 +366,101 @@ class CreoleObjSpace:
raise CreoleDictConsistencyError(_('those attributes are incompatible {}').format(incompatible)) raise CreoleDictConsistencyError(_('those attributes are incompatible {}').format(incompatible))
found = True found = True
def variableobj_tree_visitor(self,
child, def _creoleobj_tree_visitor(self, child, creoleobj, namespace):
variableobj,
namespace,
):
"""Creole object tree manipulations """Creole object tree manipulations
""" """
if child.tag == 'variable': if child.tag == 'variable' and child.attrib.get('remove_check', False):
if child.attrib.get('remove_check', False): self.remove_check(creoleobj.name)
self.remove_check(variableobj.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(variableobj.name) if child.tag in ['auto', 'fill', 'check']:
if child.tag == 'fill': 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 variable and in leader/followers if variable_name in self.redefine_variables:
variableobj.redefine = child.attrib['target'] in self.redefine_variables creoleobj.redefine = True
if not hasattr(variableobj, 'index'): else:
variableobj.index = self.index creoleobj.redefine = False
if child.tag == 'check' and child.attrib['target'] in self.redefine_variables and child.attrib['target'] not in self.check_removed: if not hasattr(creoleobj, 'index'):
self.remove_check(child.attrib['target']) creoleobj.index = self.index
self.check_removed.append(child.attrib['target']) if child.tag in ['auto', 'fill', 'condition', 'check', 'action']:
if child.tag == 'condition' and child.attrib['source'] in self.redefine_variables and child.attrib['source'] not in self.check_removed: creoleobj.namespace = namespace
self.remove_condition(child.attrib['source'])
self.condition_removed.append(child.attrib['source'])
variableobj.namespace = namespace
def fill_variableobj_path_attribute(self, def xml_parse_document(self, document, space, namespace, is_in_family=False):
space, """Parses a Creole XML file
child, populates the CreoleObjSpace
namespace, """
document, family_names = []
variableobj, for child in document:
): # pylint: disable=R0913 # 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, child, namespace, document, creoleobj): # pylint: disable=R0913
"""Fill self.paths attributes """Fill self.paths attributes
""" """
if isinstance(space, self.help): # pylint: disable=E1101 if not 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.append('variable', child.attrib['name'], namespace, family_name,
self.paths.add_variable(namespace, creoleobj)
child.attrib['name'], if child.attrib.get('redefine', 'False') == 'True':
family_name, if namespace == 'creole':
document.attrib.get('dynamic') != None, self.redefine_variables.append(child.attrib['name'])
variableobj) else:
if child.attrib.get('redefine', 'False') == 'True': self.redefine_variables.append(namespace + '.' + family_name + '.' +
if namespace == VARIABLE_NAMESPACE: child.attrib['name'])
self.redefine_variables.append(child.attrib['name'])
else:
self.redefine_variables.append(namespace + '.' + family_name + '.' +
child.attrib['name'])
elif child.tag == 'family': if child.tag == 'family':
family_name = normalize_family(child.attrib['name']) family_name = normalize_family(child.attrib['name'])
if namespace != VARIABLE_NAMESPACE: if namespace != 'creole':
family_name = namespace + '.' + family_name family_name = namespace + '.' + family_name
self.paths.add_family(namespace, self.paths.append('family', family_name, namespace, creoleobj=creoleobj)
family_name, creoleobj.path = self.paths.get_family_path(family_name, namespace)
variableobj,
) def create_or_populate_from_xml(self, namespace, xmlfolders, from_zephir=None):
variableobj.path = self.paths.get_family_path(family_name, namespace) """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)
@ -539,13 +469,42 @@ class CreoleObjSpace:
:param filename: the full XML filename :param filename: the full XML filename
""" """
xml = Element('rougail') xml = Element('creole')
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 get_attributes(self, space): # pylint: disable=R0201 def save_probes(self, filename, force_no_save=False):
"""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
@ -555,58 +514,183 @@ class CreoleObjSpace:
space = list(space.values()) space = list(space.values())
if isinstance(space, list): if isinstance(space, list):
for subspace in space: for subspace in space:
if name == 'value' and (not hasattr(subspace, 'name') or subspace.name is None): if isinstance(subspace, self.Leadership):
raise Exception('pfff') _name = 'leader'
else:
_name = name
if name in ['services', 'variables', 'actions']:
_name = 'family'
if HIGH_COMPATIBILITY and not hasattr(subspace, 'doc'):
subspace.doc = ''
if _name == 'value' and (not hasattr(subspace, 'name') or subspace.name is None):
continue continue
_name = CONVERT_EXPORT.get(subspace.__class__.__name__, 'family')
child_node = SubElement(node, _name) child_node = SubElement(node, _name)
self._xml_export(child_node, subspace, _name) self._xml_export(child_node, subspace, _name)
elif isinstance(space, (self.Atom, (self.Redefinable, self.UnRedefinable))): elif isinstance(space, self.Atom):
_name = CONVERT_EXPORT.get(space.__class__.__name__, 'family') if name == 'services':
child_node = SubElement(node, _name) child_node = SubElement(node, 'family')
if _name != name:
child_node.attrib['name'] = name child_node.attrib['name'] = name
if 'doc' not in child_node.attrib.keys(): else:
child_node.attrib['doc'] = 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 name not in ERASED_ATTRIBUTES: elif isinstance(space, self.Redefinable):
# # FIXME plutot dans annotator ... child_node = SubElement(node, 'family')
if node.tag in ['variable', 'family', 'leader']: child_node.attrib['name'] = name
if name in PROPERTIES: for subname in self._get_attributes(space):
if space is True: subspace = getattr(space, subname)
for prop in CONVERT_PROPERTIES.get(name, [name]): self._sub_xml_export(subname, child_node, name, subspace, space)
SubElement(node, 'property').text = prop else:
return # FIXME plutot dans annotator ...
if name == 'mode' and space: if name in PROPERTIES and node.tag in ['variable', 'family', 'leader']:
SubElement(node, 'property').text = space if space is True:
return for prop in CONVERT_PROPERTIES.get(name, [name]):
# Not param for calculation ... SubElement(node, 'property').text = prop
if name == 'name' and node_name in FORCED_TEXT_ELTS_AS_NAME and not hasattr(current_space, 'param'):
node.text = str(space)
elif name == 'text' and node_name in self.forced_text_elts:
node.text = space
elif node.tag == 'family' and name == 'name':
if 'doc' not in node.attrib.keys():
node.attrib['doc'] = space
node.attrib['name'] = normalize_family(space, check_name=False)
else:
if name in RENAME_ATTIBUTES:
name = RENAME_ATTIBUTES[name]
if space is not None:
node.attrib[name] = str(space)
def _xml_export(self, elif name not in ERASED_ATTRIBUTES:
node, if name == 'name' and node_name in self.forced_text_elts_as_name and not hasattr(current_space, 'param'):
space, if isinstance(space, str):
node_name=VARIABLE_NAMESPACE, node.text = space
): else:
for name in self.get_attributes(space): node.text = str(space)
elif name == 'text' and node_name in self.forced_text_elts:
node.text = space
elif node.tag == 'family' and name == 'name':
if 'doc' not in node.attrib.keys():
node.attrib['doc'] = space
node.attrib['name'] = normalize_family(space, check_name=False)
elif node.tag in ['variable', 'family', 'leader'] and name == 'mode':
if space is not None:
SubElement(node, 'property').text = space
else:
if name in RENAME_ATTIBUTES:
name = RENAME_ATTIBUTES[name]
if space is not None:
node.attrib[name] = str(space)
def _xml_export(self, node, space, node_name='creole'):
for name in self._get_attributes(space):
subspace = getattr(space, name) subspace = getattr(space, name)
self._sub_xml_export(name, self._sub_xml_export(name, node, node_name, subspace, space)
node,
node_name,
subspace, class Path(object):
space, """Helper class to handle the `path` attribute of a CreoleObjSpace
) instance.
sample: path="creole.general.condition"
"""
def __init__(self):
self.variables = {}
self.families = {}
def append(self, pathtype, name, namespace, family=None, creoleobj=None): # pylint: disable=C0111
if pathtype == 'family':
self.families[name] = dict(name=name, namespace=namespace, creoleobj=creoleobj)
elif pathtype == 'variable':
if namespace == 'creole':
varname = name
else:
if '.' in name:
varname = name
else:
varname = '.'.join([namespace, family, name])
self.variables[varname] = dict(name=name, family=family, namespace=namespace,
leader=None, creoleobj=creoleobj)
else: # pragma: no cover
raise Exception('unknown pathtype {}'.format(pathtype))
def get_family_path(self, name, current_namespace): # 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): # pylint: disable=C0111
dico = self.families[name]
if dico['namespace'] is None:
return dico['name']
return dico['namespace']
def get_family_obj(self, name): # pylint: disable=C0111
if name not in self.families:
raise CreoleDictConsistencyError(_('unknown family {}').format(name))
dico = self.families[name]
return dico['creoleobj']
def get_variable_name(self, name): # pylint: disable=C0111
dico = self._get_variable(name)
return dico['name']
def get_variable_obj(self, name): # pylint: disable=C0111
dico = self._get_variable(name)
return dico['creoleobj']
def get_variable_family_name(self, name): # pylint: disable=C0111
dico = self._get_variable(name)
return dico['family']
def get_variable_family_path(self, name): # 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): # pylint: disable=C0111
return self._get_variable(name)['namespace']
def get_variable_path(self, name, current_namespace, allow_source=False): # pylint: disable=C0111
if current_namespace is None: # pragma: no cover
raise CreoleOperationError('current_namespace must not be None')
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']:
return dico['name']
list_path = [dico['namespace'], dico['family']]
if dico['leader'] is not None:
list_path.append(dico['leader'])
list_path.append(dico['name'])
return '.'.join(list_path)
def path_is_defined(self, name): # pylint: disable=C0111
return name in self.variables
def set_leader(self, name, leader): # pylint: disable=C0111
dico = self._get_variable(name)
namespace = dico['namespace']
if dico['leader'] != None:
raise CreoleDictConsistencyError(_('Already defined leader {} for variable'
' {}'.format(dico['leader'], name)))
dico['leader'] = leader
if namespace != 'creole':
new_path = self.get_variable_path(name, namespace)
self.append('variable', new_path, namespace, family=dico['family'], creoleobj=dico['creoleobj'])
self.variables[new_path]['leader'] = leader
del self.variables[name]
def _get_variable(self, name):
if name not in self.variables:
if name.startswith('creole.'):
name = name.split('.')[-1]
if name not in self.variables:
raise CreoleDictConsistencyError(_('unknown option {}').format(name))
return self.variables[name]
def get_leader(self, name): # pylint: disable=C0111
dico = self._get_variable(name)
return dico['leader']

View File

@ -1,174 +0,0 @@
from .i18n import _
from .utils import normalize_family
from .error import CreoleOperationError, CreoleDictConsistencyError
from .annotator import VARIABLE_NAMESPACE
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,
variableobj: str,
) -> str: # pylint: disable=C0111
self.families[name] = dict(name=name,
namespace=namespace,
variableobj=variableobj,
)
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'] != VARIABLE_NAMESPACE 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['variableobj']
# Leadership
def set_leader(self,
namespace: str,
leader_family_name: str,
name: str,
leader_name: str,
) -> None: # pylint: disable=C0111
if namespace != VARIABLE_NAMESPACE:
# need rebuild path and move object in new path
old_path = namespace + '.' + leader_family_name + '.' + name
dico = self._get_variable(old_path)
del self.variables[old_path]
new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name
self.add_variable(namespace,
new_path,
dico['family'],
False,
dico['variableobj'],
)
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,
variableobj,
) -> str: # pylint: disable=C0111
if namespace == VARIABLE_NAMESPACE 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,
variableobj=variableobj)
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)['variableobj']
def get_variable_family_name(self,
name: str,
) -> str: # pylint: disable=C0111
return self._get_variable(name)['family']
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 [VARIABLE_NAMESPACE, '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(f'{VARIABLE_NAMESPACE}.'):
name = name.split('.')[-1]
if name not in self.variables:
for var_name, variable in self.variables.items():
if variable['is_dynamic'] and name.startswith(var_name):
return variable, name[len(var_name):]
raise CreoleDictConsistencyError(_('unknown option {}').format(name))
if with_suffix:
return self.variables[name], None
return self.variables[name]

View File

@ -5,12 +5,32 @@ On travaille sur les fichiers cibles
""" """
import imp import imp
import sys
from shutil import copy from shutil import copy
import logging import logging
from typing import Dict, Any from typing import Dict, Any
from subprocess import call from subprocess import call
from os import listdir, makedirs from os import listdir, unlink, makedirs
from os.path import dirname, join, isfile from os.path import dirname, basename, join, split, isfile, isdir
from tempfile import mktemp
from Cheetah import Parser
# l'encoding du template est déterminé par une regexp (encodingDirectiveRE dans Parser.py)
# il cherche un ligne qui ressemble à '#encoding: utf-8
# cette classe simule le module 're' et retourne toujours l'encoding utf-8
# 6224
class FakeEncoding:
def groups(self):
return ('utf-8',)
def search(self, *args):
return self
Parser.encodingDirectiveRE = FakeEncoding()
from Cheetah.Template import Template as ChtTemplate from Cheetah.Template import Template as ChtTemplate
from Cheetah.NameMapper import NotFound as CheetahNotFound from Cheetah.NameMapper import NotFound as CheetahNotFound
@ -18,9 +38,8 @@ from Cheetah.NameMapper import NotFound as CheetahNotFound
from tiramisu import Config from tiramisu import Config
from tiramisu.error import PropertiesOptionError from tiramisu.error import PropertiesOptionError
from .annotator import VARIABLE_NAMESPACE
from .config import patch_dir from .config import patch_dir
from .error import FileNotFound, TemplateError from .error import FileNotFound, TemplateError, TemplateDisabled
from .i18n import _ from .i18n import _
from .utils import normalize_family from .utils import normalize_family
@ -28,7 +47,6 @@ from .utils import normalize_family
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler()) log.addHandler(logging.NullHandler())
class IsDefined: class IsDefined:
""" """
filtre permettant de ne pas lever d'exception au cas où filtre permettant de ne pas lever d'exception au cas où
@ -41,16 +59,34 @@ class IsDefined:
if '.' in varname: if '.' in varname:
splitted_var = varname.split('.') splitted_var = varname.split('.')
if len(splitted_var) != 2: if len(splitted_var) != 2:
msg = _("Group variables must be of type leader.follower") msg = _("Group variables must be of type master.slave")
raise KeyError(msg) raise KeyError(msg)
leader, follower = splitted_var master, slave = splitted_var
if leader in self.context: if master in self.context:
return follower in self.context[leader].follower.keys() return slave in self.context[master].slave.keys()
return False return False
else: else:
return varname in self.context return varname in self.context
class CreoleGet:
def __init__(self, context):
self.context = context
def __call__(self, varname):
return self.context[varname]
def __getitem__(self, varname):
"""For bracket and dotted notation
"""
return self.context[varname]
def __contains__(self, varname):
"""Check variable existence in context
"""
return varname in self.context
@classmethod @classmethod
def cl_compile(kls, *args, **kwargs): def cl_compile(kls, *args, **kwargs):
kwargs['compilerSettings'] = {'directiveStartToken' : '%', kwargs['compilerSettings'] = {'directiveStartToken' : '%',
@ -67,6 +103,12 @@ ChtTemplate.old_compile = ChtTemplate.compile
ChtTemplate.compile = cl_compile ChtTemplate.compile = cl_compile
class CreoleClient:
def __init__(self,
config: Config):
self.config = config
class CheetahTemplate(ChtTemplate): class CheetahTemplate(ChtTemplate):
"""classe pour personnaliser et faciliter la construction """classe pour personnaliser et faciliter la construction
du template Cheetah du template Cheetah
@ -91,7 +133,7 @@ class CheetahTemplate(ChtTemplate):
class CreoleLeader: class CreoleLeader:
def __init__(self, value, follower=None, index=None): def __init__(self, value, slave=None, index=None):
""" """
On rend la variable itérable pour pouvoir faire: On rend la variable itérable pour pouvoir faire:
for ip in iplist: for ip in iplist:
@ -101,20 +143,20 @@ class CreoleLeader:
index is used for CreoleLint index is used for CreoleLint
""" """
self._value = value self._value = value
if follower is not None: if slave is not None:
self.follower = follower self.slave = slave
else: else:
self.follower = {} self.slave = {}
self._index = index self._index = index
def __getattr__(self, name): def __getattr__(self, name):
"""Get follower variable or attribute of leader value. """Get slave variable or attribute of master value.
If the attribute is a name of a follower variable, return its value. If the attribute is a name of a slave variable, return its value.
Otherwise, returns the requested attribute of leader value. Otherwise, returns the requested attribute of master value.
""" """
if name in self.follower: if name in self.slave:
value = self.follower[name] value = self.slave[name]
if isinstance(value, PropertiesOptionError): if isinstance(value, PropertiesOptionError):
raise AttributeError() raise AttributeError()
return value return value
@ -122,36 +164,36 @@ class CreoleLeader:
return getattr(self._value, name) return getattr(self._value, name)
def __getitem__(self, index): def __getitem__(self, index):
"""Get a leader.follower at requested index. """Get a master.slave at requested index.
""" """
ret = {} ret = {}
for key, values in self.follower.items(): for key, values in self.slave.items():
ret[key] = values[index] ret[key] = values[index]
return CreoleLeader(self._value[index], ret, index) return CreoleLeader(self._value[index], ret, index)
def __iter__(self): def __iter__(self):
"""Iterate over leader.follower. """Iterate over master.slave.
Return synchronised value of leader.follower. Return synchronised value of master.slave.
""" """
for i in range(len(self._value)): for i in range(len(self._value)):
ret = {} ret = {}
for key, values in self.follower.items(): for key, values in self.slave.items():
ret[key] = values[i] ret[key] = values[i]
yield CreoleLeader(self._value[i], ret, i) yield CreoleLeader(self._value[i], ret, i)
def __len__(self): def __len__(self):
"""Delegate to leader value """Delegate to master value
""" """
return len(self._value) return len(self._value)
def __repr__(self): def __repr__(self):
"""Show CreoleLeader as dictionary. """Show CreoleLeader as dictionary.
The leader value is stored under 'value' key. The master value is stored under 'value' key.
The followers are stored under 'follower' key. The slaves are stored under 'slave' key.
""" """
return repr({'value': self._value, 'follower': self.follower}) return repr({'value': self._value, 'slave': self.slave})
def __eq__(self, value): def __eq__(self, value):
return value == self._value return value == self._value
@ -172,7 +214,7 @@ class CreoleLeader:
return self._value >= value return self._value >= value
def __str__(self): def __str__(self):
"""Delegate to leader value """Delegate to master value
""" """
return str(self._value) return str(self._value)
@ -185,7 +227,7 @@ class CreoleLeader:
def __contains__(self, item): def __contains__(self, item):
return item in self._value return item in self._value
async def add_follower(self, config, name, path): async def add_slave(self, config, name, path):
if isinstance(self._value, list): if isinstance(self._value, list):
values = [] values = []
for idx in range(len(self._value)): for idx in range(len(self._value)):
@ -195,7 +237,7 @@ class CreoleLeader:
values.append(err) values.append(err)
else: else:
raise Exception('hu?') raise Exception('hu?')
self.follower[name] = values self.slave[name] = values
class CreoleExtra: class CreoleExtra:
@ -210,9 +252,6 @@ class CreoleExtra:
def __repr__(self): def __repr__(self):
return self.suboption.__str__() return self.suboption.__str__()
def __iter__(self):
return iter(self.suboption.values())
class CreoleTemplateEngine: class CreoleTemplateEngine:
"""Engine to process Creole cheetah template """Engine to process Creole cheetah template
@ -222,8 +261,7 @@ class CreoleTemplateEngine:
eosfunc_file: str, eosfunc_file: str,
distrib_dir: str, distrib_dir: str,
tmp_dir: str, tmp_dir: str,
dest_dir: str, dest_dir:str) -> None:
) -> None:
self.config = config self.config = config
self.dest_dir = dest_dir self.dest_dir = dest_dir
self.tmp_dir = tmp_dir self.tmp_dir = tmp_dir
@ -235,25 +273,25 @@ class CreoleTemplateEngine:
if not func.startswith('_'): if not func.startswith('_'):
eos[func] = getattr(eosfunc, func) eos[func] = getattr(eosfunc, func)
self.eosfunc = eos self.eosfunc = eos
self.rougail_variables_dict = {} self.creole_variables_dict = {}
async def load_eole_variables_rougail(self, async def load_eole_variables_creole(self,
optiondescription): optiondescription):
for option in await optiondescription.list('all'): for option in await optiondescription.list('all'):
if await option.option.isoptiondescription(): if await option.option.isoptiondescription():
if await option.option.isleadership(): if await option.option.isleadership():
for idx, suboption in enumerate(await option.list('all')): for idx, suboption in enumerate(await option.list('all')):
if idx == 0: if idx == 0:
leader = CreoleLeader(await suboption.value.get()) leader = CreoleLeader(await suboption.value.get())
self.rougail_variables_dict[await suboption.option.name()] = leader self.creole_variables_dict[await suboption.option.name()] = leader
else: else:
await leader.add_follower(self.config, await leader.add_slave(self.config,
await suboption.option.name(), await suboption.option.name(),
await suboption.option.path()) await suboption.option.path())
else: else:
await self.load_eole_variables_rougail(option) await self.load_eole_variables_creole(option)
else: else:
self.rougail_variables_dict[await option.option.name()] = await option.value.get() self.creole_variables_dict[await option.option.name()] = await option.value.get()
async def load_eole_variables(self, async def load_eole_variables(self,
namespace, namespace,
@ -262,26 +300,20 @@ class CreoleTemplateEngine:
for family in await optiondescription.list('all'): for family in await optiondescription.list('all'):
variables = {} variables = {}
for variable in await family.list('all'): for variable in await family.list('all'):
if await variable.option.isoptiondescription(): if await variable.option.isoptiondescription() and await variable.option.isleadership():
if await variable.option.isleadership(): for idx, suboption in enumerate(await variable.list('all')):
for idx, suboption in enumerate(await variable.list('all')): if idx == 0:
if idx == 0: leader = CreoleLeader(await suboption.value.get())
leader = CreoleLeader(await suboption.value.get()) leader_name = await suboption.option.name()
leader_name = await suboption.option.name() else:
else: await leader.add_slave(self.config,
await leader.add_follower(self.config, await suboption.option.name(),
await suboption.option.name(), await suboption.option.path())
await suboption.option.path()) variables[leader_name] = leader
variables[leader_name] = leader
else:
subfamilies = await self.load_eole_variables(await variable.option.name(),
variable,
)
variables[await variable.option.name()] = subfamilies
else: else:
variables[await variable.option.name()] = await variable.value.get() variables[await variable.option.name()] = await variable.value.get()
families[await family.option.name()] = CreoleExtra(variables) families[await family.option.name()] = CreoleExtra(variables)
return CreoleExtra(families) self.creole_variables_dict[namespace] = CreoleExtra(families)
def patch_template(self, def patch_template(self,
filename: str): filename: str):
@ -310,8 +342,6 @@ class CreoleTemplateEngine:
self.patch_template(filename) self.patch_template(filename)
def process(self, def process(self,
source: str,
true_destfilename: str,
destfilename: str, destfilename: str,
filevar: Dict, filevar: Dict,
variable: Any): variable: Any):
@ -320,12 +350,12 @@ class CreoleTemplateEngine:
# full path of the destination file # full path of the destination file
log.info(_(f"Cheetah processing: '{destfilename}'")) log.info(_(f"Cheetah processing: '{destfilename}'"))
try: try:
cheetah_template = CheetahTemplate(source, cheetah_template = CheetahTemplate(join(self.tmp_dir,
self.rougail_variables_dict, filevar['source']),
self.creole_variables_dict,
self.eosfunc, self.eosfunc,
true_destfilename, destfilename,
variable, variable)
)
data = str(cheetah_template) data = str(cheetah_template)
except CheetahNotFound as err: except CheetahNotFound as err:
varname = err.args[0][13:-1] varname = err.args[0][13:-1]
@ -338,53 +368,51 @@ class CreoleTemplateEngine:
def instance_file(self, def instance_file(self,
filevar: Dict, filevar: Dict,
service_name: str) -> None: systemd_rights: list) -> None:
"""Run templatisation on one file """Run templatisation on one file
""" """
log.info(_("Instantiating file '{filename}'")) log.info(_("Instantiating file '{filename}'"))
filenames = filevar['name']
if 'variable' in filevar: if 'variable' in filevar:
variable = filevar['variable'] variable = filevar['variable']
else: else:
variable = None variable = None
filenames = filevar['name']
if not isinstance(filenames, list): if not isinstance(filenames, list):
filenames = [filenames] filenames = [filenames]
if variable: if variable:
variable = [variable] variable = [variable]
for idx, filename in enumerate(filenames): for idx, filename in enumerate(filenames):
destfilename = join(self.dest_dir, filename[1:]) destfilename = join(self.dest_dir,
filename[1:])
makedirs(dirname(destfilename), exist_ok=True) makedirs(dirname(destfilename), exist_ok=True)
if variable: if variable:
var = variable[idx] var = variable[idx]
else: else:
var = None var = None
source = join(self.tmp_dir, filevar['source']) self.process(destfilename,
if filevar['templating']: filevar,
self.process(source, var)
filename, systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - -')
destfilename, systemd_rights.append(f'z {filename} - - - - -')
filevar,
var)
else:
copy(source, destfilename)
async def instance_files(self) -> None: async def instance_files(self) -> None:
"""Run templatisation on all files """Run templatisation on all files
""" """
for option in await self.config.option.list(type='all'): for option in await self.config.option.list(type='all'):
namespace = await option.option.name() namespace = await option.option.name()
if namespace == VARIABLE_NAMESPACE: if namespace in ['services', 'actions']:
await self.load_eole_variables_rougail(option) continue
elif namespace == 'creole':
await self.load_eole_variables_creole(option)
else: else:
families = await self.load_eole_variables(namespace, await self.load_eole_variables(namespace,
option) option)
self.rougail_variables_dict[namespace] = families
for template in listdir(self.distrib_dir): for template in listdir(self.distrib_dir):
self.prepare_template(join(self.distrib_dir, template)) self.prepare_template(join(self.distrib_dir, template))
systemd_rights = []
for service_obj in await self.config.option('services').list('all'): for service_obj in await self.config.option('services').list('all'):
service_name = await service_obj.option.doc()
for fills in await service_obj.list('all'): for fills in await service_obj.list('all'):
if await fills.option.name() in ['files', 'overrides']: if await fills.option.name() == 'files':
for fill_obj in await fills.list('all'): for fill_obj in await fills.list('all'):
fill = await fill_obj.value.dict() fill = await fill_obj.value.dict()
filename = fill['source'] filename = fill['source']
@ -393,22 +421,23 @@ class CreoleTemplateEngine:
raise FileNotFound(_(f"File {distib_file} does not exist.")) raise FileNotFound(_(f"File {distib_file} does not exist."))
if fill.get('activate', False): if fill.get('activate', False):
self.instance_file(fill, self.instance_file(fill,
service_name, systemd_rights)
)
else: else:
log.debug(_("Instantiation of file '{filename}' disabled")) log.debug(_("Instantiation of file '{filename}' disabled"))
with open(join(self.dest_dir, 'rougail.conf'), 'w') as fh:
fh.write('\n'.join(systemd_rights))
fh.write('\n')
async def generate(config: Config, async def generate(config: Config,
eosfunc_file: str, eosfunc_file: str,
distrib_dir: str, distrib_dir: str,
tmp_dir: str, tmp_dir: str,
dest_dir: str, dest_dir: str) -> None:
) -> None:
engine = CreoleTemplateEngine(config, engine = CreoleTemplateEngine(config,
eosfunc_file, eosfunc_file,
distrib_dir, distrib_dir,
tmp_dir, tmp_dir,
dest_dir, dest_dir)
)
await engine.instance_files() await engine.instance_files()

View File

@ -35,53 +35,58 @@ 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): def load_xml_from_folders(self, xmlfolders, from_zephir):
"""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 not isinstance(xmlfolders, list): if from_zephir:
xmlfolders = [xmlfolders] for idx, xmlfile in enumerate(xmlfolders):
for xmlfolder in xmlfolders: documents.append(('generate_{}'.format(idx), self.parse_xmlfile(xmlfile, from_zephir=from_zephir)))
if isinstance(xmlfolder, list) or isinstance(xmlfolder, tuple): else:
# directory group : collect files from each if not isinstance(xmlfolders, list):
# directory and sort them before loading xmlfolders = [xmlfolders]
group_files = [] for xmlfolder in xmlfolders:
for idx, subdir in enumerate(xmlfolder): if isinstance(xmlfolder, list) or isinstance(xmlfolder, tuple):
if isdir(subdir): # directory group : collect files from each
for filename in listdir(subdir): # directory and sort them before loading
group_files.append((filename, idx, subdir)) group_files = []
else: for idx, subdir in enumerate(xmlfolder):
group_files.append(basename(subdir), idx, dirname(subdir)) if isdir(subdir):
def sort_group(file1, file2): for filename in listdir(subdir):
if file1[0] == file2[0]: group_files.append((filename, idx, subdir))
# sort by initial xmlfolder order if same name else:
return file1[1].__cmp__(file2[1]) group_files.append(basename(subdir), idx, dirname(subdir))
# sort by filename def sort_group(file1, file2):
elif file1[0] > file2[0]: if file1[0] == file2[0]:
return 1 # sort by initial xmlfolder order if same name
else: return file1[1].__cmp__(file2[1])
return -1 # sort by filename
group_files.sort(sort_group) elif file1[0] > file2[0]:
filenames = [join(f[2], f[0]) for f in group_files] return 1
elif isdir(xmlfolder): else:
filenames = [] return -1
for filename in listdir(xmlfolder): group_files.sort(sort_group)
filenames.append(join(xmlfolder, filename)) filenames = [join(f[2], f[0]) for f in group_files]
filenames.sort() elif isdir(xmlfolder):
else: filenames = []
filenames = [xmlfolder] for filename in listdir(xmlfolder):
for xmlfile in filenames: filenames.append(join(xmlfolder, filename))
if xmlfile.endswith('.xml'): filenames.sort()
#xmlfile_path = join(xmlfolder, xmlfile) else:
documents.append((xmlfile, self.parse_xmlfile(xmlfile))) filenames = [xmlfolder]
for xmlfile in filenames:
if xmlfile.endswith('.xml'):
#xmlfile_path = join(xmlfolder, xmlfile)
documents.append((xmlfile, self.parse_xmlfile(xmlfile)))
return documents return documents
def save_xmlfile(self, xmlfilename, xml): # pylint: disable=R0201 def save_xmlfile(self, xmlfilename, xml): # pylint: disable=R0201

View File

@ -59,7 +59,3 @@ 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,7 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family name="services" doc="services"> <family name="services">
<property>hidden</property> <family name="service0" doc="tata">
<family doc="tata" name="tata"/> <property>basic</property>
</family>
</family> </family>
</rougail> </creole>

View File

@ -1,6 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <rougail>
<services/>
<variables> <variables>
<family name="général"> <family name="général">
<variable name="mode_conteneur_actif" type="oui/non" description="No change" auto_freeze="True"> <variable name="mode_conteneur_actif" type="oui/non" description="No change" auto_freeze="True">

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -10,7 +10,7 @@
<choice type="string">non</choice> <choice type="string">non</choice>
<property>mandatory</property> <property>mandatory</property>
<property>basic</property> <property>basic</property>
<property expected="oui" inverse="True" source="rougail.general.module_instancie" type="calculation">auto_frozen</property> <property expected="oui" inverse="True" source="creole.general.module_instancie" type="calculation">auto_frozen</property>
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
<variable doc="No change" multi="False" name="module_instancie" type="choice"> <variable doc="No change" multi="False" name="module_instancie" type="choice">
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -10,7 +10,7 @@
<choice type="string">non</choice> <choice type="string">non</choice>
<property>mandatory</property> <property>mandatory</property>
<property>expert</property> <property>expert</property>
<property expected="oui" inverse="True" source="rougail.general.module_instancie" type="calculation">auto_frozen</property> <property expected="oui" inverse="True" source="creole.general.module_instancie" type="calculation">auto_frozen</property>
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
<variable doc="No change" multi="False" name="module_instancie" type="choice"> <variable doc="No change" multi="False" name="module_instancie" type="choice">
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -14,4 +14,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>expert</property> <property>expert</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -14,4 +14,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -21,4 +21,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -26,4 +26,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">creole.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="Redefine description" multi="True" name="mode_conteneur_actif" type="choice"> <variable doc="Redefine description" multi="True" name="mode_conteneur_actif" type="choice">
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="Redefine description" multi="submulti" name="mode_conteneur_actif" type="choice"> <variable doc="Redefine description" multi="submulti" name="mode_conteneur_actif" type="choice">
@ -16,4 +16,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>basic</property> <property>basic</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -10,9 +10,9 @@
<choice type="string">non</choice> <choice type="string">non</choice>
<property>mandatory</property> <property>mandatory</property>
<property>basic</property> <property>basic</property>
<property expected="oui" inverse="True" source="rougail.general.module_instancie" type="calculation">auto_frozen</property> <property expected="oui" inverse="True" source="creole.general.module_instancie" type="calculation">auto_frozen</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">creole.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -32,4 +32,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>basic</property> <property>basic</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -10,7 +10,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>basic</property> <property>basic</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">creole.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">creole.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="Général" name="general"> <family doc="Général" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">creole.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,13 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="domain"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="domain">
<property>mandatory</property> <property>mandatory</property>
<property>expert</property> <property>expert</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">creole.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -20,4 +20,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,13 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="number"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="number">
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="number">3</param> <param transitive="False" type="number">3</param>
@ -23,4 +22,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -12,7 +12,7 @@
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.mode_conteneur_actif1</param> <param transitive="False" type="variable">creole.general.mode_conteneur_actif1</param>
</value> </value>
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif1" type="choice">
@ -25,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -15,7 +15,7 @@
</variable> </variable>
</family> </family>
<separators> <separators>
<separator name="rougail.general.mode_conteneur_actif">Établissement</separator> <separator name="creole.general.mode_conteneur_actif">Établissement</separator>
</separators> </separators>
</family> </family>
</rougail> </creole>

View File

@ -10,7 +10,7 @@
</variable> </variable>
</family> </family>
<separators> <separators>
<separator name="mode_conteneur_actif">Établissement</separator> <separator name="mode_conteneur_actif" never_hidden="True">Établissement</separator>
</separators> </separators>
</variables> </variables>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -15,7 +15,7 @@
</variable> </variable>
</family> </family>
<separators> <separators>
<separator name="rougail.general.mode_conteneur_actif">Établissement</separator> <separator name="creole.general.mode_conteneur_actif" never_hidden="True">Établissement</separator>
</separators> </separators>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -17,7 +17,6 @@
<property>force_store_value</property> <property>force_store_value</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>basic</property> <property>basic</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="string">oui</param> <param transitive="False" type="string">oui</param>
@ -26,4 +25,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

@ -16,7 +16,7 @@
<fill name="calc_val" target="autosavevar"> <fill name="calc_val" target="autosavevar">
<param>oui</param> <param>oui</param>
</fill> </fill>
<condition name="hidden_if_in" source="mode_conteneur_actif"> <condition name="frozen_if_in" source="mode_conteneur_actif">
<param>oui</param> <param>oui</param>
<target type="variable">autosavevar</target> <target type="variable">autosavevar</target>
</condition> </condition>

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="général" name="general"> <family doc="général" name="general">
<property>basic</property> <property>basic</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -15,11 +15,10 @@
</variable> </variable>
<variable doc="autosave variable" multi="False" name="autosavevar" type="string"> <variable doc="autosave variable" multi="False" name="autosavevar" type="string">
<property>force_store_value</property> <property>force_store_value</property>
<property>mandatory</property>
<property>basic</property> <property>basic</property>
<property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">frozen</property> <property expected="oui" inverse="False" source="creole.general.mode_conteneur_actif" type="calculation">frozen</property>
<property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">hidden</property> <property expected="oui" inverse="False" source="creole.general.mode_conteneur_actif" type="calculation">hidden</property>
<property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">force_default_on_freeze</property> <property expected="oui" inverse="False" source="creole.general.mode_conteneur_actif" type="calculation">force_default_on_freeze</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="string">oui</param> <param transitive="False" type="string">oui</param>
</value> </value>
@ -27,4 +26,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "b", "rougail.general.int": null} {"creole.general.mode_conteneur_actif": "b", "creole.general.int": null}

View File

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

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "b", "rougail.general.int2": 100, "rougail.general.int": null} {"creole.general.mode_conteneur_actif": "b", "creole.general.int2": 100, "creole.general.int": null}

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="string"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="string">
@ -16,11 +16,11 @@
<variable doc="No change" multi="False" name="int" type="number"> <variable doc="No change" multi="False" name="int" type="number">
<check name="valid_entier" warnings_only="False"> <check name="valid_entier" warnings_only="False">
<param name="mini" type="string">0</param> <param name="mini" type="string">0</param>
<param name="maxi" type="variable">rougail.general.int2</param> <param name="maxi" type="variable">creole.general.int2</param>
</check> </check>
<property>normal</property> <property>normal</property>
</variable> </variable>
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "b", "rougail.general.int": null, "rougail.general.int2": null} {"creole.general.mode_conteneur_actif": "b", "creole.general.int": null, "creole.general.int2": null}

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="string"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="string">
@ -10,8 +10,9 @@
</variable> </variable>
<variable doc="No change" multi="False" name="int" type="number"> <variable doc="No change" multi="False" name="int" type="number">
<check name="valid_not_equal" warnings_only="False"> <check name="valid_not_equal" warnings_only="False">
<param type="variable">rougail.general.int2</param> <param type="variable">creole.general.int2</param>
</check> </check>
<check name="valid_not_equal" warnings_only="False"/>
<property>normal</property> <property>normal</property>
</variable> </variable>
<variable doc="No change" multi="False" name="int2" type="number"> <variable doc="No change" multi="False" name="int2" type="number">
@ -20,4 +21,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

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

View File

@ -1,11 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<check name="valid_not_equal" warnings_only="False"> <check name="valid_not_equal" warnings_only="False">
<param type="variable">rougail.general.mode_conteneur_actif1</param> <param type="variable">creole.general.mode_conteneur_actif1</param>
</check> </check>
<choice type="string">oui</choice> <choice type="string">oui</choice>
<choice type="string">non</choice> <choice type="string">non</choice>
@ -23,4 +23,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "oui", "rougail.general.mode_conteneur_actif1": "non", "rougail.general.mode_conteneur_actif2": "non", "rougail.general.mode_conteneur_actif3": "oui"} {"creole.general.mode_conteneur_actif": "oui", "creole.general.mode_conteneur_actif1": "non", "creole.general.mode_conteneur_actif2": "non", "creole.general.mode_conteneur_actif3": "oui"}

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -26,10 +26,16 @@
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif3" type="string"> <variable doc="No change" multi="False" name="mode_conteneur_actif3" type="string">
<check name="valid_not_equal" warnings_only="False"> <check name="valid_not_equal" warnings_only="False">
<param type="variable">rougail.general.mode_conteneur_actif1</param> <param type="variable">creole.general.mode_conteneur_actif1</param>
</check> </check>
<check name="valid_not_equal" warnings_only="False"> <check name="valid_not_equal" warnings_only="False">
<param type="variable">rougail.general.mode_conteneur_actif2</param> <param type="variable">creole.general.mode_conteneur_actif2</param>
</check>
<check name="valid_not_equal" warnings_only="False">
<param type="variable">creole.general.mode_conteneur_actif1</param>
</check>
<check name="valid_not_equal" warnings_only="False">
<param type="variable">creole.general.mode_conteneur_actif2</param>
</check> </check>
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
@ -38,4 +44,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

@ -5,7 +5,7 @@
<variables> <variables>
<family name="general"> <family name="general">
<variable name="mode_conteneur_actif3" redefine="True"> <variable name="mode_conteneur_actif3" redefine="True" remove_check="True">
<value>oui</value> <value>oui</value>
</variable> </variable>
</family> </family>

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "oui", "rougail.general.mode_conteneur_actif1": "non", "rougail.general.mode_conteneur_actif2": "non", "rougail.general.mode_conteneur_actif3": "oui"} {"creole.general.mode_conteneur_actif": "oui", "creole.general.mode_conteneur_actif1": "non", "creole.general.mode_conteneur_actif2": "non", "creole.general.mode_conteneur_actif3": "oui"}

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -26,10 +26,10 @@
</variable> </variable>
<variable doc="No change" multi="False" name="mode_conteneur_actif3" type="string"> <variable doc="No change" multi="False" name="mode_conteneur_actif3" type="string">
<check name="valid_not_equal" warnings_only="False"> <check name="valid_not_equal" warnings_only="False">
<param type="variable">rougail.general.mode_conteneur_actif1</param> <param type="variable">creole.general.mode_conteneur_actif1</param>
</check> </check>
<check name="valid_not_equal" warnings_only="False"> <check name="valid_not_equal" warnings_only="False">
<param type="variable">rougail.general.mode_conteneur_actif2</param> <param type="variable">creole.general.mode_conteneur_actif2</param>
</check> </check>
<property>mandatory</property> <property>mandatory</property>
<property>normal</property> <property>normal</property>
@ -38,4 +38,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "oui", "rougail.general.adresse_ip_eth0": null, "rougail.general.adresse_netmask_eth0": null} {"creole.general.mode_conteneur_actif": "oui", "creole.general.adresse_ip_eth0": null, "creole.general.adresse_netmask_eth0": null}

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>basic</property> <property>basic</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
@ -16,7 +16,7 @@
</variable> </variable>
<variable doc="Masque de sous réseau de la carte" multi="False" name="adresse_netmask_eth0" type="netmask"> <variable doc="Masque de sous réseau de la carte" multi="False" name="adresse_netmask_eth0" type="netmask">
<check name="valid_ip_netmask" warnings_only="True"> <check name="valid_ip_netmask" warnings_only="True">
<param type="variable">rougail.general.adresse_ip_eth0</param> <param type="variable">creole.general.adresse_ip_eth0</param>
</check> </check>
<property>mandatory</property> <property>mandatory</property>
<property>basic</property> <property>basic</property>
@ -24,4 +24,4 @@
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

View File

@ -1,34 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="general1">
<variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">follower1</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

@ -1,39 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<family doc="rougail" name="rougail">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
</family>
<family doc="general1" name="general1">
<property>normal</property>
<leader doc="leader" name="leader">
<property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property>
<value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param>
</value>
</variable>
<variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property>
<value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general1.leader.follower1</param>
</value>
</variable>
<variable doc="follower3" multi="True" name="follower3" type="string">
<property>normal</property>
</variable>
</leader>
</family>
</family>
</rougail>

View File

@ -1,37 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True" hidden="True"/>
<variable name="follower2" type="string" description="follower2" multi="True" hidden="True"/>
<variable name="follower3" type="string" description="follower3" multi="True" hidden="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">follower1</param>
</fill>
<fill name="calc_val" target="follower3">
<param type="variable">leader</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
<follower>follower3</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

@ -1,32 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True" hidden="True"/>
<variable name="follower2" type="string" description="follower2" multi="True" hidden="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">leader</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

@ -1,31 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general" mode="expert">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="leadermode" mode="expert">
<variable name="leader" type="string" description="leader" multi="True" hidden="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/>
</family>
</variables>
<constraints>
<fill name="calc_list" target="leader">
<param name="valeur">valfill</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

@ -1,32 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/>
<variable name="follower2" type="string" description="follower2" multi="True" mode="expert"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">follower1</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

@ -1,32 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="Général">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">follower1</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

@ -1,32 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="leader" type="string" description="leader" multi="True" mandatory="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">follower1</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

@ -1,32 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True" mandatory="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">follower1</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
</constraints>
<help/>
</rougail>

View File

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

View File

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

View File

@ -1,41 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services/>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="general1">
<variable name="leader" type="string" description="leader" multi="True"/>
<variable name="follower1" type="string" description="follower1" multi="True"/>
<variable name="follower2" type="string" description="follower2" multi="True"/>
<variable name="leader1" type="string" description="leader" multi="True"/>
<variable name="follower11" type="string" description="follower1" multi="True"/>
<variable name="follower21" type="string" description="follower2" multi="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="follower1">
<param name="valeur">valfill</param>
</fill>
<fill name="calc_val" target="follower2">
<param type="variable">follower1</param>
</fill>
<group leader="leader">
<follower>follower1</follower>
<follower>follower2</follower>
</group>
<group leader="leader1">
<follower>follower11</follower>
<follower>follower21</follower>
</group>
</constraints>
<help/>
</rougail>

View File

@ -1 +0,0 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.general1.leader.leader": [], "rougail.general1.leader.follower1": [], "rougail.general1.leader.follower2": [], "rougail.general1.leader1.leader1": [], "rougail.general1.leader1.follower11": [], "rougail.general1.leader1.follower21": []}

View File

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

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<rougail> <creole>
<family doc="rougail" name="rougail"> <family doc="" name="creole">
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="condition" type="choice"> <variable doc="No change" multi="False" name="condition" type="choice">
@ -13,26 +13,20 @@
<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="rougail.general.condition" type="calculation">disabled</property> <property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
<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="rougail.general.condition" type="calculation">disabled</property> <property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>
<value type="string">non</value> <value type="string">non</value>
</variable> </variable>
</family> </family>
<separators/> <separators/>
</family> </family>
</rougail> </creole>

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