Compare commits

..

No commits in common. "148e55c80d8e98a8cbaed0ed43a1c21b136e0743" and "4ef86366796c71c2ad6b4d7a446b973dbdd95677" have entirely different histories.

12 changed files with 24 additions and 55 deletions

View file

@ -1,9 +1,3 @@
## 1.0.1 (2026-07-06)
### Fix
- output json is more modular for hcl
## 1.0.0 (2026-06-21)
### Feat

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail.output_json"
version = "1.0.1"
version = "1.0.0"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "Rougail output json"

View file

@ -126,58 +126,49 @@ class RougailOutputJson:
def parse_family(
self,
parent,
parent_obj,
conf,
child,
namespace,
):
for child in parent:
if child.isoptiondescription():
if child.isleadership():
child_obj = []
for option in conf:
if option.isoptiondescription():
if option.isleadership():
parent = []
self.parse_sequence(
child,
child_obj,
option,
parent,
)
else:
if (
namespace is None
and self.support_namespace
and child.group_type() is groups.namespace
and option.group_type() is groups.namespace
):
subnamespace = child.name()
subnamespace = option.name()
else:
subnamespace = namespace
child_obj = self.get_default_family(child)
self.parse_family(child, child_obj, subnamespace)
self.family_informations(parent, parent_obj, child, child_obj)
parent = {}
self.parse_family(option, parent, subnamespace)
child[option.name()] = parent
else:
self.variable_informations(parent_obj, child)
child[option.name()] = option.value.get()
def parse_sequence(
self,
child,
obj,
conf,
parent,
):
leader, *followers = list(child)
leader, *followers = list(conf)
leader_values = leader.value.get()
for idx, leader_value in enumerate(leader_values):
leader_dict = {leader.name(): leader_value}
obj.append(leader_dict)
parent.append(leader_dict)
for follower in list(followers):
if follower.index() != idx:
continue
followers.remove(follower)
leader_dict[follower.name()] = follower.value.get()
def get_default_family(self, child):
return dict()
def family_informations(self, parent, parent_obj, child, child_obj):
parent_obj[child.name()] = child_obj
def variable_informations(self, parent_obj, child):
parent_obj[child.name()] = child.value.get()
RougailOutput = RougailOutputJson

View file

@ -1 +1 @@
__version__ = "1.0.1"
__version__ = "1.0.0"

View file

@ -1,5 +1,4 @@
{
"var1": "string1",
"var2": "string1",
"var3": "string1"
"var2": "string1"
}

View file

@ -4,8 +4,5 @@
},
"family2": {
"var": "string1"
},
"family3": {
"var": "string1"
}
}

View file

@ -1,7 +1,6 @@
{
"rougail": {
"var1": "string1",
"var2": "string1",
"var3": "string1"
"var2": "string1"
}
}

View file

@ -5,9 +5,6 @@
},
"family2": {
"var": "string1"
},
"family3": {
"var": "string1"
}
}
}

View file

@ -1,7 +1,6 @@
{
"rougail": {
"var1": null,
"var2": null,
"var3": null
"var2": null
}
}

View file

@ -5,9 +5,6 @@
},
"family2": {
"var": null
},
"family3": {
"var": null
}
}
}

View file

@ -1,5 +1,4 @@
{
"var1": null,
"var2": null,
"var3": null
"var2": null
}

View file

@ -4,8 +4,5 @@
},
"family2": {
"var": null
},
"family3": {
"var": null
}
}