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)
### 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]
name = "rougail.output_formatter"
version = "0.1.0a16"
version = "0.1.0a17"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "Rougail output formatter"

View file

@ -57,13 +57,10 @@ from rougail.tiramisu import normalize_family, RENAME_TYPE
from rougail.utils import undefined
from .upgrade import RougailUpgrade
from .i18n import _
from .__version__ import __version__
def _(text):
return text
# XXX explicit null
def represent_none(self, data):
return self.represent_scalar("tag:yaml.org,2002:null", "null")
@ -119,6 +116,8 @@ class RougailOutputFormatter:
self.attributes = {}
self.yaml = YAML()
self.yaml.width = self.rougailconfig["formatter.line_width"]
self.conv_yaml = YAML()
def run(self):
self.upgrade()
@ -391,6 +390,15 @@ class RougailOutputFormatter:
else:
ret[name] = default
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:
description = variable["description"].strip()
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 .i18n import _
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
options = """
options = f"""
load_unexist_redefine:
redefine: true
type: boolean
default:
jinja: >-
{% if step.output is not propertyerror and step.output == 'formatter' %}
{{% if step.output is not propertyerror and step.output == 'formatter' %}}
true
{% else %}
{{% else %}}
false
{% endif %}
{{% endif %}}
hidden:
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
{% endif %}
{{% endif %}}
cli:
@ -48,11 +49,16 @@ cli:
type: boolean
default:
jinja: >-
{% if step.output is not propertyerror and step.output == 'formatter' %}
{{% if step.output is not propertyerror and step.output == 'formatter' %}}
false
{% else %}
{{% else %}}
true
{% endif %}
{{% endif %}}
formatter:
description: {_('Configuration for rougail-ouput-formatter')}
line_width: 120 # {_('Line size')}
"""
return {
"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
var6: value # the sixth variable
var7: '8080' # the seventh variable
var8: 'true' # the height variable
...