feat: upgrade is not in formatter

This commit is contained in:
egarette@silique.fr 2025-01-02 21:06:13 +01:00
parent 6c1df5578f
commit 3849c42cba
30 changed files with 447 additions and 1674 deletions

View file

@ -5,8 +5,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"POT-Creation-Date: 2024-11-25 09:10+0100\n" "POT-Creation-Date: 2024-12-15 16:50+0100\n"
"PO-Revision-Date: 2024-11-25 09:11+0100\n" "PO-Revision-Date: 2024-12-15 16:55+0100\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: fr\n" "Language: fr\n"
@ -16,31 +16,31 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.5\n" "X-Generator: Poedit 3.5\n"
#: src/rougail/annotator/family.py:141 #: src/rougail/annotator/family.py:143
msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}" msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr "" msgstr ""
"le mode d'une variable par défaut \"{0}\" n'est pas un mode valide, les " "le mode d'une variable par défaut \"{0}\" n'est pas un mode valide, les "
"modes valides sont {1}" "modes valides sont {1}"
#: src/rougail/annotator/family.py:147 #: src/rougail/annotator/family.py:149
msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}" msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr "" msgstr ""
"le mode d'une famille par défaut \"{0}\" n'est pas un mode valide, les modes " "le mode d'une famille par défaut \"{0}\" n'est pas un mode valide, les modes "
"valides sont {1}" "valides sont {1}"
#: src/rougail/annotator/family.py:179 #: src/rougail/annotator/family.py:181
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}" msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}"
msgstr "" msgstr ""
"le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, les modes valides " "le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, les modes valides "
"sont {2}" "sont {2}"
#: src/rougail/annotator/family.py:183 #: src/rougail/annotator/family.py:185
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available" msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available"
msgstr "" msgstr ""
"le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, aucun mode ne sont " "le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, aucun mode ne sont "
"définis" "définis"
#: src/rougail/annotator/family.py:247 #: src/rougail/annotator/family.py:249
msgid "" msgid ""
"the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the " "the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the "
"higher family mode \"{2}\"" "higher family mode \"{2}\""
@ -48,7 +48,7 @@ msgstr ""
"la variable \"{0}\" est obligatoire donc dans le mode \"{1}\" mais la " "la variable \"{0}\" est obligatoire donc dans le mode \"{1}\" mais la "
"famille a un mode supérieur \"{2}\"" "famille a un mode supérieur \"{2}\""
#: src/rougail/annotator/family.py:285 #: src/rougail/annotator/family.py:287
msgid "" msgid ""
"the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode " "the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode "
"\"{2}\"" "\"{2}\""
@ -56,7 +56,7 @@ msgstr ""
"la variable suiveuse \"{0}\" a le mode \"{1}\" mais la variable leader a un " "la variable suiveuse \"{0}\" a le mode \"{1}\" mais la variable leader a un "
"mode supérieur \"{2}\"" "mode supérieur \"{2}\""
#: src/rougail/annotator/family.py:318 #: src/rougail/annotator/family.py:320
msgid "" msgid ""
"the family \"{0}\" is in \"{1}\" mode but variables and families inside have " "the family \"{0}\" is in \"{1}\" mode but variables and families inside have "
"the higher modes \"{2}\"" "the higher modes \"{2}\""
@ -64,7 +64,7 @@ msgstr ""
"la famille \"{0}\" a le mode \"{1}\" mais les variables et les familles à " "la famille \"{0}\" a le mode \"{1}\" mais les variables et les familles à "
"l'intérieur ont des modes supérieurs \"{2}\"" "l'intérieur ont des modes supérieurs \"{2}\""
#: src/rougail/annotator/family.py:336 #: src/rougail/annotator/family.py:338
msgid "" msgid ""
"the variable \"{0}\" is in \"{1}\" mode but family has the higher family " "the variable \"{0}\" is in \"{1}\" mode but family has the higher family "
"mode \"{2}\"" "mode \"{2}\""
@ -102,6 +102,64 @@ msgid ""
msgstr "" msgstr ""
"la variable \"{0}\" a la valeur par défaut invalide \"{1}\" devrait être {2}" "la variable \"{0}\" a la valeur par défaut invalide \"{1}\" devrait être {2}"
#: src/rougail/config.py:216
msgid "Directories where dictionary files are placed"
msgstr "Répertoires où sont placés les fichiers de structure"
#: src/rougail/config.py:227
msgid "Sort dictionaries from differents directories"
msgstr "Trier les fichiers de structure à partir de différents répertoires"
#: src/rougail/config.py:232
msgid "Main namespace name"
msgstr "Nom de l'espace de nom principal"
#: src/rougail/config.py:238
msgid "Extra namespaces"
msgstr "Espaces de nom supplémentaires"
#: src/rougail/config.py:245
msgid "Extra namespace name"
msgstr "Nom de l'espace de nom supplémentaire"
#: src/rougail/config.py:251
msgid "Directories where extra dictionary files are placed"
msgstr ""
"Répertoires où sont placés les fichiers de structure de l'espace de nom "
"supplémentaire"
#: src/rougail/config.py:262
msgid "Update dictionaries to newest Rougail format version"
msgstr ""
"Mettre à jour le fichier de structure vers la dernière version du format de "
"Rougail"
#: src/rougail/config.py:263
msgid "Do not update dictionaries to newest Rougail format version"
msgstr ""
"Ne pas mettre à jour le fichier de structure vers la dernière version du "
"format de Rougail"
#: src/rougail/config.py:267
msgid "Update informations"
msgstr "Mise à jour des informations"
#: src/rougail/config.py:273
msgid "Directories where dictionary files will be placed"
msgstr "Répertoires où sont placés les fichiers de structure"
#: src/rougail/config.py:278
msgid "Directories where extra files will be placed"
msgstr "Répertoires où sont placés les fichiers de structure supplémentaire"
#: src/rougail/config.py:290
msgid "File with functions"
msgstr "Fichier avec les fonctions"
#: src/rougail/config.py:302
msgid "All modes level available"
msgstr "Tous les niveaux de modes valides"
#: src/rougail/convert.py:281 #: src/rougail/convert.py:281
msgid "" msgid ""
"A variable or a family located in the \"{0}\" namespace shall not be used in " "A variable or a family located in the \"{0}\" namespace shall not be used in "
@ -110,15 +168,19 @@ msgstr ""
"Une variable ou une famille localisé dans l'espace de nom \"{0}\" ne devrait " "Une variable ou une famille localisé dans l'espace de nom \"{0}\" ne devrait "
"pas être utilisé dans l'espace de nom \"{1}\"" "pas être utilisé dans l'espace de nom \"{1}\""
#: src/rougail/convert.py:477 #: src/rougail/convert.py:480
msgid "unknown type {0} for {1}" msgid "unknown type {0} for {1}"
msgstr "type {0} inconnu pour {1}" msgstr "type {0} inconnu pour {1}"
#: src/rougail/convert.py:1347 #: src/rougail/convert.py:613
msgid "The family \"{0}\" already exists and it is not redefined"
msgstr "La famille \"{0}\" existe déjà et n'est pas redéfinie"
#: src/rougail/convert.py:1356
msgid "duplicate dictionary file name {0}" msgid "duplicate dictionary file name {0}"
msgstr "nom de fichier {0} de dictionnaire dupliqué" msgstr "nom de fichier {0} de dictionnaire dupliqué"
#: src/rougail/convert.py:1394 #: src/rougail/convert.py:1403
msgid "Cannot execute annotate multiple time" msgid "Cannot execute annotate multiple time"
msgstr "Ne peut exécuter l'annotation plusieurs fois" msgstr "Ne peut exécuter l'annotation plusieurs fois"

