fix: without namespace

This commit is contained in:
egarette@silique.fr 2026-06-11 08:09:04 +02:00
parent 106357a27c
commit df5f3b6782
3 changed files with 31 additions and 28 deletions

View file

@ -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": '<br/>'}
@ -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

View file

@ -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

View file

@ -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