Compare commits

...

2 commits

8 changed files with 84 additions and 52 deletions

View file

@ -1,3 +1,12 @@
## 1.2.3 (2026-09-02)
### Fix
- variable and family object are same has type object
- a type could be a dynamic family
- main_namespace is not mandatory (for example for risotto)
- correction in error message
## 1.2.2 (2026-08-21) ## 1.2.2 (2026-08-21)
### Fix ### Fix

View file

@ -1,6 +1,6 @@
[project] [project]
name = "rougail" name = "rougail"
version = "1.2.2" version = "1.2.3"
[tool.commitizen] [tool.commitizen]
name = "cz_conventional_commits" name = "cz_conventional_commits"

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail-base" name = "rougail-base"
version = "1.2.2" version = "1.2.3"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md" readme = "README.md"
description = "A consistency handling system that was initially designed in the configuration management" description = "A consistency handling system that was initially designed in the configuration management"

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail" name = "rougail"
version = "1.2.2" version = "1.2.3"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md" readme = "README.md"
description = "A consistency handling system that was initially designed in the configuration management" description = "A consistency handling system that was initially designed in the configuration management"
@ -27,7 +27,7 @@ classifiers = [
dependencies = [ dependencies = [
"ruamel.yaml ~= 0.19.1", # same version as rougail-user-data-yaml "ruamel.yaml ~= 0.19.1", # same version as rougail-user-data-yaml
"pydantic ~= 2.13.4", "pydantic ~= 2.13.4",
"rougail-base == 1.2.2", "rougail-base == 1.2.3",
] ]
[tool.flit.sdist] [tool.flit.sdist]

View file

@ -1 +1 @@
__version__ = "1.2.2" __version__ = "1.2.3"

View file

@ -42,8 +42,11 @@ class Rougail(UserData):
load_from_tiramisu_cache load_from_tiramisu_cache
and Path(self.rougailconfig["tiramisu_cache"]).is_file() and Path(self.rougailconfig["tiramisu_cache"]).is_file()
) )
types = rougail_type(self.rougailconfig)
if not self.load_from_tiramisu_cache: if not self.load_from_tiramisu_cache:
if rougailconfig["types"]:
types = rougail_type(self.rougailconfig)
else:
types = {}
self.converted = RougailConvert(self.rougailconfig, **types) self.converted = RougailConvert(self.rougailconfig, **types)
self.config = None self.config = None

View file

@ -206,6 +206,7 @@ class ParserVariable:
return return
root = Path(__file__).parent.parent root = Path(__file__).parent.parent
self.walker = None self.walker = None
if self.variable_objects is None:
self.variable = Variable self.variable = Variable
self.family = Family self.family = Family
for structural_name in self.structurals: for structural_name in self.structurals:
@ -248,6 +249,20 @@ class ParserVariable:
self.get_variable_object(obj, is_variable=False) self.get_variable_object(obj, is_variable=False)
for obj in [self.dynamic, self.family] for obj in [self.dynamic, self.family]
] ]
else:
self.variable = self.variable_objects[0]
self.choices = self.variable_objects[2]
self.regexp = self.variable_objects[3]
self.family = self.family_objects[-1]
self.dynamic = self.family_objects[0]
for structural_name in self.structurals:
structural = f"structural_{structural_name}"
module_path = root / structural / "__init__.py"
if not module_path.is_file():
continue
module = load_modules(f"rougail.{structural}", str(module_path))
if not self.walker and "Walker" in module.__all__:
self.walker = module.Walker
self.is_init = True self.is_init = True
def get_variable_object(self, obj, *, is_variable: bool) -> dict: def get_variable_object(self, obj, *, is_variable: bool) -> dict:
@ -599,12 +614,16 @@ class RougailConvert(ParserVariable):
*, *,
custom_variable_types: dict = {}, custom_variable_types: dict = {},
custom_family_types: dict = {}, custom_family_types: dict = {},
variable_objects = None,
family_objects = None,
) -> None: ) -> None:
self.annotator = False self.annotator = False
self.has_namespace = False self.has_namespace = False
self.custom_variable_types = custom_variable_types self.custom_variable_types = custom_variable_types
self.custom_family_types = custom_family_types self.custom_family_types = custom_family_types
self.loaded_custom_types = None self.loaded_custom_types = None
self.variable_objects = variable_objects
self.family_objects = family_objects
super().__init__(rougailconfig) super().__init__(rougailconfig)
def get_attributes_types( def get_attributes_types(

View file

@ -27,6 +27,7 @@ class TypeRougailConvert(StaticRougailConvert):
main_structural_directories: list[str], main_structural_directories: list[str],
secret_pattern: str, secret_pattern: str,
default_structural_format_version: str, default_structural_format_version: str,
structurals: list[str],
) -> None: ) -> None:
super().__init__( super().__init__(
False, False,
@ -38,23 +39,21 @@ class TypeRougailConvert(StaticRougailConvert):
) )
self.default_structural_format_version = default_structural_format_version self.default_structural_format_version = default_structural_format_version
self.secret_pattern = secret_pattern self.secret_pattern = secret_pattern
self.structurals = structurals
self.loaded_custom_types = {} self.loaded_custom_types = {}
def load_config(self) -> None: def load_config(self) -> None:
super().load_config() super().load_config()
# self.add_extra_options = self.add_extra_options # self.add_extra_options = self.add_extra_options
self.sort_structural_files_all = False self.sort_structural_files_all = False
self.structurals = ["directory"]
def rougail_type(rougailconfig): def rougail_type(rougailconfig):
types = rougailconfig["types"]
if not types:
return {"custom_variable_types": {}, "custom_family_types": {}}
convert = TypeRougailConvert( convert = TypeRougailConvert(
types, rougailconfig["types"],
rougailconfig["secret_manager.pattern"], rougailconfig["secret_manager.pattern"],
rougailconfig["default_structural_format_version"], rougailconfig["default_structural_format_version"],
rougailconfig["step.structural"],
) )
convert.init() convert.init()
convert.parse_directories() convert.parse_directories()
@ -79,6 +78,8 @@ def rougail_type(rougailconfig):
else: else:
custom_family_types[typ] = data custom_family_types[typ] = data
return { return {
"variable_objects": convert.variable_objects,
"family_objects": convert.family_objects,
"custom_variable_types": custom_variable_types, "custom_variable_types": custom_variable_types,
"custom_family_types": custom_family_types, "custom_family_types": custom_family_types,
} }