View file

@ -5,7 +5,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-11-25 09:10+0100\n" "POT-Creation-Date: 2024-12-15 16:57+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -15,35 +15,35 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
#: src/rougail/annotator/family.py:141 #: src/rougail/annotator/family.py:143
msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}" msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr "" msgstr ""
#: src/rougail/annotator/family.py:147 #: src/rougail/annotator/family.py:149
msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}" msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr "" msgstr ""
#: src/rougail/annotator/family.py:179 #: src/rougail/annotator/family.py:181
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}" msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}"
msgstr "" msgstr ""
#: src/rougail/annotator/family.py:183 #: src/rougail/annotator/family.py:185
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available" msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available"
msgstr "" msgstr ""
#: src/rougail/annotator/family.py:247 #: src/rougail/annotator/family.py:249
msgid "the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the higher family mode \"{2}\"" msgid "the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the higher family mode \"{2}\""
msgstr "" msgstr ""
#: src/rougail/annotator/family.py:285 #: src/rougail/annotator/family.py:287
msgid "the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode \"{2}\"" msgid "the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode \"{2}\""
msgstr "" msgstr ""
#: src/rougail/annotator/family.py:318 #: src/rougail/annotator/family.py:320
msgid "the family \"{0}\" is in \"{1}\" mode but variables and families inside have the higher modes \"{2}\"" msgid "the family \"{0}\" is in \"{1}\" mode but variables and families inside have the higher modes \"{2}\""
msgstr "" msgstr ""
#: src/rougail/annotator/family.py:336 #: src/rougail/annotator/family.py:338
msgid "the variable \"{0}\" is in \"{1}\" mode but family has the higher family mode \"{2}\"" msgid "the variable \"{0}\" is in \"{1}\" mode but family has the higher family mode \"{2}\""
msgstr "" msgstr ""
@ -67,19 +67,75 @@ msgstr ""
msgid "the variable \"{0}\" has an unvalid default value \"{1}\" should be in {2}" msgid "the variable \"{0}\" has an unvalid default value \"{1}\" should be in {2}"
msgstr "" msgstr ""
#: src/rougail/config.py:216
msgid "Directories where dictionary files are placed"
msgstr ""
#: src/rougail/config.py:227
msgid "Sort dictionaries from differents directories"
msgstr ""
#: src/rougail/config.py:232
msgid "Main namespace name"
msgstr ""
#: src/rougail/config.py:238
msgid "Extra namespaces"
msgstr ""
#: src/rougail/config.py:245
msgid "Extra namespace name"
msgstr ""
#: src/rougail/config.py:251
msgid "Directories where extra dictionary files are placed"
msgstr ""
#: src/rougail/config.py:262
msgid "Update dictionaries to newest Rougail format version"
msgstr ""
#: src/rougail/config.py:263
msgid "Do not update dictionaries to newest Rougail format version"
msgstr ""
#: src/rougail/config.py:267
msgid "Update informations"
msgstr ""
#: src/rougail/config.py:273
msgid "Directories where dictionary files will be placed"
msgstr ""
#: src/rougail/config.py:278
msgid "Directories where extra files will be placed"
msgstr ""
#: src/rougail/config.py:290
msgid "File with functions"
msgstr ""
#: src/rougail/config.py:302
msgid "All modes level available"
msgstr ""
#: src/rougail/convert.py:281 #: src/rougail/convert.py:281
msgid "A variable or a family located in the \"{0}\" namespace shall not be used in the \"{1}\" namespace" msgid "A variable or a family located in the \"{0}\" namespace shall not be used in the \"{1}\" namespace"
msgstr "" msgstr ""
#: src/rougail/convert.py:477 #: src/rougail/convert.py:480
msgid "unknown type {0} for {1}" msgid "unknown type {0} for {1}"
msgstr "" msgstr ""
#: src/rougail/convert.py:1347 #: src/rougail/convert.py:613
msgid "The family \"{0}\" already exists and it is not redefined"
msgstr ""
#: src/rougail/convert.py:1356
msgid "duplicate dictionary file name {0}" msgid "duplicate dictionary file name {0}"
msgstr "" msgstr ""
#: src/rougail/convert.py:1394 #: src/rougail/convert.py:1403
msgid "Cannot execute annotate multiple time" msgid "Cannot execute annotate multiple time"
msgstr "" msgstr ""

View file

@ -71,30 +71,38 @@ class SpaceAnnotator: # pylint: disable=R0903
if extra_annotator in ANNOTATORS: if extra_annotator in ANNOTATORS:
continue continue
get_annotators(ANNOTATORS, extra_annotator) get_annotators(ANNOTATORS, extra_annotator)
if objectspace.output: for structural in objectspace.structurals:
try: try:
get_annotators(ANNOTATORS, f"rougail.output_{objectspace.output}", "annotator") get_annotators(
ANNOTATORS, f"rougail.structural_{structural}", "annotator"
)
except ModuleNotFoundError: except ModuleNotFoundError:
pass pass
for user_data in objectspace.user_datas: for user_data in objectspace.user_datas:
try: try:
get_annotators(ANNOTATORS, f"rougail.user_data_{user_data}", "annotator") get_annotators(
ANNOTATORS, f"rougail.user_data_{user_data}", "annotator"
)
except ModuleNotFoundError: except ModuleNotFoundError:
pass pass
for plugin in objectspace.plugins: if objectspace.output:
try: try:
get_annotators(ANNOTATORS, f"rougail.{plugin}", "annotator") get_annotators(
ANNOTATORS, f"rougail.output_{objectspace.output}", "annotator"
)
except ModuleNotFoundError: except ModuleNotFoundError:
pass pass
annotators = ANNOTATORS["rougail.annotator"].copy() annotators = ANNOTATORS["rougail.annotator"].copy()
for extra_annotator in objectspace.extra_annotators: for extra_annotator in objectspace.extra_annotators:
annotators.extend(ANNOTATORS[extra_annotator]) annotators.extend(ANNOTATORS[extra_annotator])
for plugin in objectspace.plugins: for structural in objectspace.structurals:
annotators.extend(ANNOTATORS[f"rougail.{plugin}.annotator"]) annotators.extend(ANNOTATORS[f"rougail.structural_{structural}.annotator"])
for user_data in objectspace.user_datas: for user_data in objectspace.user_datas:
annotators.extend(ANNOTATORS[f"rougail.user_data_{user_data}.annotator"]) annotators.extend(ANNOTATORS[f"rougail.user_data_{user_data}.annotator"])
if objectspace.output: if objectspace.output:
annotators.extend(ANNOTATORS[f"rougail.output_{objectspace.output}.annotator"]) annotators.extend(
ANNOTATORS[f"rougail.output_{objectspace.output}.annotator"]
)
annotators = sorted(annotators, key=get_level) annotators = sorted(annotators, key=get_level)
functions = {} functions = {}
functions_files = objectspace.functions_files functions_files = objectspace.functions_files

View file

@ -126,12 +126,15 @@ class Annotator(Walk):
family.dynamic, VariableCalculation family.dynamic, VariableCalculation
): ):
path = family.dynamic.variable path = family.dynamic.variable
if family.version != "1.0" and self.objectspace.paths.regexp_relative.search(path): if (
family.version != "1.0"
and self.objectspace.paths.regexp_relative.search(path)
):
path = self.objectspace.paths.get_full_path( path = self.objectspace.paths.get_full_path(
family.dynamic.variable, family.dynamic.variable,
family.path, family.path,
) )
if family.version == '1.0' and "{{ suffix }}" in path: if family.version == "1.0" and "{{ suffix }}" in path:
path = path.replace("{{ suffix }}", "{{ identifier }}") path = path.replace("{{ suffix }}", "{{ identifier }}")
self.objectspace.informations.add(family.path, "dynamic_variable", path) self.objectspace.informations.add(family.path, "dynamic_variable", path)

