Compare commits
2 commits
4ef8636679
...
148e55c80d
| Author | SHA1 | Date | |
|---|---|---|---|
| 148e55c80d | |||
| e0449f1931 |
12 changed files with 55 additions and 24 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
## 1.0.1 (2026-07-06)
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- output json is more modular for hcl
|
||||||
|
|
||||||
## 1.0.0 (2026-06-21)
|
## 1.0.0 (2026-06-21)
|
||||||
|
|
||||||
### Feat
|
### Feat
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rougail.output_json"
|
name = "rougail.output_json"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
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 json"
|
description = "Rougail output json"
|
||||||
|
|
|
||||||
|
|
@ -126,49 +126,58 @@ class RougailOutputJson:
|
||||||
|
|
||||||
def parse_family(
|
def parse_family(
|
||||||
self,
|
self,
|
||||||
conf,
|
parent,
|
||||||
child,
|
parent_obj,
|
||||||
namespace,
|
namespace,
|
||||||
):
|
):
|
||||||
for option in conf:
|
for child in parent:
|
||||||
if option.isoptiondescription():
|
if child.isoptiondescription():
|
||||||
if option.isleadership():
|
if child.isleadership():
|
||||||
parent = []
|
child_obj = []
|
||||||
self.parse_sequence(
|
self.parse_sequence(
|
||||||
option,
|
child,
|
||||||
parent,
|
child_obj,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if (
|
if (
|
||||||
namespace is None
|
namespace is None
|
||||||
and self.support_namespace
|
and self.support_namespace
|
||||||
and option.group_type() is groups.namespace
|
and child.group_type() is groups.namespace
|
||||||
):
|
):
|
||||||
subnamespace = option.name()
|
subnamespace = child.name()
|
||||||
else:
|
else:
|
||||||
subnamespace = namespace
|
subnamespace = namespace
|
||||||
parent = {}
|
child_obj = self.get_default_family(child)
|
||||||
self.parse_family(option, parent, subnamespace)
|
self.parse_family(child, child_obj, subnamespace)
|
||||||
child[option.name()] = parent
|
self.family_informations(parent, parent_obj, child, child_obj)
|
||||||
else:
|
else:
|
||||||
child[option.name()] = option.value.get()
|
self.variable_informations(parent_obj, child)
|
||||||
|
|
||||||
def parse_sequence(
|
def parse_sequence(
|
||||||
self,
|
self,
|
||||||
conf,
|
child,
|
||||||
parent,
|
obj,
|
||||||
):
|
):
|
||||||
leader, *followers = list(conf)
|
leader, *followers = list(child)
|
||||||
leader_values = leader.value.get()
|
leader_values = leader.value.get()
|
||||||
for idx, leader_value in enumerate(leader_values):
|
for idx, leader_value in enumerate(leader_values):
|
||||||
leader_dict = {leader.name(): leader_value}
|
leader_dict = {leader.name(): leader_value}
|
||||||
parent.append(leader_dict)
|
obj.append(leader_dict)
|
||||||
for follower in list(followers):
|
for follower in list(followers):
|
||||||
if follower.index() != idx:
|
if follower.index() != idx:
|
||||||
continue
|
continue
|
||||||
followers.remove(follower)
|
followers.remove(follower)
|
||||||
leader_dict[follower.name()] = follower.value.get()
|
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
|
RougailOutput = RougailOutputJson
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__version__ = "1.0.0"
|
__version__ = "1.0.1"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"var1": "string1",
|
"var1": "string1",
|
||||||
"var2": "string1"
|
"var2": "string1",
|
||||||
|
"var3": "string1"
|
||||||
}
|
}
|
||||||
|
|
@ -4,5 +4,8 @@
|
||||||
},
|
},
|
||||||
"family2": {
|
"family2": {
|
||||||
"var": "string1"
|
"var": "string1"
|
||||||
|
},
|
||||||
|
"family3": {
|
||||||
|
"var": "string1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"rougail": {
|
"rougail": {
|
||||||
"var1": "string1",
|
"var1": "string1",
|
||||||
"var2": "string1"
|
"var2": "string1",
|
||||||
|
"var3": "string1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
},
|
},
|
||||||
"family2": {
|
"family2": {
|
||||||
"var": "string1"
|
"var": "string1"
|
||||||
|
},
|
||||||
|
"family3": {
|
||||||
|
"var": "string1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"rougail": {
|
"rougail": {
|
||||||
"var1": null,
|
"var1": null,
|
||||||
"var2": null
|
"var2": null,
|
||||||
|
"var3": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
},
|
},
|
||||||
"family2": {
|
"family2": {
|
||||||
"var": null
|
"var": null
|
||||||
|
},
|
||||||
|
"family3": {
|
||||||
|
"var": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"var1": null,
|
"var1": null,
|
||||||
"var2": null
|
"var2": null,
|
||||||
|
"var3": null
|
||||||
}
|
}
|
||||||
|
|
@ -4,5 +4,8 @@
|
||||||
},
|
},
|
||||||
"family2": {
|
"family2": {
|
||||||
"var": null
|
"var": null
|
||||||
|
},
|
||||||
|
"family3": {
|
||||||
|
"var": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue