rougail-base 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rougail/__init__.py ADDED
@@ -0,0 +1,36 @@
1
+ """Rougail method
2
+
3
+ Created by:
4
+ EOLE (http://eole.orion.education.fr)
5
+ Copyright (C) 2005-2018
6
+
7
+ Forked by:
8
+ Cadoles (http://www.cadoles.com)
9
+ Copyright (C) 2019-2021
10
+
11
+ Silique (https://www.silique.fr)
12
+ Copyright (C) 2022-2026
13
+
14
+ This program is free software: you can redistribute it and/or modify it
15
+ under the terms of the GNU Lesser General Public License as published by the
16
+ Free Software Foundation, either version 3 of the License, or (at your
17
+ option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful, but WITHOUT
20
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
22
+ details.
23
+
24
+ You should have received a copy of the GNU Lesser General Public License
25
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
26
+ """
27
+
28
+ from .__version__ import __version__
29
+
30
+ try:
31
+ from .convert import Rougail, SUPPORTED_VERSION
32
+ from .config import RougailConfig
33
+
34
+ __all__ = ("Rougail", "RougailConfig", "__version__")
35
+ except ModuleNotFoundError as err:
36
+ __all__ = ("__version__",)
rougail/__version__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "1.2.0"
rougail/error.py ADDED
@@ -0,0 +1,87 @@
1
+ """Standard error classes
2
+
3
+ Created by:
4
+ EOLE (http://eole.orion.education.fr)
5
+ Copyright (C) 2005-2018
6
+
7
+ Forked by:
8
+ Cadoles (http://www.cadoles.com)
9
+ Copyright (C) 2019-2021
10
+
11
+ Silique (https://www.silique.fr)
12
+ Copyright (C) 2022-2026
13
+
14
+ This program is free software: you can redistribute it and/or modify it
15
+ under the terms of the GNU Lesser General Public License as published by the
16
+ Free Software Foundation, either version 3 of the License, or (at your
17
+ option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful, but WITHOUT
20
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
22
+ details.
23
+
24
+ You should have received a copy of the GNU Lesser General Public License
25
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
26
+ """
27
+
28
+ from .i18n import _
29
+ from .tiramisu import display_xmlfiles
30
+
31
+
32
+ class ConfigError(Exception):
33
+ """Standard error for templating"""
34
+
35
+
36
+ class FileNotFound(ConfigError):
37
+ """Template file is not found"""
38
+
39
+
40
+ class TemplateError(ConfigError):
41
+ """Templating generate an error"""
42
+
43
+
44
+ class TemplateDisabled(TemplateError):
45
+ """Template is disabled."""
46
+
47
+
48
+ class SpaceObjShallNotBeUpdated(Exception):
49
+ """Specific behavior in case of the presence or not
50
+ of an object in the space object
51
+ """
52
+
53
+
54
+ class DictConsistencyError(Exception):
55
+ """It's not only that the Creole XML is valid against the Creole DTD
56
+ it's that it is not consistent.
57
+ """
58
+
59
+ def __init__(self, msg, errno, xmlfiles):
60
+ if xmlfiles:
61
+ msg = _("{0} in {1}").format(msg, display_xmlfiles(xmlfiles))
62
+ super().__init__(msg)
63
+ self.errno = errno
64
+
65
+
66
+ ## ---- generic exceptions ----
67
+
68
+
69
+ class NotFoundError(Exception):
70
+ "not found error"
71
+
72
+ pass
73
+
74
+
75
+ class ExtensionError(Exception):
76
+ pass
77
+
78
+
79
+ class RougailWarning(UserWarning):
80
+ pass
81
+
82
+
83
+ ## ---- specific exceptions ----
84
+
85
+
86
+ class VariableCalculationDependencyError(Exception):
87
+ pass
rougail/i18n.py ADDED
@@ -0,0 +1,32 @@
1
+ """Internationalisation utilities
2
+ Created by:
3
+ EOLE (http://eole.orion.education.fr)
4
+ Copyright (C) 2005-2018
5
+
6
+ Forked by:
7
+ Cadoles (http://www.cadoles.com)
8
+ Copyright (C) 2019-2021
9
+
10
+ Silique (https://www.silique.fr)
11
+ Copyright (C) 2022-2026
12
+
13
+ This program is free software: you can redistribute it and/or modify it
14
+ under the terms of the GNU Lesser General Public License as published by the
15
+ Free Software Foundation, either version 3 of the License, or (at your
16
+ option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful, but WITHOUT
19
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
21
+ details.
22
+
23
+ You should have received a copy of the GNU Lesser General Public License
24
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ """
26
+
27
+ from gettext import translation
28
+ from pathlib import Path
29
+
30
+ t = translation("rougail", str(Path(__file__).parent / "locale"), fallback=True)
31
+
32
+ _ = t.gettext
Binary file
@@ -0,0 +1,103 @@
1
+ """
2
+ Silique (https://www.silique.fr)
3
+ Copyright (C) 2025-2026
4
+
5
+ This program is free software: you can redistribute it and/or modify it
6
+ under the terms of the GNU Lesser General Public License as published by the
7
+ Free Software Foundation, either version 3 of the License, or (at your
8
+ option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful, but WITHOUT
11
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
+ details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ """
18
+
19
+ from typing import List, Optional
20
+ from itertools import chain
21
+ from ruamel.yaml import YAML
22
+
23
+ from ..tiramisu import normalize_family
24
+ from ..convert.path import Paths
25
+
26
+ # from ..error import DictConsistencyError
27
+ # from ..i18n import _
28
+
29
+
30
+ class Walker:
31
+ def __init__(
32
+ self,
33
+ convert,
34
+ ) -> None:
35
+ """Parse directories content"""
36
+ self.convert = convert
37
+ self.yaml = YAML()
38
+ rougailconfig = self.convert.rougailconfig
39
+ if rougailconfig["main_namespace"]:
40
+ self.load_with_extra(
41
+ rougailconfig["extra_namespaces"],
42
+ rougailconfig["main_namespace"],
43
+ rougailconfig["main_structural_strings"],
44
+ rougailconfig["isolated_namespace"],
45
+ )
46
+ else:
47
+ self.convert.namespace = None
48
+ for string in rougailconfig["main_structural_strings"]:
49
+ self.parse_variable(
50
+ string,
51
+ )
52
+
53
+ def load_with_extra(
54
+ self,
55
+ extra_structures: dict,
56
+ main_namespace: str,
57
+ main_strings: Optional[List[str]] = None,
58
+ isolated_namespace: bool = True,
59
+ ) -> None:
60
+ directory_dict = chain(
61
+ (
62
+ (
63
+ main_namespace,
64
+ main_strings,
65
+ ),
66
+ ),
67
+ extra_structures.items(),
68
+ )
69
+ for namespace, extra_objects in directory_dict:
70
+ namespace_path = normalize_family(namespace)
71
+ for idx, string in enumerate(extra_objects):
72
+ if not idx:
73
+ # create only for the first file
74
+ self.convert.create_namespace(namespace, isolated_namespace)
75
+ self.parse_variable(
76
+ string,
77
+ )
78
+
79
+ def parse_variable(
80
+ self,
81
+ string: str,
82
+ ) -> None:
83
+ objects = self.yaml.load(string)
84
+ if objects is None:
85
+ return
86
+ path = self.convert.namespace
87
+ if path:
88
+ name = f"yaml file for {path}"
89
+ else:
90
+ name = "yaml file"
91
+ version = self.convert.validate_file_version(
92
+ objects,
93
+ name,
94
+ )
95
+ self.convert.parse_root_file(
96
+ [name],
97
+ path,
98
+ version,
99
+ objects,
100
+ )
101
+
102
+
103
+ __all__ = ("Walker",)
@@ -0,0 +1,68 @@
1
+ """
2
+ Silique (https://www.silique.fr)
3
+ Copyright (C) 2025-2026
4
+
5
+ This program is free software: you can redistribute it and/or modify it
6
+ under the terms of the GNU Lesser General Public License as published by the
7
+ Free Software Foundation, either version 3 of the License, or (at your
8
+ option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful, but WITHOUT
11
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
+ details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ """
18
+
19
+ from ..utils import _
20
+
21
+
22
+ def get_rougail_config(
23
+ *,
24
+ backward_compatibility=True,
25
+ ) -> dict:
26
+ if backward_compatibility:
27
+ main_namespace_default = "rougail"
28
+ else:
29
+ main_namespace_default = "null"
30
+ options = f"""
31
+ main_structural_strings:
32
+ description: {_("Structural files contents")}
33
+ help: {_("This variable is a list of string with YAML file format")}
34
+ multi: true
35
+ disabled:
36
+ jinja: >-
37
+ {{% if 'string' not in _.step.structural %}}
38
+ true
39
+ {{% elif cli is defined and cli.versions is defined and cli.versions %}}
40
+ true
41
+ {{% else %}}
42
+ false
43
+ {{% endif %}}
44
+ return_type: boolean
45
+ description: {_('string is not in "_.step.structural"')}
46
+
47
+ extra_namespaces:
48
+
49
+ strings:
50
+ description: {_("Extra structural contents")}
51
+ help: {_("This variable is a list of string with YAML file format")}
52
+ alternative_name: xc
53
+ multi: true
54
+ disabled:
55
+ jinja: >-
56
+ {{{{ 'string' not in __.step.structural }}}}
57
+ return_type: boolean
58
+ description: {_('string is not in "__.step.structural"')}
59
+ """
60
+ return {
61
+ "name": "string",
62
+ "process": "structural",
63
+ "options": options,
64
+ "level": 15,
65
+ }
66
+
67
+
68
+ __all__ = "get_rougail_config"