View file

@ -64,7 +64,11 @@ def get_sub_modules():
def get_level(module): def get_level(module):
return module["level"] return float(module["level"]) + {
"structural": 0.1,
"user data": 0.2,
"output": 0.3,
}.get(module["process"])
class _RougailConfig: class _RougailConfig:
@ -187,10 +191,12 @@ class FakeRougailConvert(RougailConvert):
self.export_with_import = True self.export_with_import = True
self.internal_functions = [] self.internal_functions = []
self.force_optional = False self.force_optional = False
self.plugins = ["structural_commandline"] self.structurals = ["commandline"]
self.user_datas = [] self.user_datas = []
self.output = None self.output = None
self.add_extra_options = self.add_extra_options self.add_extra_options = self.add_extra_options
self.tiramisu_cache = False
self.load_unexist_redefine = False
def get_rougail_config( def get_rougail_config(
@ -198,10 +204,6 @@ def get_rougail_config(
backward_compatibility: bool = True, backward_compatibility: bool = True,
add_extra_options: bool = True, add_extra_options: bool = True,
) -> _RougailConfig: ) -> _RougailConfig:
if backward_compatibility:
main_namespace_default = "rougail"
else:
main_namespace_default = "null"
rougail_options = f"""default_dictionary_format_version: rougail_options = f"""default_dictionary_format_version:
description: Dictionary format version by default, if not specified in dictionary file description: Dictionary format version by default, if not specified in dictionary file
alternative_name: v alternative_name: v
@ -210,82 +212,8 @@ def get_rougail_config(
- '1.1' - '1.1'
mandatory: false mandatory: false
main_dictionaries:
description: 'Directories where dictionary files are placed'
type: unix_filename
alternative_name: m
params:
allow_relative: True
test_existence: True
types:
- directory
multi: true
sort_dictionaries_all:
description: Sort dictionaries from differents directories
negative_description: Sort dictionaries directory by directory
default: false
main_namespace:
description: Main namespace name
default: {main_namespace_default}
alternative_name: s
mandatory: false
extra_dictionaries:
description: Extra namespaces
type: leadership
disabled:
variable: main_namespace
when: null
names:
description: 'Extra namespace name'
alternative_name: xn
multi: true
mandatory: false
directories:
description: Directories where extra dictionary files are placed
alternative_name: xd
type: unix_filename
params:
allow_relative: true
test_existence: true
types:
- directory
multi: true
upgrade:
description: Update dictionaries to newest Rougail format version
negative_description: Do not update dictionaries to newest Rougail format version
default: false
upgrade_options:
description: Update informations
disabled:
variable: upgrade
when: false
main_dictionaries:
description: 'Directories where dictionary files will be placed'
default:
variable: __.main_dictionaries
extra_dictionary:
description: 'Directories where extra files will be placed'
type: unix_filename
params:
allow_relative: true
test_existence: true
types:
- directory
disabled:
variable: __.main_namespace
when: null
functions_files: functions_files:
description: File with functions description: {_("File with functions")}
alternative_name: c alternative_name: c
type: unix_filename type: unix_filename
params: params:
@ -297,74 +225,73 @@ functions_files:
mandatory: false mandatory: false
modes_level: modes_level:
description: All modes level available description: {_("All modes level available")}
multi: true multi: true
mandatory: false mandatory: false
""" """
if backward_compatibility: if backward_compatibility:
rougail_options += """ rougail_options += """ default:
default:
- basic - basic
- standard - standard
- advanced - advanced
""" """
rougail_options += """ rougail_options += f"""
default_family_mode: default_family_mode:
description: Default mode for a family description: {_("Default mode for a family")}
default: default:
jinja: | jinja: |
{% if modes_level %} {{% if modes_level %}}
{{ modes_level[0] }} {{{{ modes_level[0] }}}}
{% endif %} {{% endif %}}
disabled: disabled:
jinja: | jinja: |
{% if not modes_level %} {{% if not modes_level %}}
No mode No mode
{% endif %} {{% endif %}}
validators: validators:
- type: jinja - type: jinja
jinja: | jinja: |
{% if default_family_mode not in modes_level %} {{% if default_family_mode not in modes_level %}}
not in modes_level ({modes_level}) not in modes_level ({{modes_level}})
{% endif %} {{% endif %}}
commandline: false commandline: false
default_variable_mode: default_variable_mode:
description: Default mode for a variable description: {_("Default mode for a variable")}
default: default:
jinja: | jinja: |
{% if modes_level %} {{% if modes_level %}}
{% if modes_level | length == 1 %} {{% if modes_level | length == 1 %}}
{{ modes_level[0] }} {{{{ modes_level[0] }}}}
{% else %} {{% else %}}
{{ modes_level[1] }} {{{{ modes_level[1] }}}}
{% endif %} {{% endif %}}
{% endif %} {{% endif %}}
disabled: disabled:
jinja: | jinja: |
{% if not modes_level %} {{% if not modes_level %}}
No mode No mode
{% endif %} {{% endif %}}
validators: validators:
- type: jinja - type: jinja
jinja: | jinja: |
{% if default_variable_mode not in modes_level %} {{% if default_variable_mode not in modes_level %}}
not in modes_level ({modes_level}) not in modes_level ({{modes_level}})
{% endif %} {{% endif %}}
commandline: false commandline: false
base_option_name: base_option_name:
description: Option name for the base option description: {_("Option name for the base option")}
default: baseoption default: baseoption
commandline: false commandline: false
not_export_with_import: not_export_with_import:
description: In cache file, do not importation of Tiramisu and other dependencies description: {_("In cache file, do not importation of Tiramisu and other dependencies")}
default: false default: false
commandline: false commandline: false
tiramisu_cache: tiramisu_cache:
description: Tiramisu cache filename description: {_("Tiramisu cache filename")}
alternative_name: t alternative_name: t
type: unix_filename type: unix_filename
mandatory: false mandatory: false
@ -372,52 +299,52 @@ tiramisu_cache:
allow_relative: true allow_relative: true
internal_functions: internal_functions:
description: Name of internal functions that we can use as a function description: {_("Name of internal functions that we can use as a function")}
multi: true multi: true
mandatory: false mandatory: false
commandline: false commandline: false
extra_annotators: extra_annotators:
description: Name of extra annotators description: {_("Name of extra annotators")}
multi: true
mandatory: false
commandline: false
plugins:
description: Name of Rougail plugins
multi: true multi: true
mandatory: false mandatory: false
commandline: false commandline: false
suffix: suffix:
description: Suffix add to generated option name description: {_("Suffix add to generated option name")}
default: '' default: ''
mandatory: false mandatory: false
commandline: false commandline: false
force_optional: force_optional:
description: Every variable in calculation are optional description: {_("Every variable in calculation are optional")}
negative_description: Variable in calculation are not optional by default negative_description: {_("Variable in calculation are not optional by default")}
default: False default: False
load_unexist_redefine:
description: {_("Load redefine variable even if there don't already exists")}
negative_description: {_("Load redefine variable even if there don't already exists")}
commandline: false
default: False
""" """
processes = { processes = {
"structural": [], "structural": [],
"output": [],
"user data": [], "user data": [],
"output": [],
} }
for module in get_sub_modules().values(): for module in get_sub_modules().values():
data = module.get_rougail_config() data = module.get_rougail_config(backward_compatibility=backward_compatibility)
processes[data["process"]].append(data) processes[data["process"]].append(data)
# reorder # reorder
for process in processes: for process in processes:
processes[process] = list(sorted(processes[process], key=get_level)) processes[process] = list(sorted(processes[process], key=get_level))
rougail_process = """step: # Load and exporter steps rougail_process = "step: # Load and exporter steps"
disabled:
variable: upgrade"""
for process in processes: for process in processes:
if processes[process]: if processes[process]:
objects = processes[process] objects = processes[process]
rougail_process += """ rougail_process += """
{NAME}: {NAME}:
description: Select for {NAME} description: Select for {NAME}
alternative_name: {NAME[0]} alternative_name: {NAME[0]}
@ -428,26 +355,29 @@ force_optional:
for obj in objects: for obj in objects:
rougail_process += f" - {obj['name']}\n" rougail_process += f" - {obj['name']}\n"
if process == "structural": if process == "structural":
rougail_process += " commandline: false" rougail_process += """ commandline: false
multi: true
default:
- directory
"""
elif process == "user data": elif process == "user data":
rougail_process += """ multi: true rougail_process += """ multi: true
mandatory: false mandatory: false"""
"""
hidden_outputs = [ hidden_outputs = [
process["name"] process["name"]
for process in processes["output"] for process in processes["output"]
if not process.get("allow_user_data", True) if not process.get("allow_user_data", True)
] ]
if hidden_outputs: if hidden_outputs:
rougail_process += """ hidden: rougail_process += """
hidden:
type: jinja type: jinja
jinja: | jinja: |
""" """
for hidden_output in hidden_outputs: for hidden_output in hidden_outputs:
rougail_process += """ {% if _.output == 'NAME' %} rougail_process += """ {% if _.output == 'NAME' %}
Cannot load user data for NAME output Cannot load user data for NAME output
{% endif %} {% endif %}""".replace(
""".replace(
"NAME", hidden_output "NAME", hidden_output
) )
elif objects: elif objects:
@ -455,10 +385,10 @@ force_optional:
DEFAULT=objects[0]["name"] DEFAULT=objects[0]["name"]
) )
else: else:
if process == 'output': if process == "output":
prop = 'hidden' prop = "hidden"
else: else:
prop = 'disabled' prop = "disabled"
rougail_process += """ rougail_process += """
{NAME}: {NAME}:
description: Select for {NAME} description: Select for {NAME}
@ -473,8 +403,9 @@ force_optional:
PROP=prop, PROP=prop,
) )
rougail_options += rougail_process rougail_options += rougail_process
# print(rougail_options)
convert = FakeRougailConvert(add_extra_options) convert = FakeRougailConvert(add_extra_options)
convert._init() convert.init()
convert.namespace = None convert.namespace = None
convert.parse_root_file( convert.parse_root_file(
"rougail.config", "rougail.config",
@ -483,25 +414,27 @@ force_optional:
YAML().load(rougail_options), YAML().load(rougail_options),
) )
extra_vars = {} extra_vars = {}
for process in processes: objects = []
for obj in processes[process]: for obj in sorted(
if "extra_vars" in obj: [obj for objects in processes.values() for obj in objects], key=get_level
extra_vars |= obj["extra_vars"] ):
if not "options" in obj: if "extra_vars" in obj:
continue extra_vars |= obj["extra_vars"]
if not isinstance(obj["options"], list): if not "options" in obj:
options = [obj["options"]] continue
else: if not isinstance(obj["options"], list):
options = obj["options"] options = [obj["options"]]
for option in options: else:
convert.parse_root_file( options = obj["options"]
f'rougail.config.{obj["name"]}', for option in options:
"", convert.parse_root_file(
"1.1", f'rougail.config.{obj["name"]}',
YAML().load(option), "",
) "1.1",
YAML().load(option),
)
tiram_obj = convert.save(None) tiram_obj = convert.save()
optiondescription = {} optiondescription = {}
exec(tiram_obj, {}, optiondescription) # pylint: disable=W0122 exec(tiram_obj, {}, optiondescription) # pylint: disable=W0122
return _RougailConfig( return _RougailConfig(

View file

@ -69,10 +69,6 @@ class DictConsistencyError(Exception):
self.errno = errno self.errno = errno
class UpgradeError(Exception):
"""Error during XML upgrade"""
## ---- generic exceptions ---- ## ---- generic exceptions ----

View file

@ -27,7 +27,7 @@ from pydantic import (
ConfigDict, ConfigDict,
) )
from tiramisu import undefined from tiramisu import undefined
from .utils import get_jinja_variable_to_param, get_realpath from .utils import get_jinja_variable_to_param
from .error import DictConsistencyError, VariableCalculationDependencyError from .error import DictConsistencyError, VariableCalculationDependencyError
BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None] BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None]
@ -178,7 +178,6 @@ PARAM_TYPES = {
class Calculation(BaseModel): class Calculation(BaseModel):
path_prefix: Optional[str]
path: str path: str
inside_list: bool inside_list: bool
version: str version: str
@ -189,12 +188,6 @@ class Calculation(BaseModel):
model_config = ConfigDict(extra="forbid") model_config = ConfigDict(extra="forbid")
def get_realpath(
self,
path: str,
) -> str:
return get_realpath(path, self.path_prefix)
def get_params(self, objectspace): def get_params(self, objectspace):
if not self.params: if not self.params:
return {} return {}
@ -208,7 +201,6 @@ class Calculation(BaseModel):
path = self.ori_path path = self.ori_path
variable, identifier = objectspace.paths.get_with_dynamic( variable, identifier = objectspace.paths.get_with_dynamic(
param["variable"], param["variable"],
self.path_prefix,
path, path,
self.version, self.version,
self.namespace, self.namespace,
@ -220,7 +212,12 @@ class Calculation(BaseModel):
raise DictConsistencyError(msg, 22, self.xmlfiles) raise DictConsistencyError(msg, 22, self.xmlfiles)
continue continue
if not isinstance(variable, objectspace.variable): if not isinstance(variable, objectspace.variable):
raise Exception("pfff it's a family") if isinstance(variable, objectspace.family):
msg = f'the variable "{variable["name"]}" is in fact a family in attribute "{self.attribute_name}" for "{self.path}"'
raise DictConsistencyError(msg, 42, self.xmlfiles)
else:
msg = f'unknown object "{variable}" in attribute "{self.attribute_name}" for "{self.path}"'
raise DictConsistencyError(msg, 44, self.xmlfiles)
param["variable"] = variable param["variable"] = variable
if identifier: if identifier:
param["identifier"] = identifier param["identifier"] = identifier
@ -232,7 +229,6 @@ class Calculation(BaseModel):
path = self.ori_path path = self.ori_path
variable, identifier = objectspace.paths.get_with_dynamic( variable, identifier = objectspace.paths.get_with_dynamic(
param["variable"], param["variable"],
self.path_prefix,
path, path,
self.version, self.version,
self.namespace, self.namespace,
@ -314,7 +310,6 @@ class JinjaCalculation(Calculation):
objectspace, objectspace,
variable.xmlfiles, variable.xmlfiles,
objectspace.functions, objectspace.functions,
self.path_prefix,
self.version, self.version,
self.namespace, self.namespace,
): ):
@ -413,15 +408,18 @@ class _VariableCalculation(Calculation):
path = self.ori_path path = self.ori_path
variable, identifier = objectspace.paths.get_with_dynamic( variable, identifier = objectspace.paths.get_with_dynamic(
self.variable, self.variable,
self.path_prefix,
path, path,
self.version, self.version,
self.namespace, self.namespace,
self.xmlfiles, self.xmlfiles,
) )
if variable and not isinstance(variable, objectspace.variable): if variable and not isinstance(variable, objectspace.variable):
# FIXME remove the pfff if isinstance(variable, objectspace.family):
raise Exception("pfff it's a family") msg = f'the variable "{variable.path}" is in fact a family in attribute "{self.attribute_name}" for "{self.path}"'
raise DictConsistencyError(msg, 47, self.xmlfiles)
else:
msg = f'unknown object "{variable}" in attribute "{self.attribute_name}" for "{self.path}"'
raise DictConsistencyError(msg, 48, self.xmlfiles)
return variable, identifier return variable, identifier
def get_params( def get_params(
@ -434,9 +432,13 @@ class _VariableCalculation(Calculation):
): ):
if not variable: if not variable:
if not objectspace.force_optional: if not objectspace.force_optional:
msg = f'Variable not found "{self.variable}" for attribut "{self.attribute_name}" for variable "{self.path}"' if self.ori_path is None:
path = self.path
else:
path = self.ori_path
msg = f'Variable not found "{self.variable}" for attribut "{self.attribute_name}" in variable "{path}"'
raise DictConsistencyError(msg, 88, self.xmlfiles) raise DictConsistencyError(msg, 88, self.xmlfiles)
return {None: [['example']]} return {None: [["example"]]}
param = { param = {
"type": "variable", "type": "variable",
"variable": variable, "variable": variable,
@ -497,7 +499,7 @@ class _VariableCalculation(Calculation):
multi = objectspace.multis[self.path] == "submulti" multi = objectspace.multis[self.path] == "submulti"
else: else:
multi = self.path in objectspace.multis multi = self.path in objectspace.multis
if multi: if multi and not self.inside_list:
params["__internal_multi"] = True params["__internal_multi"] = True
return params return params
@ -514,7 +516,11 @@ class VariableCalculation(_VariableCalculation):
msg = f'"{self.attribute_name}" variable shall not have an "optional" attribute for variable "{self.variable}"' msg = f'"{self.attribute_name}" variable shall not have an "optional" attribute for variable "{self.variable}"'
raise DictConsistencyError(msg, 33, self.xmlfiles) raise DictConsistencyError(msg, 33, self.xmlfiles)
variable, identifier = self.get_variable(objectspace) variable, identifier = self.get_variable(objectspace)
if not variable and self.optional or (objectspace.force_optional and self.attribute_name == "default"): if (
not variable
and self.optional
or (objectspace.force_optional and self.attribute_name == "default")
):
raise VariableCalculationDependencyError() raise VariableCalculationDependencyError()
params = self.get_params( params = self.get_params(
objectspace, objectspace,
@ -600,7 +606,6 @@ class InformationCalculation(Calculation):
path = self.ori_path path = self.ori_path
variable, identifier = objectspace.paths.get_with_dynamic( variable, identifier = objectspace.paths.get_with_dynamic(
self.variable, self.variable,
self.path_prefix,
path, path,
self.version, self.version,
self.namespace, self.namespace,
@ -704,16 +709,16 @@ class IndexCalculation(Calculation):
CALCULATION_TYPES = { CALCULATION_TYPES = {
"jinja": JinjaCalculation, "jinja": JinjaCalculation,
"variable": VariableCalculation,
"information": InformationCalculation, "information": InformationCalculation,
"variable": VariableCalculation,
"identifier": IdentifierCalculation, "identifier": IdentifierCalculation,
"suffix": IdentifierCalculation, "suffix": IdentifierCalculation,
"index": IndexCalculation, "index": IndexCalculation,
} }
CALCULATION_PROPERTY_TYPES = { CALCULATION_PROPERTY_TYPES = {
"jinja": JinjaCalculation, "jinja": JinjaCalculation,
"variable": VariablePropertyCalculation,
"information": InformationCalculation, "information": InformationCalculation,
"variable": VariablePropertyCalculation,
"identifier": IdentifierPropertyCalculation, "identifier": IdentifierPropertyCalculation,
"index": IndexCalculation, "index": IndexCalculation,
} }
@ -722,14 +727,18 @@ BASETYPE_CALC = Union[StrictBool, StrictInt, StrictFloat, StrictStr, Calculation
class Family(BaseModel): class Family(BaseModel):
name: str name: str
# informations
description: Optional[str] = None description: Optional[str] = None
type: Literal["family", "leadership", "dynamic"] = "family"
path: str
help: Optional[str] = None help: Optional[str] = None
mode: Optional[str] = None mode: Optional[str] = None
# validation
type: Literal["family", "leadership", "dynamic"] = "family"
# properties
hidden: Union[bool, Calculation] = False hidden: Union[bool, Calculation] = False
disabled: Union[bool, Calculation] = False disabled: Union[bool, Calculation] = False
# others
namespace: Optional[str] namespace: Optional[str]
path: str
version: str version: str
xmlfiles: List[str] = [] xmlfiles: List[str] = []
@ -743,30 +752,34 @@ class Dynamic(Family):
class Variable(BaseModel): class Variable(BaseModel):
# type will be set dynamically in `annotator/value.py`, default is None
type: str = None
name: str name: str
# user informations
description: Optional[str] = None description: Optional[str] = None
default: Union[List[BASETYPE_CALC], BASETYPE_CALC] = None
choices: Optional[Union[List[BASETYPE_CALC], Calculation]] = None
regexp: Optional[str] = None
params: Optional[List[Param]] = None
validators: Optional[List[Calculation]] = None
multi: Optional[bool] = None
unique: Optional[bool] = None
help: Optional[str] = None help: Optional[str] = None
hidden: Union[bool, Calculation] = False mode: Optional[str] = None
disabled: Union[bool, Calculation] = False examples: Optional[list] = None
test: Optional[list] = None
# validations
## type will be set dynamically in `annotator/value.py`, default is None
type: str = None
params: Optional[List[Param]] = None
regexp: Optional[str] = None
choices: Optional[Union[List[BASETYPE_CALC], Calculation]] = None
multi: Optional[bool] = None
validators: Optional[List[Calculation]] = None
# value
default: Union[List[BASETYPE_CALC], BASETYPE_CALC] = None
# properties
auto_save: bool = False
mandatory: Union[None, bool, Calculation] = None mandatory: Union[None, bool, Calculation] = None
empty: Union[None, bool, Calculation] = True empty: Union[None, bool, Calculation] = True
auto_save: bool = False unique: Optional[bool] = None
mode: Optional[str] = None hidden: Union[bool, Calculation] = False
test: Optional[list] = None disabled: Union[bool, Calculation] = False
examples: Optional[list] = None # others
path: str path: str
namespace: Optional[str] namespace: Optional[str]
version: str version: str
path_prefix: Optional[str]
xmlfiles: List[str] = [] xmlfiles: List[str] = []
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True) model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
@ -779,7 +792,6 @@ class SymLink(BaseModel):
opt: Variable opt: Variable
namespace: Optional[str] namespace: Optional[str]
version: str version: str
path_prefix: Optional[str]
xmlfiles: List[str] = [] xmlfiles: List[str] = []
model_config = ConfigDict(extra="forbid") model_config = ConfigDict(extra="forbid")

View file

@ -0,0 +1,22 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from .object_model import Variable, Family
__all__ = ("Variable", "Family")

View file

@ -27,12 +27,13 @@ def get_rougail_config(
structural_commandline: structural_commandline:
description: Configuration rougail-structural_commandline description: Configuration rougail-structural_commandline
commandline: false commandline: false
add_extra_options: add_extra_options:
description: Add extra options to tiramisu-cmdline-parser description: Add extra options to tiramisu-cmdline-parser
default: true default: true
""" """
return { return {
"name": "exporter", "name": "cmdline",
"process": "structural", "process": "structural",
"options": options, "options": options,
"level": 20, "level": 20,

View file

@ -29,6 +29,3 @@ class Variable(BaseModel):
class Family(BaseModel): class Family(BaseModel):
commandline: bool = True commandline: bool = True
__all__ = ("Variable", "Family")

View file

@ -127,7 +127,9 @@ def jinja_to_function(
c_kw = kw c_kw = kw
path, var = key.rsplit(".", 1) path, var = key.rsplit(".", 1)
if isinstance(value, CancelParam): if isinstance(value, CancelParam):
count_o_path = value.origin_path.count('.') - value.current_path.count('.') count_o_path = value.origin_path.count(".") - value.current_path.count(
"."
)
path = path.rsplit(".", count_o_path)[0] path = path.rsplit(".", count_o_path)[0]
for subkey in path.split("."): for subkey in path.split("."):
c_kw = c_kw.setdefault(subkey, {}) c_kw = c_kw.setdefault(subkey, {})

View file

@ -87,7 +87,7 @@ class TiramisuReflector:
continue continue
self.text["header"].append(f"load_functions('{funcs_path}')") self.text["header"].append(f"load_functions('{funcs_path}')")
if self.objectspace.export_with_import: if self.objectspace.export_with_import:
if objectspace.main_namespace: if self.objectspace.has_namespace:
self.text["header"].extend( self.text["header"].extend(
[ [
"try:", "try:",
@ -372,6 +372,11 @@ class Common:
) )
params = [f"{option_name}"] params = [f"{option_name}"]
if identifier is not None: if identifier is not None:
if not self.objectspace.paths.is_dynamic(variable.path):
msg = _("internal error, {0} is not a dynamic variable").format(
variable.path
)
raise DictConsistencyError(msg, 49, self.elt.xmlfiles)
param_type = "ParamDynOption" param_type = "ParamDynOption"
identifiers = [] identifiers = []
for ident in identifier: for ident in identifier:

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024 Copyright (C) 2022-2024
distribued with GPL-2 or later license distribued with GPL-2 or later license
@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from typing import List from typing import List
from re import findall from re import findall
@ -76,8 +77,7 @@ class UserDatas:
self._not_found_is_dynamic(self.config, path, cache, added) self._not_found_is_dynamic(self.config, path, cache, added)
def _not_found_is_dynamic(self, config, path, cache, added): def _not_found_is_dynamic(self, config, path, cache, added):
"""if path is not found, check if parent is a dynamic family """if path is not found, check if parent is a dynamic family"""
"""
current_path = "" current_path = ""
identifiers = [] identifiers = []
# get parent # get parent
@ -102,9 +102,7 @@ class UserDatas:
if not tconfig.isdynamic(only_self=True): if not tconfig.isdynamic(only_self=True):
# it's not a dynamic variable # it's not a dynamic variable
continue continue
identifier = self._get_identifier( identifier = self._get_identifier(tconfig.name(), name)
tconfig.name(), name
)
if identifier is None: if identifier is None:
# it's a dynamic variable but doesn't match the current name # it's a dynamic variable but doesn't match the current name
continue continue
@ -116,11 +114,13 @@ class UserDatas:
# it's the good dynamic variable but it's not linked to a variable # it's the good dynamic variable but it's not linked to a variable
# so cannot change the variable # so cannot change the variable
continue continue
option_type = self.config.option( option_type = self.config.option(dynamic_variable).information.get(
dynamic_variable "type"
).information.get("type") )
dyn_options_values = self.config.option(dynamic_variable).get().impl_getdefault() dyn_options_values = (
if "{{ identifier }}" in dynamic_variable: self.config.option(dynamic_variable).get().impl_getdefault()
)
if "{{ identifier }}" in dynamic_variable:
for s in identifiers: for s in identifiers:
dynamic_variable = dynamic_variable.replace( dynamic_variable = dynamic_variable.replace(
"{{ identifier }}", str(s), 1 "{{ identifier }}", str(s), 1
@ -132,18 +132,11 @@ class UserDatas:
continue continue
config = tconfig config = tconfig
identifiers.append(identifier) identifiers.append(identifier)
typ = CONVERT_OPTION.get(option_type, {}).get( typ = CONVERT_OPTION.get(option_type, {}).get("func")
"func"
)
if typ: if typ:
identifier = typ(identifier) identifier = typ(identifier)
if ( if identifier not in self.values[dynamic_variable]["values"]:
identifier self.values[dynamic_variable]["values"].append(identifier)
not in self.values[dynamic_variable]["values"]
):
self.values[dynamic_variable]["values"].append(
identifier
)
cache[current_path] = config, identifier cache[current_path] = config, identifier
break break
@ -211,6 +204,11 @@ class UserDatas:
for path, data in self.values.items(): for path, data in self.values.items():
try: try:
option = self.config.option(path) option = self.config.option(path)
if option.isoptiondescription():
self.errors.append(
f'the option "{option.path()}" is an option description'
)
continue
value = data["values"] value = data["values"]
if option.isfollower(): if option.isfollower():
for index, val in enumerate(value): for index, val in enumerate(value):
@ -231,7 +229,7 @@ def convert_value(option, value):
if value == "": if value == "":
return None return None
option_type = option.information.get("type") option_type = option.information.get("type")
if option_type == 'choice': if option_type == "choice":
choices = option.value.list() choices = option.value.list()
if value not in choices and isinstance(value, str): if value not in choices and isinstance(value, str):
# FIXME add other tests (boolean, float, ...) # FIXME add other tests (boolean, float, ...)

View file

@ -11,6 +11,6 @@ ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_2 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -7,5 +7,5 @@ ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_1 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -11,6 +11,6 @@ ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_2 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True)}))], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2))))], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -7,5 +7,5 @@ ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_1 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True)}))], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1))))], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -18,12 +18,16 @@
"owner": "default", "owner": "default",
"value": null "value": null
}, },
"rougail.family2.var3": {
"owner": "default",
"value": "string4"
},
"rougail.family2.subfamily.variable": { "rougail.family2.subfamily.variable": {
"owner": "default", "owner": "default",
"value": [ "value": [
null, null,
null, null,
null "string4"
] ]
} }
} }

