From 553c905e89105929a137ad4b9fb360d73ef7631d Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 31 Oct 2024 10:01:39 +0100 Subject: [PATCH] feat: improvemnt + translation --- bin/rougail | 1 + locale/fr/LC_MESSAGES/rougail_cli.mo | Bin 0 -> 588 bytes locale/fr/LC_MESSAGES/rougail_cli.po | 29 ++++++++ locale/rougail_cli.pot | 29 ++++++++ pyproject.toml | 31 ++++++++ src/rougail/cli/__init__.py | 18 +++++ src/rougail/cli/__main__.py | 70 +++++++++++++----- src/rougail/cli/i18n.py | 25 +++++++ .../cli/locale/fr/LC_MESSAGES/rougail_cli.mo | Bin 0 -> 588 bytes 9 files changed, 185 insertions(+), 18 deletions(-) create mode 100644 locale/fr/LC_MESSAGES/rougail_cli.mo create mode 100644 locale/fr/LC_MESSAGES/rougail_cli.po create mode 100644 locale/rougail_cli.pot create mode 100644 pyproject.toml create mode 100644 src/rougail/cli/i18n.py create mode 100644 src/rougail/cli/locale/fr/LC_MESSAGES/rougail_cli.mo diff --git a/bin/rougail b/bin/rougail index 6e12c78..67a2eae 100755 --- a/bin/rougail +++ b/bin/rougail @@ -2,6 +2,7 @@ import re import sys from rougail.cli.__main__ import main + if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main()) diff --git a/locale/fr/LC_MESSAGES/rougail_cli.mo b/locale/fr/LC_MESSAGES/rougail_cli.mo new file mode 100644 index 0000000000000000000000000000000000000000..c627c5a7ed354b1254754d898220dc8356d343ef GIT binary patch literal 588 zcmZXQ&q~8U5XR%bOZ4Q~!w@_vTQ^ogqJpSZ1WQY(;z5u#nbehbH*O}yqCSQX;4_I= z@kInDR?^_uR^{rN2&Jfp z5Xwl(Wf@B8AFF~y$0<|v6j{fe$I5g|)kV=k)gL=YkU773)NK5032V~dvxd;{jA718 z2yba6?!hiK68M^mvoj36I&k*Z;} zdW54^L^!T<0OWW#|9zCl7O5o2MFxlx4UD8kDUH5&2)05(Lv>V NZc8`b{>%N*fDa;trDXsB literal 0 HcmV?d00001 diff --git a/locale/fr/LC_MESSAGES/rougail_cli.po b/locale/fr/LC_MESSAGES/rougail_cli.po new file mode 100644 index 0000000..5178386 --- /dev/null +++ b/locale/fr/LC_MESSAGES/rougail_cli.po @@ -0,0 +1,29 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2024-10-31 09:57+0100\n" +"PO-Revision-Date: 2024-10-31 10:00+0100\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.5\n" + +#: src/rougail/cli/__main__.py:43 +msgid "cannot find \"user_data\" module \"{0}\"" +msgstr "ne peut trouve le module \"user_data\" \"{0}\"" + +#: src/rougail/cli/__main__.py:56 +msgid "cannot find cli file for \"output_name\" module \"{0}\"" +msgstr "ne peut trouve le fichier cli pour le module \"output_name\" \"{0}\"" + +#: src/rougail/cli/__main__.py:69 +msgid "ERROR: {0}" +msgstr "ERREUR : {0}" diff --git a/locale/rougail_cli.pot b/locale/rougail_cli.pot new file mode 100644 index 0000000..f93a543 --- /dev/null +++ b/locale/rougail_cli.pot @@ -0,0 +1,29 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2024-10-31 19:17+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \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/cli/__main__.py:63 +msgid "cannot find \"user_data\" module \"{0}\"" +msgstr "" + +#: src/rougail/cli/__main__.py:76 +msgid "cannot find cli file for \"output_name\" module \"{0}\"" +msgstr "" + +#: src/rougail/cli/__main__.py:89 +msgid "ERROR: {0}" +msgstr "" + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a250dc0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,31 @@ +[build-system] +build-backend = "flit_core.buildapi" +requires = ["flit_core >=3.8.0,<4"] + +[project] +name = "rougail.cli" +version = "0.0.0" +authors = [ + {name = "Emmanuel Garette", email = "gnunux@gnunux.info"}, +] +readme = "README.md" +description = "CLI for Rougail" +license = {file = "LICENSE"} +classifiers = ["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"] + +dependencies = [ + "rougail ~= 1.1.0", +] + +[project.scripts] +rougail = "rougail.cli.__main__:main" + +[project.urls] +Home = "https://forge.cloud.silique.fr/stove/rougail-cli" + +[tool.commitizen] +name = "cz_conventional_commits" +tag_format = "$version" +version_scheme = "pep440" +version_provider = "pep621" +update_changelog_on_bump = true diff --git a/src/rougail/cli/__init__.py b/src/rougail/cli/__init__.py index e69de29..4289faf 100644 --- a/src/rougail/cli/__init__.py +++ b/src/rougail/cli/__init__.py @@ -0,0 +1,18 @@ +""" +Silique (https://www.silique.fr) +Copyright (C) 2024 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mtools 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mtools. If not, see . +""" + diff --git a/src/rougail/cli/__main__.py b/src/rougail/cli/__main__.py index 5a226b7..8d8573b 100644 --- a/src/rougail/cli/__main__.py +++ b/src/rougail/cli/__main__.py @@ -1,13 +1,34 @@ +""" +Silique (https://www.silique.fr) +Copyright (C) 2024 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mtools 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mtools. If not, see . +""" + from tiramisu_cmdline_parser import TiramisuCmdlineParser from tiramisu import Config from pathlib import Path from rougail import Rougail from rougail.config import get_rougail_config +from rougail.update import RougailUpgrade from rougail.utils import load_modules +from .i18n import _ -def main(): + +def _main(): rougailconfig = get_rougail_config(backward_compatibility=False, add_extra_options=False) cmd_config = rougailconfig.config cmd_config.property.read_write() @@ -19,6 +40,9 @@ def main(): parser.parse_args() cmd_config.property.remove('not_for_commandline') cmd_config.property.read_only() + if rougailconfig['upgrade']: + RougailUpgrade(rougailconfig=rougailconfig).run() + return user_data_names = rougailconfig['step.user_data'] output_name = rougailconfig['step.output'] # structural @@ -32,25 +56,35 @@ def main(): user_datas = None else: config.property.read_write() - user_datas = {'errors': [], - 'warnings': [], - } + user_datas = [] for user_data_name in user_data_names: - path = Path(__file__).parent.parent / ('user_data_' + user_data_name) / 'cli.py' + path = Path(__file__).parent.parent / ('user_data_' + user_data_name) / '__init__.py' if not path.is_file(): - raise Exception(f'cannot find cli file for "user_data" module "{user_data_name}"') - module = load_modules('rougail.user_data_' + user_data_name + '.cli', str(path)) - module.run(rougailconfig, - config, - user_datas, - ) + raise Exception(_('cannot find "user_data" module "{0}"').format(user_data_name)) + module = load_modules('rougail.user_data_' + user_data_name, str(path)) + user_datas.extend(module.RougailUserData(config, + rougailconfig=rougailconfig, + ).run()) + if user_datas: + err_warn = rougail.user_datas(user_datas) + else: + err_warn = {'errors': [], 'warnings': []} # output config.property.read_only() - path = Path(__file__).parent.parent / ('output_' + output_name) / 'cli.py' + path = Path(__file__).parent.parent / ('output_' + output_name) / '__init__.py' if not path.is_file(): - raise Exception(f'cannot find cli file for "output_name" module "{output_name}"') - module = load_modules('rougail.output_' + output_name + '.cli', str(path)) - module.run(rougailconfig, - config, - user_datas, - ) + raise Exception(_('cannot find cli file for "output_name" module "{0}"').format(output_name)) + module = load_modules('rougail.output_' + output_name, str(path)) + module.RougailOutput(config=config, + rougailconfig=rougailconfig, + user_data_errors = err_warn['errors'], + user_data_warnings = err_warn['warnings'], + ).run() + + +def main(): + try: + _main() + except Exception as err: + print(_('ERROR: {0}').format(err)) + exit(1) diff --git a/src/rougail/cli/i18n.py b/src/rougail/cli/i18n.py new file mode 100644 index 0000000..1197dcb --- /dev/null +++ b/src/rougail/cli/i18n.py @@ -0,0 +1,25 @@ +"""Internationalisation utilities +Silique (https://www.silique.fr) +Copyright (C) 2024 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mtools 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mtools. If not, see . +""" + +from gettext import translation +from pathlib import Path + +t = translation('rougail_cli', str(Path(__file__).parent / 'locale')) + +_ = t.gettext + diff --git a/src/rougail/cli/locale/fr/LC_MESSAGES/rougail_cli.mo b/src/rougail/cli/locale/fr/LC_MESSAGES/rougail_cli.mo new file mode 100644 index 0000000000000000000000000000000000000000..c627c5a7ed354b1254754d898220dc8356d343ef GIT binary patch literal 588 zcmZXQ&q~8U5XR%bOZ4Q~!w@_vTQ^ogqJpSZ1WQY(;z5u#nbehbH*O}yqCSQX;4_I= z@kInDR?^_uR^{rN2&Jfp z5Xwl(Wf@B8AFF~y$0<|v6j{fe$I5g|)kV=k)gL=YkU773)NK5032V~dvxd;{jA718 z2yba6?!hiK68M^mvoj36I&k*Z;} zdW54^L^!T<0OWW#|9zCl7O5o2MFxlx4UD8kDUH5&2)05(Lv>V NZc8`b{>%N*fDa;trDXsB literal 0 HcmV?d00001