Compare commits

..

3 commits

10 changed files with 145 additions and 16 deletions

View file

@ -1,3 +1,13 @@
## 0.1.0a17 (2025-09-29)
### Feat
- param line size
### Fix
- support numeric string
## 0.1.0a16 (2025-09-29) ## 0.1.0a16 (2025-09-29)
### Feat ### Feat

View file

@ -0,0 +1,37 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2025-09-29 11:38+0200\n"
"PO-Revision-Date: 2025-09-29 11:46+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.7\n"
#: src/rougail/output_formatter/__init__.py:105
msgid "the \"step.output\" is not set to \"{0}\""
msgstr "\"step.output\" n'est pas défini pour \"{0}\""
#: src/rougail/output_formatter/__init__.py:155
msgid "only one file is allowed"
msgstr "seulement un fichier est autorisé"
#: src/rougail/output_formatter/__init__.py:158
msgid "only a file is allowed"
msgstr "seulement un fichier est autorisé"
#: src/rougail/output_formatter/config.py:59
msgid "Configuration for rougail-ouput-formatter"
msgstr "Configuration pour rougail-ouput-formatter"
#: src/rougail/output_formatter/config.py:61
msgid "Line size"
msgstr "Taille des lignes"

View file

@ -0,0 +1,37 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-09-29 11:47+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: src/rougail/output_formatter/__init__.py:105
msgid "the \"step.output\" is not set to \"{0}\""
msgstr ""
#: src/rougail/output_formatter/__init__.py:155
msgid "only one file is allowed"
msgstr ""
#: src/rougail/output_formatter/__init__.py:158
msgid "only a file is allowed"
msgstr ""
#: src/rougail/output_formatter/config.py:59
msgid "Configuration for rougail-ouput-formatter"
msgstr ""
#: src/rougail/output_formatter/config.py:61
msgid "Line size"
msgstr ""

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail.output_formatter" name = "rougail.output_formatter"
version = "0.1.0a16" version = "0.1.0a17"
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 formatter" description = "Rougail output formatter"

View file

@ -1,7 +1,7 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024-2025
This program is free software: you can redistribute it and/or modify it 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 under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your Free Software Foundation, either version 3 of the License, or (at your
@ -57,13 +57,10 @@ from rougail.tiramisu import normalize_family, RENAME_TYPE
from rougail.utils import undefined from rougail.utils import undefined
from .upgrade import RougailUpgrade from .upgrade import RougailUpgrade
from .i18n import _
from .__version__ import __version__ from .__version__ import __version__
def _(text):
return text
# XXX explicit null # XXX explicit null
def represent_none(self, data): def represent_none(self, data):
return self.represent_scalar("tag:yaml.org,2002:null", "null") return self.represent_scalar("tag:yaml.org,2002:null", "null")
@ -119,6 +116,8 @@ class RougailOutputFormatter:
self.attributes = {} self.attributes = {}
self.yaml = YAML() self.yaml = YAML()
self.yaml.width = self.rougailconfig["formatter.line_width"]
self.conv_yaml = YAML()
def run(self): def run(self):
self.upgrade() self.upgrade()
@ -391,6 +390,15 @@ class RougailOutputFormatter:
else: else:
ret[name] = default ret[name] = default
add_column += len(str(default)) + 1 add_column += len(str(default)) + 1
if isinstance(default, str):
# some entries have ' (like '8080') those characters are not count, so add it
with BytesIO() as ymlfh:
self.conv_yaml.dump(default, ymlfh)
ret2 = ymlfh.getvalue().decode("utf-8").strip()
if ret2.endswith("..."):
ret2 = ret2[:-3].strip()
if default != ret2:
add_column += len(ret2) - len(default)
if "description" in variable: if "description" in variable:
description = variable["description"].strip() description = variable["description"].strip()
if self.remaining and (not multi or not default): if self.remaining and (not multi or not default):

View file

@ -1 +1 @@
__version__ = "0.1.0a16" __version__ = "0.1.0a17"

View file

@ -17,28 +17,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
from pathlib import Path from pathlib import Path
from .i18n import _
def get_rougail_config( def get_rougail_config(
*, *,
backward_compatibility=True, backward_compatibility=True,
) -> dict: ) -> dict:
options = """ options = f"""
load_unexist_redefine: load_unexist_redefine:
redefine: true redefine: true
type: boolean type: boolean
default: default:
jinja: >- jinja: >-
{% if step.output is not propertyerror and step.output == 'formatter' %} {{% if step.output is not propertyerror and step.output == 'formatter' %}}
true true
{% else %} {{% else %}}
false false
{% endif %} {{% endif %}}
hidden: hidden:
jinja: >- jinja: >-
{% if step.output is not propertyerror and step.output == 'formatter' %} {{% if step.output is not propertyerror and step.output == 'formatter' %}}
load_unexist_redefine is always true with 'formatter' output load_unexist_redefine is always true with 'formatter' output
{% endif %} {{% endif %}}
cli: cli:
@ -48,11 +49,16 @@ cli:
type: boolean type: boolean
default: default:
jinja: >- jinja: >-
{% if step.output is not propertyerror and step.output == 'formatter' %} {{% if step.output is not propertyerror and step.output == 'formatter' %}}
false false
{% else %} {{% else %}}
true true
{% endif %} {{% endif %}}
formatter:
description: {_('Configuration for rougail-ouput-formatter')}
line_width: 120 # {_('Line size')}
""" """
return { return {
"name": "formatter", "name": "formatter",

View file

@ -0,0 +1,27 @@
"""Internationalisation utilities
Silique (https://www.silique.fr)
Copyright (C) 2025
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
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from gettext import translation
from pathlib import Path
t = translation(
"rougail_output_formatter", str(Path(__file__).parent / "locale"), fallback=True
)
_ = t.gettext

View file

@ -13,4 +13,8 @@ var4: value # the forth variable
var5: value # the fifth variable var5: value # the fifth variable
var6: value # the sixth variable var6: value # the sixth variable
var7: '8080' # the seventh variable
var8: 'true' # the height variable
... ...