View file

@ -6,9 +6,10 @@
null null
], ],
"rougail.family2.var2": null, "rougail.family2.var2": null,
"rougail.family2.var3": "string4",
"rougail.family2.subfamily.variable": [ "rougail.family2.subfamily.variable": [
null, null,
null, null,
null "string4"
] ]
} }

View file

@ -18,12 +18,16 @@
"owner": "default", "owner": "default",
"value": null "value": null
}, },
"rougail.family2.var3": {
"owner": "default",
"value": "string4"
},
"rougail.family2.subfamily.variable": { "rougail.family2.subfamily.variable": {
"owner": "default", "owner": "default",
"value": [ "value": [
null, null,
null, null,
null "string4"
] ]
} }
} }

View file

@ -7,12 +7,13 @@ ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="var1", doc="first variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'}) option_1 = StrOption(name="var1", doc="first variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
option_3 = StrOption(name="var2", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'}) option_3 = StrOption(name="var2", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string', 'test': ('string6',)})
option_5 = StrOption(name="variable", doc="third variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(False)})), Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(False)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(False)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_5 = StrOption(name="variable", doc="third variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)))), Calculation(func['calc_value'], Params((ParamOption(option_3))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_4 = OptionDescription(name="subfamily", doc="a sub family", children=[option_5], properties=frozenset({"standard"})) optiondescription_4 = OptionDescription(name="subfamily", doc="a sub family", children=[option_5], properties=frozenset({"standard"}))
optiondescription_2 = OptionDescription(name="family", doc="a family", children=[option_3, optiondescription_4], properties=frozenset({"basic"})) optiondescription_2 = OptionDescription(name="family", doc="a family", children=[option_3, optiondescription_4], properties=frozenset({"basic"}))
option_7 = StrOption(name="var2", doc="var2", default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_7 = StrOption(name="var2", doc="a variable2", default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_9 = StrOption(name="variable", doc="fourth variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(False)})), Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(False)})), Calculation(func['calc_value'], Params((ParamOption(option_7)), kwargs={'__internal_multi': ParamValue(False)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(False)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_8 = StrOption(name="var3", doc="var3", default="string4", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string', 'test': ('string5',)})
optiondescription_8 = OptionDescription(name="subfamily", doc="a sub family", children=[option_9], properties=frozenset({"standard"})) option_10 = StrOption(name="variable", doc="fourth variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)))), Calculation(func['calc_value'], Params((ParamOption(option_3)))), Calculation(func['calc_value'], Params((ParamOption(option_8))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_6 = OptionDescription(name="family2", doc="a family", children=[option_7, optiondescription_8], properties=frozenset({"standard"})) optiondescription_9 = OptionDescription(name="subfamily", doc="a sub family", children=[option_10], properties=frozenset({"standard"}))
optiondescription_6 = OptionDescription(name="family2", doc="a family", children=[option_7, option_8, optiondescription_9], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, optiondescription_2, optiondescription_6]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, optiondescription_2, optiondescription_6])

View file

@ -1,18 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="var1", doc="first variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
option_3 = StrOption(name="var2", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
option_5 = StrOption(name="variable", doc="third variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True)})), Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_4 = OptionDescription(name="subfamily", doc="a sub family", children=[option_5], properties=frozenset({"standard"}))
optiondescription_2 = OptionDescription(name="family", doc="a family", children=[option_3, optiondescription_4], properties=frozenset({"basic"}))
option_7 = StrOption(name="var2", doc="var2", default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_9 = StrOption(name="variable", doc="fourth variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True)})), Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)})), Calculation(func['calc_value'], Params((ParamOption(option_7)), kwargs={'__internal_multi': ParamValue(True)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_8 = OptionDescription(name="subfamily", doc="a sub family", children=[option_9], properties=frozenset({"standard"}))
optiondescription_6 = OptionDescription(name="family2", doc="a family", children=[option_7, optiondescription_8], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, optiondescription_2, optiondescription_6])

View file

@ -12,6 +12,6 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_3 = StrOption(name="var2", doc="a second variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_3 = StrOption(name="var2", doc="a second variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="var3", doc="a third variable", default="yes", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_4 = StrOption(name="var3", doc="a third variable", default="yes", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_2 = StrOption(name="var", doc="a first variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)})), Calculation(func['calc_value'], Params((ParamOption(option_4)), kwargs={'__internal_multi': ParamValue(True)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_2 = StrOption(name="var", doc="a first variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_3)))), Calculation(func['calc_value'], Params((ParamOption(option_4))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"standard"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -8,5 +8,5 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="var2", doc="a second variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_2 = StrOption(name="var2", doc="a second variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="var3", doc="a third variable", default="yes", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_3 = StrOption(name="var3", doc="a third variable", default="yes", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_1 = StrOption(name="var", doc="a first variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True)})), Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)}))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) option_1 = StrOption(name="var", doc="a first variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2)))), Calculation(func['calc_value'], Params((ParamOption(option_3))))], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3])

View file

@ -12,7 +12,7 @@
"default" "default"
], ],
"value": [ "value": [
"ne peut acc\u00e9der \u00e0 l'option \"a follower\" \u00e0 cause de la propri\u00e9t\u00e9 \"disabled\" (the value of \"leader\" is \"a\")", "cannot access to option \"a follower\" because has property \"disabled\" (the value of \"leader\" is \"a\")",
"b" "b"
] ]
} }

