From 6bda6459030fecfd8e42e8ce8c2f4b936ffb9622 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 14 Nov 2020 17:20:55 +0100 Subject: [PATCH] leadership name --- src/rougail/annotator.py | 14 +++++++--- src/rougail/data/rougail.dtd | 1 + .../10load_leadership_name/00-base.xml | 27 +++++++++++++++++++ .../10load_leadership_name/__init__.py | 0 .../10load_leadership_name/makedict/base.json | 1 + .../tiramisu/__init__.py | 0 .../10load_leadership_name/tiramisu/base.py | 19 +++++++++++++ 7 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 tests/dictionaries/10load_leadership_name/00-base.xml create mode 100644 tests/dictionaries/10load_leadership_name/__init__.py create mode 100644 tests/dictionaries/10load_leadership_name/makedict/base.json create mode 100644 tests/dictionaries/10load_leadership_name/tiramisu/__init__.py create mode 100644 tests/dictionaries/10load_leadership_name/tiramisu/base.py diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index e3334c11..2f77c789 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -108,7 +108,7 @@ class GroupAnnotator: self.manage_follower(namespace, leader_family_name, variable, - leader_name, + leadership_name, follower_names, leader_space, leader_is_hidden, @@ -126,8 +126,13 @@ class GroupAnnotator: # leader_is_hidden = True else: leader_space = self.objectspace.Leadership(variable.xmlfiles) + if hasattr(group, 'name'): + leadership_name = group.name + else: + leadership_name = leader_name leader_is_hidden = self.manage_leader(leader_space, leader_family_name, + leadership_name, leader_name, namespace, variable, @@ -142,6 +147,7 @@ class GroupAnnotator: def manage_leader(self, leader_space: 'Leadership', leader_family_name: str, + leadership_name: str, leader_name: str, namespace: str, variable: 'Variable', @@ -152,7 +158,7 @@ class GroupAnnotator: if variable.multi is not True: raise DictConsistencyError(_('the variable {} in a group must be multi').format(variable.name)) leader_space.variable = [] - leader_space.name = leader_name + leader_space.name = leadership_name leader_space.hidden = variable.hidden if variable.hidden: leader_is_hidden = True @@ -167,9 +173,9 @@ class GroupAnnotator: leader_space.doc = variable.description else: leader_space.doc = variable.name - leader_path = namespace + '.' + leader_family_name + '.' + leader_name + leadership_path = namespace + '.' + leader_family_name + '.' + leadership_name self.objectspace.paths.add_family(namespace, - leader_path, + leadership_path, leader_space, ) leader_family = self.objectspace.space.variables[namespace].family[leader_family_name] diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 46f1e10a..6269540d 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -131,6 +131,7 @@ + diff --git a/tests/dictionaries/10load_leadership_name/00-base.xml b/tests/dictionaries/10load_leadership_name/00-base.xml new file mode 100644 index 00000000..b0dfda28 --- /dev/null +++ b/tests/dictionaries/10load_leadership_name/00-base.xml @@ -0,0 +1,27 @@ + + + + + + non + + + + + + + + + + + valfill + + + follower1 + + + follower1 + follower2 + + + diff --git a/tests/dictionaries/10load_leadership_name/__init__.py b/tests/dictionaries/10load_leadership_name/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/10load_leadership_name/makedict/base.json b/tests/dictionaries/10load_leadership_name/makedict/base.json new file mode 100644 index 00000000..e02048af --- /dev/null +++ b/tests/dictionaries/10load_leadership_name/makedict/base.json @@ -0,0 +1 @@ +{"rougail.general.mode_conteneur_actif": "non", "rougail.general1.other_name.leader": [], "rougail.general1.other_name.follower1": [], "rougail.general1.other_name.follower2": []} diff --git a/tests/dictionaries/10load_leadership_name/tiramisu/__init__.py b/tests/dictionaries/10load_leadership_name/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/10load_leadership_name/tiramisu/base.py b/tests/dictionaries/10load_leadership_name/tiramisu/base.py new file mode 100644 index 00000000..6a5fb478 --- /dev/null +++ b/tests/dictionaries/10load_leadership_name/tiramisu/base.py @@ -0,0 +1,19 @@ +import imp +func = imp.load_source('func', 'tests/dictionaries/../eosfunc/test.py') +for key, value in dict(locals()).items(): + if key != ['imp', 'func']: + setattr(func, key, value) +try: + from tiramisu3 import * +except: + from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) +option_6 = StrOption(name='leader', doc='leader', multi=True) +option_7 = StrOption(properties=frozenset({'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) +option_8 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_5 = Leadership(name='other_name', doc='leader', properties=frozenset({'normal'}), children=[option_6, option_7, option_8]) +option_4 = OptionDescription(name='general1', doc='general1', properties=frozenset({'normal'}), children=[option_5]) +option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])