From 601f84277223ebf5afaf3ad7b7996d494937fafd Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 19 Dec 2025 13:34:58 +0100 Subject: [PATCH] fix: better namespace support --- src/rougail/output_json/__init__.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/rougail/output_json/__init__.py b/src/rougail/output_json/__init__.py index f8f38ef..d5ce460 100644 --- a/src/rougail/output_json/__init__.py +++ b/src/rougail/output_json/__init__.py @@ -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,