View file

@ -12,7 +12,7 @@
"default" "default"
], ],
"value": [ "value": [
"ne peut acc\u00e9der \u00e0 l'option \"a follower\" \u00e0 cause de la propri\u00e9t\u00e9 \"disabled\" (the value of \"leader\" is \"a\")", "cannot access to option \"a follower\" because has property \"disabled\" (the value of \"leader\" is \"a\")",
"b" "b"
] ]
} }

View file

@ -45,7 +45,7 @@ excludes = set([
]) ])
test_ok -= excludes test_ok -= excludes
test_raise -= excludes test_raise -= excludes
#test_ok = ['00_9extra'] # test_ok = ['00_9default_calculation_multi_optional']
#test_ok = [] #test_ok = []
#test_raise = ['88valid_enum_invalid_default'] #test_raise = ['88valid_enum_invalid_default']
#test_raise = [] #test_raise = []
@ -124,7 +124,7 @@ def save(test_dir, eolobj, multi=False, namespace=False, error=False):
tiramisu_dir = dirname(tiramisu_file) tiramisu_dir = dirname(tiramisu_file)
if not error: if not error:
if not isdir(tiramisu_dir): if not isdir(tiramisu_dir):
raise Exception(f'creates {tiramisu_dir}') raise Exception(f'please creates {tiramisu_dir}')
if not isfile(tiramisu_file) or debug: if not isfile(tiramisu_file) or debug:
copyfile(tiramisu_tmp, tiramisu_file) copyfile(tiramisu_tmp, tiramisu_file)
with open(tiramisu_tmp, 'r') as fh: with open(tiramisu_tmp, 'r') as fh:
@ -161,28 +161,32 @@ def test_dictionary_namespace(test_dir):
test_dir_ = join(dico_dirs, test_dir) test_dir_ = join(dico_dirs, test_dir)
rougailconfig = RougailConfig.copy() rougailconfig = RougailConfig.copy()
rougailconfig['main_namespace'] = 'Rougail' rougailconfig['main_namespace'] = 'Rougail'
if (dico_dirs / test_dir / 'force_no_namespace').is_file():
return
eolobj = load_rougail_object(test_dir_, rougailconfig, namespace=True) eolobj = load_rougail_object(test_dir_, rougailconfig, namespace=True)
if not eolobj: if not eolobj:
return return
save(test_dir_, eolobj, namespace=True) save(test_dir_, eolobj, namespace=True)
assert getcwd() == ORI_DIR assert getcwd() == ORI_DIR
#
#
def test_dictionary_multi(test_dir): #def test_dictionary_multi(test_dir):
if not test_multi: # if not test_multi:
print('MULTI!') # print('MULTI!')
return # return
assert getcwd() == ORI_DIR # assert getcwd() == ORI_DIR
test_dir_ = join(dico_dirs, test_dir) # test_dir_ = join(dico_dirs, test_dir)
rougailconfig = RougailConfig.copy() # rougailconfig = RougailConfig.copy()
rougailconfig['main_namespace'] = 'Rougail' # rougailconfig['main_namespace'] = 'Rougail'
eolobj = load_rougail_object(test_dir_, rougailconfig, multi=True) # if (dico_dirs / test_dir / 'force_no_namespace').is_file():
if not eolobj: # return
return # eolobj = load_rougail_object(test_dir_, rougailconfig, multi=True)
eolobj.add_path_prefix('1') # if not eolobj:
eolobj.add_path_prefix('2') # return
save(test_dir_, eolobj, multi=True) # eolobj.add_path_prefix('1')
assert getcwd() == ORI_DIR # eolobj.add_path_prefix('2')
# save(test_dir_, eolobj, multi=True)
# assert getcwd() == ORI_DIR
def test_error_dictionary(test_dir_error): def test_error_dictionary(test_dir_error):

