fix: dictionary => structure
This commit is contained in:
parent
e2d5a30c21
commit
bfc59e8084
17 changed files with 178 additions and 89 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
"""Annotate dictionaries
|
"""Annotate structural file
|
||||||
|
|
||||||
Created by:
|
Created by:
|
||||||
EOLE (http://eole.orion.education.fr)
|
EOLE (http://eole.orion.education.fr)
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ from ..convert.object_model import get_convert_option_types
|
||||||
|
|
||||||
|
|
||||||
RENAMED = {
|
RENAMED = {
|
||||||
"dictionaries_dir": "main_dictionaries",
|
"dictionaries_dir": "main_structural_directories",
|
||||||
|
"main_dictionaries": "main_structural_directories",
|
||||||
"variable_namespace": "main_namespace",
|
"variable_namespace": "main_namespace",
|
||||||
"functions_file": "functions_files",
|
"functions_file": "functions_files",
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +179,8 @@ class _RougailConfig:
|
||||||
yield f"{option.path()}: {option.value.get()}"
|
yield f"{option.path()}: {option.value.get()}"
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
self.generate_config()
|
if self.root is None:
|
||||||
|
self.generate_config()
|
||||||
self.config.property.read_write()
|
self.config.property.read_write()
|
||||||
try:
|
try:
|
||||||
values = "\n".join(self.parse(self.config))
|
values = "\n".join(self.parse(self.config))
|
||||||
|
|
@ -197,7 +199,7 @@ class FakeRougailConvert(RougailConvert):
|
||||||
super().__init__({})
|
super().__init__({})
|
||||||
|
|
||||||
def load_config(self) -> None:
|
def load_config(self) -> None:
|
||||||
self.sort_dictionaries_all = False
|
self.sort_structural_files_all = False
|
||||||
self.main_namespace = None
|
self.main_namespace = None
|
||||||
self.suffix = ""
|
self.suffix = ""
|
||||||
self.custom_types = {}
|
self.custom_types = {}
|
||||||
|
|
@ -220,7 +222,7 @@ def _rougail_config(
|
||||||
backward_compatibility: bool = True,
|
backward_compatibility: bool = True,
|
||||||
add_extra_options: bool = True,
|
add_extra_options: bool = True,
|
||||||
) -> "OptionDescription":
|
) -> "OptionDescription":
|
||||||
rougail_options = f"""default_dictionary_format_version:
|
rougail_options = f"""default_structural_format_version:
|
||||||
description: {_('Structure format version by default, if not specified in structure file')}
|
description: {_('Structure format version by default, if not specified in structure file')}
|
||||||
alternative_name: v
|
alternative_name: v
|
||||||
choices:
|
choices:
|
||||||
|
|
|
||||||
|
|
@ -160,8 +160,8 @@ class ParserVariable:
|
||||||
def load_config(self) -> None:
|
def load_config(self) -> None:
|
||||||
rougailconfig = self.rougailconfig
|
rougailconfig = self.rougailconfig
|
||||||
self.suffix = rougailconfig["suffix"]
|
self.suffix = rougailconfig["suffix"]
|
||||||
self.default_dictionary_format_version = rougailconfig[
|
self.default_structural_format_version= rougailconfig[
|
||||||
"default_dictionary_format_version"
|
"default_structural_format_version"
|
||||||
]
|
]
|
||||||
self.custom_types = rougailconfig["custom_types"]
|
self.custom_types = rougailconfig["custom_types"]
|
||||||
self.functions_files = rougailconfig["functions_files"]
|
self.functions_files = rougailconfig["functions_files"]
|
||||||
|
|
@ -1105,7 +1105,7 @@ class RougailConvert(ParserVariable):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# the `version` attribute is not mandatory
|
# the `version` attribute is not mandatory
|
||||||
default_version = self.default_dictionary_format_version
|
default_version = self.default_structural_format_version
|
||||||
if default_version is not None:
|
if default_version is not None:
|
||||||
version = default_version
|
version = default_version
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ class Walker:
|
||||||
self.convert = convert
|
self.convert = convert
|
||||||
self.yaml = YAML()
|
self.yaml = YAML()
|
||||||
rougailconfig = self.convert.rougailconfig
|
rougailconfig = self.convert.rougailconfig
|
||||||
self.sort_dictionaries_all = rougailconfig["sort_dictionaries_all"]
|
self.sort_structural_files_all = rougailconfig["sort_structural_files_all"]
|
||||||
if rougailconfig["main_namespace"]:
|
if rougailconfig["main_namespace"]:
|
||||||
self.convert.paths = Paths(rougailconfig["main_namespace"])
|
self.convert.paths = Paths(rougailconfig["main_namespace"])
|
||||||
self.load_with_extra(
|
self.load_with_extra(
|
||||||
rougailconfig["extra_dictionaries"],
|
rougailconfig["extra_namespaces"],
|
||||||
rougailconfig["main_namespace"],
|
rougailconfig["main_namespace"],
|
||||||
rougailconfig["main_dictionaries"],
|
rougailconfig["main_structural_directories"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.convert.namespace = None
|
self.convert.namespace = None
|
||||||
|
|
@ -51,7 +51,7 @@ class Walker:
|
||||||
if namespace_path in self.convert.parents:
|
if namespace_path in self.convert.parents:
|
||||||
raise Exception("pfff")
|
raise Exception("pfff")
|
||||||
for filename in self.get_sorted_filename(
|
for filename in self.get_sorted_filename(
|
||||||
rougailconfig["main_dictionaries"]
|
rougailconfig["main_structural_directories"]
|
||||||
):
|
):
|
||||||
self.parse_variable_file(
|
self.parse_variable_file(
|
||||||
filename,
|
filename,
|
||||||
|
|
@ -101,21 +101,21 @@ class Walker:
|
||||||
"""Sort filename"""
|
"""Sort filename"""
|
||||||
if not isinstance(directories, list):
|
if not isinstance(directories, list):
|
||||||
directories = [directories]
|
directories = [directories]
|
||||||
if self.sort_dictionaries_all:
|
if self.sort_structural_files_all:
|
||||||
filenames = {}
|
filenames = {}
|
||||||
for directory_name in directories:
|
for directory_name in directories:
|
||||||
directory = Path(directory_name)
|
directory = Path(directory_name)
|
||||||
if not self.sort_dictionaries_all:
|
if not self.sort_structural_files_all:
|
||||||
filenames = {}
|
filenames = {}
|
||||||
if directory.is_file():
|
if directory.is_file():
|
||||||
self.get_filename(directory, filenames)
|
self.get_filename(directory, filenames)
|
||||||
else:
|
else:
|
||||||
for file_path in directory.iterdir():
|
for file_path in directory.iterdir():
|
||||||
self.get_filename(file_path, filenames)
|
self.get_filename(file_path, filenames)
|
||||||
if not self.sort_dictionaries_all:
|
if not self.sort_structural_files_all:
|
||||||
for filename in sorted(filenames):
|
for filename in sorted(filenames):
|
||||||
yield filenames[filename]
|
yield filenames[filename]
|
||||||
if self.sort_dictionaries_all:
|
if self.sort_structural_files_all:
|
||||||
for filename in sorted(filenames):
|
for filename in sorted(filenames):
|
||||||
yield filenames[filename]
|
yield filenames[filename]
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ class Walker:
|
||||||
return
|
return
|
||||||
if file_path.name in filenames:
|
if file_path.name in filenames:
|
||||||
raise DictConsistencyError(
|
raise DictConsistencyError(
|
||||||
_("duplicate dictionary file name {0}").format(file_path.name),
|
_("duplicate structural file name {0}").format(file_path.name),
|
||||||
78,
|
78,
|
||||||
[filenames[file_path.name], str(file_path)],
|
[filenames[file_path.name], str(file_path)],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ def get_rougail_config(
|
||||||
else:
|
else:
|
||||||
main_namespace_default = "null"
|
main_namespace_default = "null"
|
||||||
options = f"""
|
options = f"""
|
||||||
main_dictionaries:
|
main_structural_directories:
|
||||||
description: {_("Directories where dictionary files are placed")}
|
description: {_("Directories where structural files are placed")}
|
||||||
type: unix_filename
|
type: unix_filename
|
||||||
alternative_name: m
|
alternative_name: m
|
||||||
params:
|
params:
|
||||||
|
|
@ -45,8 +45,8 @@ main_dictionaries:
|
||||||
cli.versions is specified
|
cli.versions is specified
|
||||||
{{% endif %}}
|
{{% endif %}}
|
||||||
|
|
||||||
sort_dictionaries_all:
|
sort_structural_files_all:
|
||||||
description: {_("Sort dictionaries from differents directories")}
|
description: {_("Sort structural from differents directories")}
|
||||||
default: false
|
default: false
|
||||||
disabled:
|
disabled:
|
||||||
jinja: >-
|
jinja: >-
|
||||||
|
|
@ -65,7 +65,7 @@ main_namespace:
|
||||||
directory is not in step.structural
|
directory is not in step.structural
|
||||||
{{% endif %}}
|
{{% endif %}}
|
||||||
|
|
||||||
extra_dictionaries:
|
extra_namespaces:
|
||||||
description: {_("Extra namespaces")}
|
description: {_("Extra namespaces")}
|
||||||
type: leadership
|
type: leadership
|
||||||
disabled:
|
disabled:
|
||||||
|
|
@ -81,7 +81,7 @@ extra_dictionaries:
|
||||||
mandatory: false
|
mandatory: false
|
||||||
|
|
||||||
directories:
|
directories:
|
||||||
description: {_("Directories where extra dictionary files are placed")}
|
description: {_("Directories where extra structural files are placed")}
|
||||||
alternative_name: xd
|
alternative_name: xd
|
||||||
type: unix_filename
|
type: unix_filename
|
||||||
params:
|
params:
|
||||||
|
|
|
||||||
|
|
@ -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('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['disabled_rougail.leadership.follower'] = "{% if not index %}\nthe first follower\n{% endif %}\n"
|
||||||
|
option_3 = StrOption(name="leader", doc="aleader", multi=True, default=["a", "b"], properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_4 = StrOption(name="follower", doc="a follower", multi=True, default_multi="value", properties=frozenset({"mandatory", "standard", Calculation(func['jinja_to_property'], Params((ParamValue("disabled")), kwargs={'__internal_jinja': ParamValue("disabled_rougail.leadership.follower"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml']), '__internal_attribute': ParamValue("disabled"), '__internal_variable': ParamValue("rougail.leadership.follower"), 'index': ParamIndex(), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
optiondescription_2 = Leadership(name="leadership", doc="a leadership", children=[option_3, option_4], properties=frozenset({"standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml']})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -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('../rougail-tests/funcs/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['disabled_leadership.follower'] = "{% if not index %}\nthe first follower\n{% endif %}\n"
|
||||||
|
option_2 = StrOption(name="leader", doc="aleader", multi=True, default=["a", "b"], properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
option_3 = StrOption(name="follower", doc="a follower", multi=True, default_multi="value", properties=frozenset({"mandatory", "standard", Calculation(func['jinja_to_property'], Params((ParamValue("disabled")), kwargs={'__internal_jinja': ParamValue("disabled_leadership.follower"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml']), '__internal_attribute': ParamValue("disabled"), '__internal_variable': ParamValue("leadership.follower"), 'index': ParamIndex(), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['jinja_to_property_help'])}), informations={'ymlfiles': ['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml'], 'type': 'string'})
|
||||||
|
optiondescription_1 = Leadership(name="leadership", doc="a leadership", children=[option_2, option_3], properties=frozenset({"standard"}), informations={'ymlfiles': ['../rougail-tests/structures/44_4disabled_calcultion_follower_index/rougail/00-base.yml']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -1,19 +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')
|
|
||||||
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="address", doc="{{ identifier }} address", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/60_8family_dynamic_same_name_1/rougail/00-base.yml'], 'type': 'string'})
|
|
||||||
optiondescription_3 = OptionDescription(name="https_proxy", doc="{{ identifier }} Proxy", children=[option_4], properties=frozenset({"basic"}), informations={'ymlfiles': ['../rougail-tests/structures/60_8family_dynamic_same_name_1/rougail/00-base.yml']})
|
|
||||||
option_6 = StrOption(name="address", doc="{{ identifier }} address", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/60_8family_dynamic_same_name_1/rougail/00-base.yml'], 'type': 'string'})
|
|
||||||
optiondescription_5 = ConvertDynOptionDescription(name="{{ identifier }}_proxy", doc="{{ identifier }} Proxy", identifiers=["HTTPS", "SOCKS"], children=[option_6], properties=frozenset({"basic"}), informations={'ymlfiles': ['../rougail-tests/structures/60_8family_dynamic_same_name_1/rougail/00-base.yml']})
|
|
||||||
optiondescription_2 = OptionDescription(name="manual", doc="manual", children=[optiondescription_3, optiondescription_5], properties=frozenset({"basic"}), informations={'ymlfiles': ['../rougail-tests/structures/60_8family_dynamic_same_name_1/rougail/00-base.yml']})
|
|
||||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2], properties=frozenset({"basic"}), informations={'ymlfiles': ['']})
|
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
|
||||||
18
tests/duplicates/0/00-rougail.yml
Normal file
18
tests/duplicates/0/00-rougail.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
"od":
|
||||||
|
|
||||||
|
"od_{{ identifier }}":
|
||||||
|
description: "{{ identifier }}"
|
||||||
|
dynamic:
|
||||||
|
- val1
|
||||||
|
|
||||||
|
var:
|
||||||
|
|
||||||
|
"od_{{ identifier }}":
|
||||||
|
description: "{{ identifier }}"
|
||||||
|
dynamic:
|
||||||
|
- val2
|
||||||
|
|
||||||
|
var:
|
||||||
16
tests/duplicates/1/00-base.yml
Normal file
16
tests/duplicates/1/00-base.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
"od":
|
||||||
|
|
||||||
|
"od_val":
|
||||||
|
description: "val"
|
||||||
|
|
||||||
|
var:
|
||||||
|
|
||||||
|
"od_{{ identifier }}":
|
||||||
|
description: "{{ identifier }}"
|
||||||
|
dynamic:
|
||||||
|
- val
|
||||||
|
|
||||||
|
var:
|
||||||
16
tests/duplicates/2/00-base.yml
Normal file
16
tests/duplicates/2/00-base.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
"od":
|
||||||
|
|
||||||
|
"od_{{ identifier }}":
|
||||||
|
description: "{{ identifier }}"
|
||||||
|
dynamic:
|
||||||
|
- val
|
||||||
|
|
||||||
|
var:
|
||||||
|
|
||||||
|
"od_val":
|
||||||
|
description: "val"
|
||||||
|
|
||||||
|
var:
|
||||||
14
tests/duplicates/3/00-base.yml
Normal file
14
tests/duplicates/3/00-base.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
"od":
|
||||||
|
|
||||||
|
od_val:
|
||||||
|
description: "val"
|
||||||
|
|
||||||
|
"od_{{ identifier }}":
|
||||||
|
description: "{{ identifier }}"
|
||||||
|
dynamic:
|
||||||
|
- val
|
||||||
|
|
||||||
|
var:
|
||||||
18
tests/duplicates/5/00-base.yml
Normal file
18
tests/duplicates/5/00-base.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
"od":
|
||||||
|
|
||||||
|
"od_{{ identifier }}":
|
||||||
|
description: "val"
|
||||||
|
dynamic:
|
||||||
|
- val
|
||||||
|
|
||||||
|
var:
|
||||||
|
|
||||||
|
"od{{ identifier }}":
|
||||||
|
description: "{{ identifier }}"
|
||||||
|
dynamic:
|
||||||
|
- _val
|
||||||
|
|
||||||
|
var:
|
||||||
|
|
@ -97,8 +97,8 @@ def load_rougail_object(test_dir, rougailconfig, multi=False, namespace=False):
|
||||||
subfolder = join(test_dir, 'rougail2')
|
subfolder = join(test_dir, 'rougail2')
|
||||||
if isdir(subfolder):
|
if isdir(subfolder):
|
||||||
dirs.append(subfolder)
|
dirs.append(subfolder)
|
||||||
rougailconfig['dictionaries_dir'] = dirs
|
rougailconfig['main_structural_directories'] = dirs
|
||||||
extra_dictionaries = {}
|
extra_namespaces = {}
|
||||||
extras = listdir(join(test_dir))
|
extras = listdir(join(test_dir))
|
||||||
extras.sort()
|
extras.sort()
|
||||||
for extra in extras:
|
for extra in extras:
|
||||||
|
|
@ -106,11 +106,11 @@ def load_rougail_object(test_dir, rougailconfig, multi=False, namespace=False):
|
||||||
continue
|
continue
|
||||||
subfolder = join(test_dir, extra)
|
subfolder = join(test_dir, extra)
|
||||||
if isdir(subfolder):
|
if isdir(subfolder):
|
||||||
extra_dictionaries[extra] = [subfolder]
|
extra_namespaces[extra] = [subfolder]
|
||||||
if extra_dictionaries:
|
if extra_namespaces:
|
||||||
if namespace is False and not multi:
|
if namespace is False and not multi:
|
||||||
return None
|
return None
|
||||||
rougailconfig['extra_dictionaries'] = extra_dictionaries
|
rougailconfig['extra_namespaces'] = extra_namespaces
|
||||||
rougailconfig['tiramisu_cache'] = get_tiramisu_filename(test_dir, 'tmp', multi, namespace)
|
rougailconfig['tiramisu_cache'] = get_tiramisu_filename(test_dir, 'tmp', multi, namespace)
|
||||||
rougailconfig['custom_types']['custom'] = CustomOption
|
rougailconfig['custom_types']['custom'] = CustomOption
|
||||||
return Rougail(rougailconfig)
|
return Rougail(rougailconfig)
|
||||||
|
|
@ -139,7 +139,7 @@ def save(test_dir, eolobj, multi=False, namespace=False, error=False):
|
||||||
rmtree(tiramisu_tmp_dir)
|
rmtree(tiramisu_tmp_dir)
|
||||||
|
|
||||||
|
|
||||||
def test_dictionary(test_dir):
|
def test_structural_file(test_dir):
|
||||||
if not test_no_namespace:
|
if not test_no_namespace:
|
||||||
print('NAMESPACE!')
|
print('NAMESPACE!')
|
||||||
return
|
return
|
||||||
|
|
@ -149,10 +149,10 @@ def test_dictionary(test_dir):
|
||||||
rougailconfig['main_namespace'] = None
|
rougailconfig['main_namespace'] = None
|
||||||
if (dico_dirs / test_dir / 'force_namespace').is_file():
|
if (dico_dirs / test_dir / 'force_namespace').is_file():
|
||||||
return
|
return
|
||||||
if (dico_dirs / test_dir / 'default_dictionary_format_version').is_file():
|
if (dico_dirs / test_dir / 'default_structural_format_version').is_file():
|
||||||
rougailconfig['default_dictionary_format_version'] = "1.1"
|
rougailconfig['default_structural_format_version'] = "1.1"
|
||||||
else:
|
else:
|
||||||
rougailconfig['default_dictionary_format_version'] = None
|
rougailconfig['default_structural_format_version'] = None
|
||||||
eolobj = load_rougail_object(str(dico_dirs / test_dir), rougailconfig)
|
eolobj = load_rougail_object(str(dico_dirs / test_dir), rougailconfig)
|
||||||
if not eolobj:
|
if not eolobj:
|
||||||
return
|
return
|
||||||
|
|
@ -160,7 +160,7 @@ def test_dictionary(test_dir):
|
||||||
assert getcwd() == ORI_DIR
|
assert getcwd() == ORI_DIR
|
||||||
|
|
||||||
|
|
||||||
def test_dictionary_namespace(test_dir):
|
def test_structural_file_namespace(test_dir):
|
||||||
if not test_base:
|
if not test_base:
|
||||||
print('BASE!')
|
print('BASE!')
|
||||||
return
|
return
|
||||||
|
|
@ -170,10 +170,10 @@ def test_dictionary_namespace(test_dir):
|
||||||
rougailconfig['main_namespace'] = 'Rougail'
|
rougailconfig['main_namespace'] = 'Rougail'
|
||||||
if (dico_dirs / test_dir / 'force_no_namespace').is_file():
|
if (dico_dirs / test_dir / 'force_no_namespace').is_file():
|
||||||
return
|
return
|
||||||
if (dico_dirs / test_dir / 'default_dictionary_format_version').is_file():
|
if (dico_dirs / test_dir / 'default_structural_format_version').is_file():
|
||||||
rougailconfig['default_dictionary_format_version'] = "1.1"
|
rougailconfig['default_structural_format_version'] = "1.1"
|
||||||
else:
|
else:
|
||||||
rougailconfig['default_dictionary_format_version'] = None
|
rougailconfig['default_structural_format_version'] = None
|
||||||
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
|
||||||
|
|
@ -181,7 +181,7 @@ def test_dictionary_namespace(test_dir):
|
||||||
assert getcwd() == ORI_DIR
|
assert getcwd() == ORI_DIR
|
||||||
|
|
||||||
|
|
||||||
def test_error_dictionary_namespace(test_dir_error):
|
def test_error_structural_file_namespace(test_dir_error):
|
||||||
assert getcwd() == ORI_DIR
|
assert getcwd() == ORI_DIR
|
||||||
test_dir_ = join(errors_dirs, test_dir_error)
|
test_dir_ = join(errors_dirs, test_dir_error)
|
||||||
errno = []
|
errno = []
|
||||||
|
|
@ -204,7 +204,7 @@ def test_error_dictionary_namespace(test_dir_error):
|
||||||
assert getcwd() == ORI_DIR
|
assert getcwd() == ORI_DIR
|
||||||
|
|
||||||
|
|
||||||
def test_error_dictionary(test_dir_error):
|
def test_error_structural_file(test_dir_error):
|
||||||
assert getcwd() == ORI_DIR
|
assert getcwd() == ORI_DIR
|
||||||
test_dir_ = join(errors_dirs, test_dir_error)
|
test_dir_ = join(errors_dirs, test_dir_error)
|
||||||
if isfile(join(test_dir_, 'force_namespace')):
|
if isfile(join(test_dir_, 'force_namespace')):
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ def mandatory(test_dir, mandatory_file, mandatories, filename):
|
||||||
assert ret == load(fh), f"error in file {mandatory_file}"
|
assert ret == load(fh), f"error in file {mandatory_file}"
|
||||||
|
|
||||||
|
|
||||||
def test_dictionary(test_dir):
|
def test_structural_file(test_dir):
|
||||||
if no_test_base:
|
if no_test_base:
|
||||||
print('FIXME')
|
print('FIXME')
|
||||||
return
|
return
|
||||||
|
|
@ -281,14 +281,14 @@ def test_dictionary(test_dir):
|
||||||
launch_flattener(test_dir, 'base')
|
launch_flattener(test_dir, 'base')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionary_no_namespace(test_dir):
|
def test_structural_file_no_namespace(test_dir):
|
||||||
test_dir = join(dico_dirs, test_dir)
|
test_dir = join(dico_dirs, test_dir)
|
||||||
if not (Path(test_dir) / 'tiramisu' / 'no_namespace.py').is_file():
|
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')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionary_multi(test_dir):
|
def test_structural_file_multi(test_dir):
|
||||||
if no_test_base_multi:
|
if no_test_base_multi:
|
||||||
print('FIXME')
|
print('FIXME')
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ logger.setLevel(logging.INFO)
|
||||||
def test_mode_invalid_default():
|
def test_mode_invalid_default():
|
||||||
# default variable mode is not in modes_level
|
# default variable mode is not in modes_level
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
|
rougailconfig['main_structural_directories'] = ['tests/personalize_mode/dictionary']
|
||||||
rougailconfig['modes_level'] = ['level1', 'level2']
|
rougailconfig['modes_level'] = ['level1', 'level2']
|
||||||
with raises(ValueError) as err:
|
with raises(ValueError) as err:
|
||||||
rougailconfig['default_family_mode'] = 'level3'
|
rougailconfig['default_family_mode'] = 'level3'
|
||||||
|
|
@ -23,7 +23,7 @@ def test_mode_invalid_default():
|
||||||
def test_mode_invalid_default_family():
|
def test_mode_invalid_default_family():
|
||||||
# default family mode is not in modes_level
|
# default family mode is not in modes_level
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
|
rougailconfig['main_structural_directories'] = ['tests/personalize_mode/dictionary']
|
||||||
rougailconfig['modes_level'] = ['level1', 'level2']
|
rougailconfig['modes_level'] = ['level1', 'level2']
|
||||||
with raises(ValueError) as err:
|
with raises(ValueError) as err:
|
||||||
rougailconfig['default_variable_mode'] = 'level3'
|
rougailconfig['default_variable_mode'] = 'level3'
|
||||||
|
|
@ -31,7 +31,7 @@ def test_mode_invalid_default_family():
|
||||||
|
|
||||||
def test_personalize_mode():
|
def test_personalize_mode():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
|
rougailconfig['main_structural_directories'] = ['tests/personalize_mode/dictionary']
|
||||||
rougailconfig['modes_level'] = ['level1', 'level2']
|
rougailconfig['modes_level'] = ['level1', 'level2']
|
||||||
rougailconfig['default_variable_mode'] = 'level1'
|
rougailconfig['default_variable_mode'] = 'level1'
|
||||||
rougailconfig['default_family_mode'] = 'level1'
|
rougailconfig['default_family_mode'] = 'level1'
|
||||||
|
|
@ -43,7 +43,7 @@ def test_personalize_mode():
|
||||||
def test_personalize_mode_unknown():
|
def test_personalize_mode_unknown():
|
||||||
# a variable has an unknown mode
|
# a variable has an unknown mode
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
|
rougailconfig['main_structural_directories'] = ['tests/personalize_mode/dictionary']
|
||||||
rougailconfig['modes_level'] = ['level1']
|
rougailconfig['modes_level'] = ['level1']
|
||||||
rougailconfig['default_variable_mode'] = 'level1'
|
rougailconfig['default_variable_mode'] = 'level1'
|
||||||
rougailconfig['default_family_mode'] = 'level1'
|
rougailconfig['default_family_mode'] = 'level1'
|
||||||
|
|
@ -55,7 +55,7 @@ def test_personalize_mode_unknown():
|
||||||
|
|
||||||
def test_personalize_annotate_twice():
|
def test_personalize_annotate_twice():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/personalize_mode/dictionary']
|
rougailconfig['main_structural_directories'] = ['tests/personalize_mode/dictionary']
|
||||||
rougailconfig['modes_level'] = ['level1', 'level2']
|
rougailconfig['modes_level'] = ['level1', 'level2']
|
||||||
rougailconfig['default_variable_mode'] = 'level1'
|
rougailconfig['default_variable_mode'] = 'level1'
|
||||||
rougailconfig['default_family_mode'] = 'level1'
|
rougailconfig['default_family_mode'] = 'level1'
|
||||||
|
|
@ -68,7 +68,7 @@ def test_personalize_annotate_twice():
|
||||||
|
|
||||||
def test_option_params():
|
def test_option_params():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/default_option_params/structure']
|
rougailconfig['main_structural_directories'] = ['tests/default_option_params/structure']
|
||||||
rougailconfig["define_default_params"] = True
|
rougailconfig["define_default_params"] = True
|
||||||
rougailconfig["default_params.unix_filename.test_existence"] = True
|
rougailconfig["default_params.unix_filename.test_existence"] = True
|
||||||
eolobj = Rougail(rougailconfig=rougailconfig)
|
eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
|
|
@ -85,8 +85,8 @@ def test_option_params():
|
||||||
def test_namespace():
|
def test_namespace():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['main_namespace'] = 'NS1'
|
rougailconfig['main_namespace'] = 'NS1'
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/namespace']
|
rougailconfig['main_structural_directories'] = ['tests/namespace']
|
||||||
rougailconfig['extra_dictionaries'] = {'NS2': ['tests/namespace'],
|
rougailconfig['extra_namespaces'] = {'NS2': ['tests/namespace'],
|
||||||
'NS3': ['tests/namespace'],
|
'NS3': ['tests/namespace'],
|
||||||
}
|
}
|
||||||
eolobj = Rougail(rougailconfig=rougailconfig)
|
eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
|
|
@ -101,7 +101,7 @@ def test_namespace():
|
||||||
#def test_duplicate_0():
|
#def test_duplicate_0():
|
||||||
# rougailconfig = RougailConfig.copy()
|
# rougailconfig = RougailConfig.copy()
|
||||||
# rougailconfig['main_namespace'] = None
|
# rougailconfig['main_namespace'] = None
|
||||||
# rougailconfig['dictionaries_dir'] = ['tests/duplicates/0/']
|
# rougailconfig['main_structural_directories'] = ['tests/duplicates/0/']
|
||||||
# eolobj = Rougail(rougailconfig=rougailconfig)
|
# eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
# cfg = eolobj.run()
|
# cfg = eolobj.run()
|
||||||
# cfg.value.get()
|
# cfg.value.get()
|
||||||
|
|
@ -112,7 +112,7 @@ def test_namespace():
|
||||||
def test_duplicate_1():
|
def test_duplicate_1():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['main_namespace'] = None
|
rougailconfig['main_namespace'] = None
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/duplicates/1/']
|
rougailconfig['main_structural_directories'] = ['tests/duplicates/1/']
|
||||||
eolobj = Rougail(rougailconfig=rougailconfig)
|
eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
cfg = eolobj.run()
|
cfg = eolobj.run()
|
||||||
with raises(ConflictError):
|
with raises(ConflictError):
|
||||||
|
|
@ -124,7 +124,7 @@ def test_duplicate_1():
|
||||||
def test_duplicate_2():
|
def test_duplicate_2():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['main_namespace'] = None
|
rougailconfig['main_namespace'] = None
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/duplicates/2/']
|
rougailconfig['main_structural_directories'] = ['tests/duplicates/2/']
|
||||||
eolobj = Rougail(rougailconfig=rougailconfig)
|
eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
cfg = eolobj.run()
|
cfg = eolobj.run()
|
||||||
with raises(ConflictError):
|
with raises(ConflictError):
|
||||||
|
|
@ -136,7 +136,7 @@ def test_duplicate_2():
|
||||||
def test_duplicate_3():
|
def test_duplicate_3():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['main_namespace'] = None
|
rougailconfig['main_namespace'] = None
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/duplicates/3/']
|
rougailconfig['main_structural_directories'] = ['tests/duplicates/3/']
|
||||||
eolobj = Rougail(rougailconfig=rougailconfig)
|
eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
cfg = eolobj.run()
|
cfg = eolobj.run()
|
||||||
with raises(ConflictError):
|
with raises(ConflictError):
|
||||||
|
|
@ -148,7 +148,7 @@ def test_duplicate_3():
|
||||||
#def test_duplicate_4():
|
#def test_duplicate_4():
|
||||||
# rougailconfig = RougailConfig.copy()
|
# rougailconfig = RougailConfig.copy()
|
||||||
# rougailconfig['main_namespace'] = None
|
# rougailconfig['main_namespace'] = None
|
||||||
# rougailconfig['dictionaries_dir'] = ['tests/duplicates/4/']
|
# rougailconfig['main_structural_directories'] = ['tests/duplicates/4/']
|
||||||
# eolobj = Rougail(rougailconfig=rougailconfig)
|
# eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
# cfg = eolobj.run()
|
# cfg = eolobj.run()
|
||||||
# with raises(ConflictError):
|
# with raises(ConflictError):
|
||||||
|
|
@ -160,7 +160,7 @@ def test_duplicate_3():
|
||||||
def test_duplicate_5():
|
def test_duplicate_5():
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['main_namespace'] = None
|
rougailconfig['main_namespace'] = None
|
||||||
rougailconfig['dictionaries_dir'] = ['tests/duplicates/5/']
|
rougailconfig['main_structural_directories'] = ['tests/duplicates/5/']
|
||||||
eolobj = Rougail(rougailconfig=rougailconfig)
|
eolobj = Rougail(rougailconfig=rougailconfig)
|
||||||
cfg = eolobj.run()
|
cfg = eolobj.run()
|
||||||
with raises(ConflictError):
|
with raises(ConflictError):
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ the kinematics are as follows:
|
||||||
|
|
||||||
|
|
||||||
def test_validate_default_version():
|
def test_validate_default_version():
|
||||||
"retrieves the default_dictionary_format_version if no version in the yaml file"
|
"retrieves the default_structural_format_version if no version in the yaml file"
|
||||||
|
|
||||||
RougailConfig["dictionaries_dir"] = ["tests/data/dict1"]
|
RougailConfig["main_structural_directories"] = ["tests/data/dict1"]
|
||||||
RougailConfig["default_dictionary_format_version"] = "1.1"
|
RougailConfig["default_structural_format_version"] = "1.1"
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
config = rougail.run()
|
config = rougail.run()
|
||||||
|
|
||||||
|
|
@ -46,14 +46,14 @@ def test_validate_default_version():
|
||||||
with open(filename, encoding="utf8") as file_fh:
|
with open(filename, encoding="utf8") as file_fh:
|
||||||
objects = YAML(typ="safe").load(file_fh)
|
objects = YAML(typ="safe").load(file_fh)
|
||||||
version = rougail.converted.validate_file_version(objects, filename)
|
version = rougail.converted.validate_file_version(objects, filename)
|
||||||
assert version == RougailConfig["default_dictionary_format_version"]
|
assert version == RougailConfig["default_structural_format_version"]
|
||||||
|
|
||||||
|
|
||||||
def test_validate_file_version_from_yml():
|
def test_validate_file_version_from_yml():
|
||||||
"retrives the yaml file version defined in the yaml file"
|
"retrives the yaml file version defined in the yaml file"
|
||||||
|
|
||||||
RougailConfig["dictionaries_dir"] = ["tests/data/dict2"]
|
RougailConfig["main_structural_directories"] = ["tests/data/dict2"]
|
||||||
RougailConfig["default_dictionary_format_version"] = "1.1"
|
RougailConfig["default_structural_format_version"] = "1.1"
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
config = rougail.run()
|
config = rougail.run()
|
||||||
|
|
||||||
|
|
@ -66,17 +66,10 @@ def test_validate_file_version_from_yml():
|
||||||
|
|
||||||
def test_retrieve_version_from_config():
|
def test_retrieve_version_from_config():
|
||||||
|
|
||||||
RougailConfig["dictionaries_dir"] = ["tests/data/dict2"]
|
RougailConfig["main_structural_directories"] = ["tests/data/dict2"]
|
||||||
RougailConfig["default_dictionary_format_version"] = "1.1"
|
RougailConfig["default_structural_format_version"] = "1.1"
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
# FIXME replace with rougail.annotator()
|
# FIXME replace with rougail.annotator()
|
||||||
# rougail.converted.annotator()
|
# rougail.converted.annotator()
|
||||||
rougail.run()
|
rougail.run()
|
||||||
assert rougail.converted.paths._data["rougail.hello"].version == "1.0"
|
assert rougail.converted.paths._data["rougail.hello"].version == "1.0"
|
||||||
|
|
||||||
|
|
||||||
# def test_dictionary(test_dir):
|
|
||||||
# assert getcwd() == ORI_DIR
|
|
||||||
# test_dir = join(dico_dirs, test_dir)
|
|
||||||
# launch_test(test_dir, 'dict')
|
|
||||||
# assert getcwd() == ORI_DIR
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue