WIP: Expand the developer documentation #27

Draft
gremond wants to merge 77 commits from develop into developer_docs
11 changed files with 123 additions and 11 deletions
Showing only changes of commit c25a66f0cb - Show all commits

View file

@ -428,7 +428,7 @@ class ParserVariable:
# FIXME: only for format 1.0 # FIXME: only for format 1.0
self.family_types = hint["type"].__args__ # pylint: disable=W0201 self.family_types = hint["type"].__args__ # pylint: disable=W0201
self.family_attrs = frozenset( # pylint: disable=W0201 self.family_attrs = frozenset( # pylint: disable=W0201
set(hint) - {"name", "path", "xmlfiles"} | {"redefine"} set(hint) - {"name", "path", "xmlfiles"} | {"redefine", "exists"}
) )
self.family_calculations = self.search_calculation( # pylint: disable=W0201 self.family_calculations = self.search_calculation( # pylint: disable=W0201
hint hint
@ -590,6 +590,10 @@ class ParserVariable:
return return
family_obj = {} family_obj = {}
subfamily_obj = {} subfamily_obj = {}
if version != '1.0':
exists = obj.pop("exists", None)
else:
exists = None
force_to_attrs = list(self.list_attributes(obj)) force_to_attrs = list(self.list_attributes(obj))
for key, value in obj.items(): for key, value in obj.items():
if key in force_to_attrs: if key in force_to_attrs:
@ -601,9 +605,9 @@ class ParserVariable:
if path in self.paths: if path in self.paths:
# it's just for modify subfamily or subvariable, do not redefine # it's just for modify subfamily or subvariable, do not redefine
if family_obj: if family_obj:
if not obj.pop("redefine", False): if exists is None and not obj.pop("redefine", False):
raise DictConsistencyError( raise DictConsistencyError(
f'The family "{path}" already exists and it is not redefined', _('The family "{0}" already exists and it is not redefined').format(path),
32, 32,
[filename], [filename],
) )
@ -617,6 +621,7 @@ class ParserVariable:
version, version,
typ="family", typ="family",
) )
if exists in [None, True]:
self.paths.add( self.paths.add(
path, path,
self.paths[path].model_copy(update=obj), self.paths[path].model_copy(update=obj),
@ -630,7 +635,7 @@ class ParserVariable:
family_is_dynamic = True family_is_dynamic = True
parent_dynamic = path parent_dynamic = path
else: else:
if "redefine" in obj and obj["redefine"]: if exists is None and "redefine" in obj and obj["redefine"]:
raise Exception( raise Exception(
f'cannot redefine the inexisting family "{path}" in {filename}' f'cannot redefine the inexisting family "{path}" in {filename}'
) )

View file

@ -0,0 +1,10 @@
---
version: '1.1'
family1: # a family
variable1: # a variable
family2: # a second family
variable2: # a second variable

View file

@ -0,0 +1,16 @@
---
version: '1.1'
family1:
exists: true
redefine: true
description: new description
family2:
exists: false
description: new description
family3:
exists: true
redefine: true
description: new description

View file

@ -0,0 +1,10 @@
{
"rougail.family1.variable1": {
"owner": "default",
"value": null
},
"rougail.family2.variable2": {
"owner": "default",
"value": null
}
}

View file

@ -0,0 +1,4 @@
{
"rougail.family1.variable1": null,
"rougail.family2.variable2": null
}

View file

@ -0,0 +1,10 @@
{
"rougail.family1.variable1": {
"owner": "default",
"value": null
},
"rougail.family2.variable2": {
"owner": "default",
"value": null
}
}

View file

@ -0,0 +1 @@
["rougail.family1.variable1", "rougail.family2.variable2"]

View file

@ -0,0 +1,18 @@
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('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_3 = StrOption(name="variable1", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_2 = OptionDescription(name="family1", doc="new description", children=[option_3], properties=frozenset({"basic"}))
option_5 = StrOption(name="variable2", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_4 = OptionDescription(name="family2", doc="a second family", children=[option_5], properties=frozenset({"basic"}))
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, optiondescription_4], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,25 @@
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('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_4 = StrOption(name="variable1", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_3 = OptionDescription(name="family1", doc="new description", children=[option_4], properties=frozenset({"basic"}))
option_6 = StrOption(name="variable2", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_5 = OptionDescription(name="family2", doc="a second family", children=[option_6], properties=frozenset({"basic"}))
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_3, optiondescription_5], properties=frozenset({"basic"}))
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
option_10 = StrOption(name="variable1", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_9 = OptionDescription(name="family1", doc="new description", children=[option_10], properties=frozenset({"basic"}))
option_12 = StrOption(name="variable2", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_11 = OptionDescription(name="family2", doc="a second family", children=[option_12], properties=frozenset({"basic"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_9, optiondescription_11], properties=frozenset({"basic"}))
optiondescription_7 = OptionDescription(name="2", doc="2", children=[optiondescription_8], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_7])

View file

@ -0,0 +1,13 @@
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('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="variable1", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="family1", doc="new description", children=[option_2], properties=frozenset({"basic"}))
option_4 = StrOption(name="variable2", doc="a second variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_3 = OptionDescription(name="family2", doc="a second family", children=[option_4], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_3])