View file

@ -85,6 +85,8 @@ def launch_flattener(test_dir,
mandatory_file = Path(makedict_dir) / 'mandatory.json' mandatory_file = Path(makedict_dir) / 'mandatory.json'
modulepath = join(test_dir, 'tiramisu', filename + '.py') modulepath = join(test_dir, 'tiramisu', filename + '.py')
if not isfile(modulepath):
return
with open(modulepath) as fh: with open(modulepath) as fh:
optiondescription = {} optiondescription = {}
exec(fh.read(), {'CustomOption': CustomOption}, optiondescription) # pylint: disable=W0122 exec(fh.read(), {'CustomOption': CustomOption}, optiondescription) # pylint: disable=W0122
@ -113,17 +115,20 @@ def launch_flattener(test_dir,
for root in ['1', '2']: for root in ['1', '2']:
config.option(f'{root}.{key}').information.set('test_information', value) config.option(f'{root}.{key}').information.set('test_information', value)
# #
if not isdir(makedict_dir):
mkdir(makedict_dir)
config_dict = dict(option_value(config.value.get())) config_dict = dict(option_value(config.value.get()))
if filename == 'base': if not isfile(Path(test_dir) / 'tiramisu' / 'base.py'):
if not isdir(makedict_dir): tconfig_dict = {f'rougail.{path}': value for path, value in config_dict.items()}
mkdir(makedict_dir)
if not isfile(makedict_file) or debug:
with open(makedict_file, 'w') as fh:
dump(config_dict, fh, indent=4)
fh.write('\n')
elif filename == 'no_namespace':
config_dict = {f'rougail.{path}': value for path, value in config_dict.items()}
else: else:
tconfig_dict = config_dict
if not isfile(makedict_file) or debug:
with open(makedict_file, 'w') as fh:
dump(tconfig_dict, fh, indent=4)
fh.write('\n')
if filename == 'no_namespace':
config_dict = {f'rougail.{path}': value for path, value in config_dict.items()}
elif filename != 'base':
config_dict_prefix = {'1': {}, '2': {}} config_dict_prefix = {'1': {}, '2': {}}
for key, value in config_dict.items(): for key, value in config_dict.items():
prefix, path = key.split('.', 1) prefix, path = key.split('.', 1)
@ -142,9 +147,10 @@ def launch_flattener(test_dir,
if not isfile(makedict_file): if not isfile(makedict_file):
raise Exception('dict is not empty') raise Exception('dict is not empty')
with open(makedict_file, 'r') as fh: with open(makedict_file, 'r') as fh:
assert load(fh) == loads(dumps(config_dict)), f"error in file {makedict_file}" loaded_config_dict = load(fh)
assert loaded_config_dict == loads(dumps(config_dict)), f"error in file {makedict_file}"
# #
value_owner(makedict_before, config, filename) value_owner(test_dir, makedict_before, config, filename)
# deploy # deploy
ro = config.property.default('read_only', 'append') ro = config.property.default('read_only', 'append')
ro = frozenset(list(ro) + ['force_store_value']) ro = frozenset(list(ro) + ['force_store_value'])
@ -154,12 +160,12 @@ def launch_flattener(test_dir,
config.property.setdefault(rw, 'read_write', 'append') config.property.setdefault(rw, 'read_write', 'append')
config.property.add('force_store_value') config.property.add('force_store_value')
# #
value_owner(makedict_after, config, filename) value_owner(test_dir, makedict_after, config, filename)
# #
mandatory(mandatory_file, config.value.mandatory(), filename) mandatory(test_dir, mandatory_file, config.value.mandatory(), filename)
def value_owner(makedict_value_owner, config, filename): def value_owner(test_dir, makedict_value_owner, config, filename):
ret = {} ret = {}
for key, value in option_value(config.value.get(), True): for key, value in option_value(config.value.get(), True):
path = key.path() path = key.path()
@ -182,14 +188,17 @@ def value_owner(makedict_value_owner, config, filename):
ret[path] = {'owner': owner, ret[path] = {'owner': owner,
'value': value, 'value': value,
} }
if filename == 'base': if not isfile(Path(test_dir) / 'tiramisu' / 'base.py'):
if not isfile(makedict_value_owner) or debug: tret = {f'rougail.{path}': value for path, value in ret.items()}
with open(makedict_value_owner, 'w') as fh:
dump(ret, fh, indent=4)
fh.write('\n')
elif filename == 'no_namespace':
ret = {f'rougail.{path}': value for path, value in ret.items()}
else: else:
tret = ret
if not isfile(makedict_value_owner) or debug:
with open(makedict_value_owner, 'w') as fh:
dump(tret, fh, indent=4)
fh.write('\n')
if filename == 'no_namespace':
ret = {f'rougail.{path}': value for path, value in ret.items()}
elif filename != 'base':
ret_prefix = {'1': {}, '2': {}} ret_prefix = {'1': {}, '2': {}}
for key, value in ret.items(): for key, value in ret.items():
prefix, path = key.split('.', 1) prefix, path = key.split('.', 1)
@ -200,14 +209,15 @@ def value_owner(makedict_value_owner, config, filename):
assert load(fh) == loads(dumps(ret)), f"error in file {makedict_value_owner}" assert load(fh) == loads(dumps(ret)), f"error in file {makedict_value_owner}"
def mandatory(mandatory_file, mandatories, filename): def mandatory(test_dir, mandatory_file, mandatories, filename):
ret = [opt.path() for opt in mandatories] if filename == 'no_namespace':
ret = [f'rougail.{opt.path()}' for opt in mandatories]
else:
ret = [opt.path() for opt in mandatories]
if not mandatory_file.is_file(): if not mandatory_file.is_file():
with mandatory_file.open('w') as fh: with mandatory_file.open('w') as fh:
dump(ret, fh) dump(ret, fh)
if filename == 'no_namespace': if filename == 'multi':
ret = [f'rougail.{path}' for path in ret]
elif filename == 'multi':
ret_prefix = {'1': [], '2': []} ret_prefix = {'1': [], '2': []}
for key in ret: for key in ret:
prefix, path = key.split('.', 1) prefix, path = key.split('.', 1)
@ -223,12 +233,14 @@ def test_dictionary(test_dir):
print('FIXME') print('FIXME')
return return
test_dir = join(dico_dirs, test_dir) test_dir = join(dico_dirs, test_dir)
if not (Path(test_dir) / 'tiramisu' / 'base.py').is_file():
return
launch_flattener(test_dir, 'base') launch_flattener(test_dir, 'base')
def test_dictionary_no_namespace(test_dir): def test_dictionary_no_namespace(test_dir):
test_dir = join(dico_dirs, test_dir) test_dir = join(dico_dirs, test_dir)
if not isfile(Path(test_dir) / 'tiramisu' / 'no_namespace.py'): if not (Path(test_dir) / 'tiramisu' / 'no_namespace.py').is_file():
return return
launch_flattener(test_dir, 'no_namespace') launch_flattener(test_dir, 'no_namespace')
@ -238,6 +250,6 @@ def test_dictionary_multi(test_dir):
print('FIXME') print('FIXME')
return return
test_dir = join(dico_dirs, test_dir) test_dir = join(dico_dirs, test_dir)
if not isfile(Path(test_dir) / 'tiramisu' / 'multi.py'): if not (Path(test_dir) / 'tiramisu' / 'multi.py').is_file():
return return
launch_flattener(test_dir, 'multi') launch_flattener(test_dir, 'multi')