feat: separate rougail and rougail-base
This commit is contained in:
parent
c7a66a034e
commit
a3b2699289
19 changed files with 215 additions and 1286 deletions
|
|
@ -1,47 +1,6 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail"
|
||||
version = "1.2.0a26"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "A consistency handling system that was initially designed in the configuration management"
|
||||
requires-python = ">=3.8"
|
||||
license = {file = "LICENSE"}
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3.14",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
"Natural Language :: French",
|
||||
|
||||
]
|
||||
dependencies = [
|
||||
"ruamel.yaml ~= 0.18.6",
|
||||
"pydantic ~= 2.9.2",
|
||||
"jinja2 ~= 3.1.4",
|
||||
"tiramisu >=5.0,<6"
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"pylint ~= 3.0.3",
|
||||
"pytest ~= 8.2.2",
|
||||
"lxml ~= 5.2.2"
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Home = "https://forge.cloud.silique.fr/stove/rougail"
|
||||
|
||||
[tool.commitizen]
|
||||
name = "cz_conventional_commits"
|
||||
|
|
@ -50,7 +9,10 @@ version_scheme = "pep440"
|
|||
version_provider = "pep621"
|
||||
version_files = [
|
||||
"src/rougail/__version__.py",
|
||||
"pyproject.toml:version"
|
||||
"rougail-pyproject.toml:version",
|
||||
"rougail-pyproject.toml:rougail-base == ",
|
||||
"rougail-base-pyproject.toml:version",
|
||||
]
|
||||
update_changelog_on_bump = true
|
||||
changelog_merge_prerelease = true
|
||||
|
||||
|
|
|
|||
52
rougail-base-pyproject.toml
Normal file
52
rougail-base-pyproject.toml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail-base"
|
||||
version = "1.2.0a26"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "A consistency handling system that was initially designed in the configuration management"
|
||||
requires-python = ">=3.10"
|
||||
license = {file = "LICENSE"}
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3.14",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
"Natural Language :: French",
|
||||
|
||||
]
|
||||
dependencies = [
|
||||
"jinja2 ~= 3.1.4",
|
||||
"tiramisu ~= 5.0"
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"pylint ~= 3.0.3",
|
||||
"pytest ~= 8.2.2",
|
||||
]
|
||||
|
||||
[tool.flit.module]
|
||||
name = "rougail"
|
||||
|
||||
[tool.flit.sdist]
|
||||
exclude = [
|
||||
"src/rougail/annotator",
|
||||
"src/rougail/config",
|
||||
"src/rougail/convert",
|
||||
"src/rougail/structural_commandline",
|
||||
"src/rougail/structural_directory",
|
||||
"src/rougail/update",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Home = "https://forge.cloud.silique.fr/stove/rougail"
|
||||
35
rougail-pyproject.toml
Normal file
35
rougail-pyproject.toml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail"
|
||||
version = "1.2.0a26"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
description = "A consistency handling system that was initially designed in the configuration management"
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||
"Programming Language :: Python",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
"Natural Language :: French",
|
||||
|
||||
]
|
||||
dependencies = [
|
||||
"ruamel.yaml ~= 0.18.6",
|
||||
"pydantic ~= 2.9.2",
|
||||
"rougail-base == 1.2.0a26",
|
||||
]
|
||||
|
||||
[tool.flit.sdist]
|
||||
exclude = [
|
||||
"src/rougail/error.py",
|
||||
"src/rougail/i18n.py",
|
||||
"src/rougail/tiramisu.py",
|
||||
"src/rougail/user_datas.py",
|
||||
"src/rougail/utils.py",
|
||||
"src/rougail/__version__.py",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Home = "https://forge.cloud.silique.fr/stove/rougail"
|
||||
|
|
@ -24,56 +24,10 @@ 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 tiramisu import Config
|
||||
from warnings import warn
|
||||
|
||||
from .convert import RougailConvert
|
||||
from .config import RougailConfig
|
||||
from .utils import normalize_family
|
||||
from .object_model import CONVERT_OPTION
|
||||
from .user_datas import UserDatas
|
||||
from .tiramisu import tiramisu_display_name
|
||||
from .__version__ import __version__
|
||||
|
||||
|
||||
class Rougail(UserDatas):
|
||||
"""Main Rougail object"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
rougailconfig=None,
|
||||
) -> None:
|
||||
if rougailconfig is None:
|
||||
rougailconfig = RougailConfig
|
||||
self.rougailconfig = rougailconfig
|
||||
self.converted = RougailConvert(self.rougailconfig)
|
||||
self.config = None
|
||||
|
||||
def run(self):
|
||||
"""Get Tiramisu Config"""
|
||||
if not self.config:
|
||||
tiram_obj = self.converted.save()
|
||||
optiondescription = {}
|
||||
custom_types = {
|
||||
custom.__name__: custom
|
||||
for custom in self.rougailconfig["custom_types"].values()
|
||||
}
|
||||
exec(tiram_obj, custom_types, optiondescription) # pylint: disable=W0122
|
||||
self.config = Config(
|
||||
optiondescription["option_0"],
|
||||
display_name=tiramisu_display_name,
|
||||
)
|
||||
self.config.property.read_write()
|
||||
return self.config
|
||||
|
||||
def get_config(self):
|
||||
warn(
|
||||
"get_config is deprecated, use run instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.run()
|
||||
|
||||
|
||||
__all__ = ("Rougail", "RougailConfig")
|
||||
try:
|
||||
from .convert import Rougail
|
||||
from .config import RougailConfig
|
||||
__all__ = ("Rougail", "RougailConfig", "__version__")
|
||||
except ModuleNotFoundError as err:
|
||||
__all__ = ("__version__",)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from typing import Optional
|
|||
from rougail.i18n import _
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.annotator.variable import Walk
|
||||
from rougail.object_model import VariableCalculation
|
||||
from rougail.convert.object_model import VariableCalculation
|
||||
|
||||
|
||||
class Mode: # pylint: disable=R0903
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from typing import Union
|
|||
from rougail.i18n import _
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.annotator.variable import Walk
|
||||
from rougail.object_model import Calculation
|
||||
from rougail.convert.object_model import Calculation
|
||||
|
||||
|
||||
PROPERTIES = (
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from rougail.annotator.variable import Walk
|
|||
|
||||
from rougail.i18n import _
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.object_model import Calculation
|
||||
from rougail.convert.object_model import Calculation
|
||||
|
||||
|
||||
class Annotator(Walk): # pylint: disable=R0903
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from tiramisu.error import display_list
|
|||
from rougail.i18n import _
|
||||
from rougail.utils import calc_multi_for_type_variable
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.object_model import Calculation, VariableCalculation
|
||||
from rougail.convert.object_model import Calculation, VariableCalculation
|
||||
|
||||
|
||||
class Walk:
|
||||
|
|
|
|||
|
|
@ -26,17 +26,15 @@ 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 sys import version_info
|
||||
|
||||
from pathlib import Path
|
||||
from tiramisu import Config
|
||||
from ruamel.yaml import YAML
|
||||
from .utils import _, load_modules, normalize_family
|
||||
from .convert import RougailConvert
|
||||
from .object_model import get_convert_option_types
|
||||
from ..utils import _, load_modules
|
||||
from ..tiramisu import normalize_family
|
||||
from ..convert import RougailConvert
|
||||
from ..convert.object_model import get_convert_option_types
|
||||
|
||||
if version_info.major == 3 and version_info.minor:
|
||||
import rougail.structural_commandline.object_model
|
||||
#import rougail.structural_commandline.object_model
|
||||
|
||||
RENAMED = {
|
||||
"dictionaries_dir": "main_dictionaries",
|
||||
|
|
@ -53,7 +51,7 @@ def get_sub_modules():
|
|||
global SUBMODULES
|
||||
if SUBMODULES is None:
|
||||
SUBMODULES = {}
|
||||
for submodule in Path(__file__).parent.iterdir():
|
||||
for submodule in Path(__file__).parent.parent.iterdir():
|
||||
if submodule.name.startswith("_") or not submodule.is_dir():
|
||||
continue
|
||||
config_file = submodule / "config.py"
|
||||
|
|
@ -181,6 +179,7 @@ class _RougailConfig:
|
|||
yield f"{option.path()}: {option.value.get()}"
|
||||
|
||||
def __repr__(self):
|
||||
print(self.config)
|
||||
self.config.property.read_write()
|
||||
try:
|
||||
values = "\n".join(self.parse(self.config))
|
||||
File diff suppressed because it is too large
Load diff
63
src/rougail/convert/__init__.py
Normal file
63
src/rougail/convert/__init__.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
"""Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 tiramisu import Config
|
||||
from warnings import warn
|
||||
|
||||
from .convert import RougailConvert
|
||||
from ..config import RougailConfig
|
||||
from ..user_datas import UserDatas
|
||||
from ..tiramisu import tiramisu_display_name
|
||||
|
||||
|
||||
class Rougail(UserDatas):
|
||||
"""Main Rougail object"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
rougailconfig=None,
|
||||
) -> None:
|
||||
if rougailconfig is None:
|
||||
rougailconfig = RougailConfig
|
||||
self.rougailconfig = rougailconfig
|
||||
self.converted = RougailConvert(self.rougailconfig)
|
||||
self.config = None
|
||||
|
||||
def run(self):
|
||||
"""Get Tiramisu Config"""
|
||||
if not self.config:
|
||||
tiram_obj = self.converted.save()
|
||||
optiondescription = {}
|
||||
custom_types = {
|
||||
custom.__name__: custom
|
||||
for custom in self.rougailconfig["custom_types"].values()
|
||||
}
|
||||
exec(tiram_obj, custom_types, optiondescription) # pylint: disable=W0122
|
||||
self.config = Config(
|
||||
optiondescription["option_0"],
|
||||
display_name=tiramisu_display_name,
|
||||
)
|
||||
self.config.property.read_write()
|
||||
return self.config
|
||||
|
||||
def get_config(self):
|
||||
warn(
|
||||
"get_config is deprecated, use run instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.run()
|
||||
|
|
@ -28,10 +28,10 @@ from pydantic import (
|
|||
)
|
||||
import tiramisu
|
||||
from tiramisu.config import get_common_path
|
||||
from .utils import get_jinja_variable_to_param, calc_multi_for_type_variable, undefined
|
||||
from .i18n import _
|
||||
from .error import DictConsistencyError, VariableCalculationDependencyError
|
||||
from .tiramisu import CONVERT_OPTION
|
||||
from ..utils import get_jinja_variable_to_param, calc_multi_for_type_variable, undefined
|
||||
from ..i18n import _
|
||||
from ..error import DictConsistencyError, VariableCalculationDependencyError
|
||||
from ..tiramisu import CONVERT_OPTION
|
||||
|
||||
BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None]
|
||||
PROPERTY_ATTRIBUTE = ["frozen", "hidden", "disabled", "mandatory"]
|
||||
|
|
@ -24,9 +24,9 @@ from typing import (
|
|||
import logging
|
||||
from re import compile, findall
|
||||
|
||||
from .i18n import _
|
||||
from ..i18n import _
|
||||
from .object_model import Family, Variable
|
||||
from .utils import normalize_family
|
||||
from ..tiramisu import normalize_family
|
||||
|
||||
|
||||
class Paths:
|
||||
|
|
@ -30,10 +30,10 @@ from typing import Optional, Union
|
|||
from json import dumps
|
||||
from os.path import isfile, basename
|
||||
|
||||
from .i18n import _
|
||||
from .error import DictConsistencyError, VariableCalculationDependencyError
|
||||
from .utils import normalize_family
|
||||
from .object_model import Calculation, CONVERT_OPTION
|
||||
from ..i18n import _
|
||||
from ..error import DictConsistencyError, VariableCalculationDependencyError
|
||||
from ..tiramisu import normalize_family, CONVERT_OPTION
|
||||
from .object_model import Calculation
|
||||
|
||||
|
||||
class BaseElt: # pylint: disable=R0903
|
||||
|
|
@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
from .i18n import _
|
||||
from .tiramisu import display_xmlfiles
|
||||
|
||||
|
||||
class ConfigError(Exception):
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ from pathlib import Path
|
|||
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
from ..utils import normalize_family
|
||||
from ..path import Paths
|
||||
from ..tiramisu import normalize_family
|
||||
from ..convert.path import Paths
|
||||
from ..error import DictConsistencyError
|
||||
from ..i18n import _
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
from typing import List
|
||||
from re import findall
|
||||
|
||||
from rougail.utils import normalize_family, undefined
|
||||
from tiramisu import Calculation
|
||||
from tiramisu.error import (
|
||||
PropertiesOptionError,
|
||||
|
|
@ -31,10 +30,11 @@ from tiramisu.error import (
|
|||
ConfigError,
|
||||
CancelParam,
|
||||
)
|
||||
from .utils import undefined
|
||||
from .tiramisu import normalize_family, CONVERT_OPTION
|
||||
from .error import DictConsistencyError
|
||||
|
||||
from .i18n import _
|
||||
from .object_model import CONVERT_OPTION
|
||||
|
||||
|
||||
class UserDatas:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
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_2 = StrOption(name="var1", doc="a first variable", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_variable_description_multi_line/rougail/00-base.yml'], 'type': 'string'})
|
||||
option_3 = StrOption(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_variable_description_multi_line/rougail/00-base.yml'], 'type': 'string'})
|
||||
option_4 = StrOption(name="var3", doc="a new variable", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_variable_description_multi_line/rougail/00-base.yml'], 'type': 'string'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"basic"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
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="a first variable", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_variable_description_multi_line/rougail/00-base.yml'], 'type': 'string'})
|
||||
option_2 = StrOption(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_variable_description_multi_line/rougail/00-base.yml'], 'type': 'string'})
|
||||
option_3 = StrOption(name="var3", doc="a new variable", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_variable_description_multi_line/rougail/00-base.yml'], 'type': 'string'})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3])
|
||||
Loading…
Reference in a new issue