From df5f3b67829b69dc5e8cb434a4b819cd075bb3e9 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 11 Jun 2026 08:09:04 +0200 Subject: [PATCH] fix: without namespace --- src/rougail/output_table/__init__.py | 55 +++++++++++++++------------- src/rougail/output_table/config.py | 2 +- src/rougail/output_table/i18n.py | 2 +- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/rougail/output_table/__init__.py b/src/rougail/output_table/__init__.py index 32d45bf..c902f7d 100644 --- a/src/rougail/output_table/__init__.py +++ b/src/rougail/output_table/__init__.py @@ -1,6 +1,6 @@ """ Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -28,7 +28,7 @@ from .i18n import _ from .__version__ import __version__ -TABULATE = {"console": "plain", +TABULATE = {"console": "heavy_grid", "html": "unsafehtml", } ENTER = {"github": '
'} @@ -57,11 +57,7 @@ class RougailOutputTable: ) self.rougailconfig = rougailconfig self.config = config - try: - groups.namespace - self.support_namespace = True - except AttributeError: - self.support_namespace = False + self.support_namespace = rougailconfig["main_namespace"] is not None if user_data_errors: self.errors = user_data_errors.copy() else: @@ -80,7 +76,8 @@ class RougailOutputTable: self.columns = self.rougailconfig["table.columns"].copy() self.first_column = self.rougailconfig["table.first_column"] if self.first_column == 'namespace': - self.columns.insert(0, 'namespace') + if self.support_namespace: + self.columns.insert(0, 'namespace') else: self.columns.insert(0, 'description') for option in self.config: @@ -88,7 +85,10 @@ class RougailOutputTable: namespace = option.description() else: namespace = "" - self.walk(option, namespace) + if option.isoptiondescription(): + self.walk(option, namespace) + else: + self.manage(option, namespace) if self.rougailconfig["table.header"]: headers = tuple([col.capitalize() for col in self.columns]) else: @@ -117,23 +117,26 @@ class RougailOutputTable: def walk(self, config, namespace): for option in config: - if option.isoptiondescription(): - self.walk(option, namespace) - tags = option.information.get('tags', []) - if not tags: - continue - for col in self.columns: - if col in tags: - value = option.value.get() - if self.first_column == 'namespace': - key = namespace - else: - key = option.description() - if isinstance(value, list): - self.datas.setdefault(key, {}).setdefault(col, []).extend([str(val) for val in value]) - else: - self.datas.setdefault(key, {}).setdefault(col, []).append(str(value)) - self.datas[key][self.first_column] = [key] + self.manage(option, namespace) + + def manage(self, option, namespace): + if option.isoptiondescription(): + self.walk(option, namespace) + tags = option.information.get('tags', []) + if not tags: + return + for col in self.columns: + if col in tags: + value = option.value.get() + if self.first_column == 'namespace': + key = namespace + else: + key = option.description() + if isinstance(value, list): + self.datas.setdefault(key, {}).setdefault(col, []).extend([str(val) for val in value]) + else: + self.datas.setdefault(key, {}).setdefault(col, []).append(str(value)) + self.datas[key][self.first_column] = [key] RougailOutput = RougailOutputTable diff --git a/src/rougail/output_table/config.py b/src/rougail/output_table/config.py index bb3bee4..a69e4be 100644 --- a/src/rougail/output_table/config.py +++ b/src/rougail/output_table/config.py @@ -1,6 +1,6 @@ """ Silique (https://www.silique.fr) -Copyright (C) 2025 +Copyright (C) 2025-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/output_table/i18n.py b/src/rougail/output_table/i18n.py index f6b7d4a..60a0cab 100644 --- a/src/rougail/output_table/i18n.py +++ b/src/rougail/output_table/i18n.py @@ -1,6 +1,6 @@ """Internationalisation utilities Silique (https://www.silique.fr) -Copyright (C) 2025 +Copyright (C) 2025-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the