fix: better namespace support

This commit is contained in:
egarette@silique.fr 2025-12-19 13:34:58 +01:00
parent 5f17a1f086
commit 601f842772

View file

@ -20,6 +20,7 @@ from typing import Any, List, Optional
from json import dumps
from tiramisu import groups
from tiramisu.error import PropertiesOptionError, ConfigError
from rougail.error import ExtensionError
@ -50,6 +51,11 @@ class RougailOutputJson:
)
self.rougailconfig = rougailconfig
self.config = config
try:
groups.namespace
self.support_namespace = True
except AttributeError:
self.support_namespace = False
if user_data_errors:
self.errors = user_data_errors
else:
@ -81,8 +87,6 @@ class RougailOutputJson:
self.config.property.read_write()
self.mandatory()
self.config.property.importation(ori_properties)
if self.manage_errors():
return False
self.manage_warnings()
if self.get:
config = self.config.option(self.get)
@ -94,8 +98,9 @@ class RougailOutputJson:
self.parse_family(
config,
self.dico,
None,
)
return True
return self.manage_errors()
def mandatory(self):
title = False
@ -144,6 +149,7 @@ class RougailOutputJson:
self,
conf,
child,
namespace,
):
for option in conf:
if option.isoptiondescription():
@ -154,11 +160,18 @@ class RougailOutputJson:
parent,
)
else:
if namespace is None and self.support_namespace and option.group_type() is groups.namespace:
subnamespace = option.name()
else:
subnamespace = namespace
parent = {}
self.parse_family(option, parent)
self.parse_family(option, parent, subnamespace)
child[option.name()] = parent
else:
child[option.name()] = option.value.get()
self.parse_variable(option, child)
def parse_variable(self, option, child):
child[option.name()] = option.value.get()
def parse_leadership(
self,