Compare commits
2 commits
6f18fbb701
...
78096446dc
| Author | SHA1 | Date | |
|---|---|---|---|
| 78096446dc | |||
| f1b8ea81cb |
7 changed files with 73 additions and 7 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
## 0.1.0a18 (2025-09-30)
|
||||||
|
|
||||||
|
### Feat
|
||||||
|
|
||||||
|
- family or dynamic could needs type attribute
|
||||||
|
|
||||||
## 0.1.0a17 (2025-09-29)
|
## 0.1.0a17 (2025-09-29)
|
||||||
|
|
||||||
### Feat
|
### Feat
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rougail.output_formatter"
|
name = "rougail.output_formatter"
|
||||||
version = "0.1.0a17"
|
version = "0.1.0a18"
|
||||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
description = "Rougail output formatter"
|
description = "Rougail output formatter"
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,18 @@ RoundTripRepresenter.add_representer(str, represent_str)
|
||||||
# XXX
|
# XXX
|
||||||
|
|
||||||
|
|
||||||
|
class RougailConvertFormatter(RougailConvert):
|
||||||
|
def parse_root_file(
|
||||||
|
self,
|
||||||
|
filename: str,
|
||||||
|
path: str,
|
||||||
|
version: str,
|
||||||
|
objects: dict,
|
||||||
|
) -> None:
|
||||||
|
self.objects = objects
|
||||||
|
super().parse_root_file(filename, path, version, objects)
|
||||||
|
|
||||||
|
|
||||||
class RougailOutputFormatter:
|
class RougailOutputFormatter:
|
||||||
output_name = "formatter"
|
output_name = "formatter"
|
||||||
|
|
||||||
|
|
@ -161,7 +173,7 @@ class RougailOutputFormatter:
|
||||||
filename
|
filename
|
||||||
)
|
)
|
||||||
self.version_name, datas = RougailUpgrade(self.rougailconfig).run(filename)
|
self.version_name, datas = RougailUpgrade(self.rougailconfig).run(filename)
|
||||||
self.rougail = RougailConvert(self.rougailconfig)
|
self.rougail = RougailConvertFormatter(self.rougailconfig)
|
||||||
self.rougail.load_config()
|
self.rougail.load_config()
|
||||||
self.rougail.init()
|
self.rougail.init()
|
||||||
self.filename_str = str(filename)
|
self.filename_str = str(filename)
|
||||||
|
|
@ -239,6 +251,32 @@ class RougailOutputFormatter:
|
||||||
attr = f"_{attr}"
|
attr = f"_{attr}"
|
||||||
family[attr] = self.object_to_yaml(attr, type_, value, False, path)
|
family[attr] = self.object_to_yaml(attr, type_, value, False, path)
|
||||||
if type_ == "dynamic" or (children and type_ == "family"):
|
if type_ == "dynamic" or (children and type_ == "family"):
|
||||||
|
tmp_family = family.copy()
|
||||||
|
if "_type" in tmp_family:
|
||||||
|
del tmp_family["_type"]
|
||||||
|
else:
|
||||||
|
del tmp_family["type"]
|
||||||
|
for child_path in self.rougail.parents[path]:
|
||||||
|
child = self.rougail.objects
|
||||||
|
if self.rougail.has_namespace:
|
||||||
|
split_path = child_path.split('.')[1:]
|
||||||
|
else:
|
||||||
|
split_path = child_path.split('.')
|
||||||
|
for cpath in split_path:
|
||||||
|
if cpath not in child and '{{ identifier }}' in cpath:
|
||||||
|
# support format 1.0
|
||||||
|
if cpath.replace('{{ identifier }}', '') in child:
|
||||||
|
cpath = cpath.replace('{{ identifier }}', '')
|
||||||
|
elif cpath.replace('{{ identifier }}', '{{ suffix }}') in child:
|
||||||
|
cpath = cpath.replace('{{ identifier }}', '{{ suffix }}')
|
||||||
|
child = child[cpath]
|
||||||
|
tmp_family[cpath] = child
|
||||||
|
family_type = self.rougail.is_family_or_variable("", tmp_family, False, "")
|
||||||
|
if family_type == "family":
|
||||||
|
family_type = self.rougail.get_family_or_variable_type(tmp_family)
|
||||||
|
if family_type is None:
|
||||||
|
family_type = 'family'
|
||||||
|
if family_type == type_:
|
||||||
if "_type" in family:
|
if "_type" in family:
|
||||||
del family["_type"]
|
del family["_type"]
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__version__ = "0.1.0a17"
|
__version__ = "0.1.0a18"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
my_family:
|
||||||
|
type: family
|
||||||
|
|
||||||
|
dynamic:
|
||||||
|
- val1
|
||||||
|
- val2
|
||||||
|
|
||||||
|
var: true # a variable
|
||||||
|
...
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
my_family:
|
||||||
|
type: family
|
||||||
|
|
||||||
|
default: true
|
||||||
|
...
|
||||||
|
|
@ -15,7 +15,7 @@ excludes = [
|
||||||
]
|
]
|
||||||
|
|
||||||
test_ok = get_structures_list(excludes)
|
test_ok = get_structures_list(excludes)
|
||||||
# test_ok = [Path('../rougail-tests/structures/40_2leadership_calculation_index')]
|
# test_ok = [Path('../rougail-tests/structures/60_6family_dynamic_sub_dynamic_1_0_2')]
|
||||||
|
|
||||||
|
|
||||||
def idfn(fixture_value):
|
def idfn(fixture_value):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue