feat: improvemnt + translation
This commit is contained in:
parent
998d84863b
commit
553c905e89
9 changed files with 185 additions and 18 deletions
|
@ -2,6 +2,7 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from rougail.cli.__main__ import main
|
from rougail.cli.__main__ import main
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
BIN
locale/fr/LC_MESSAGES/rougail_cli.mo
Normal file
BIN
locale/fr/LC_MESSAGES/rougail_cli.mo
Normal file
Binary file not shown.
29
locale/fr/LC_MESSAGES/rougail_cli.po
Normal file
29
locale/fr/LC_MESSAGES/rougail_cli.po
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR ORGANIZATION
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 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}"
|
29
locale/rougail_cli.pot
Normal file
29
locale/rougail_cli.pot
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR ORGANIZATION
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 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 <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/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 ""
|
||||||
|
|
31
pyproject.toml
Normal file
31
pyproject.toml
Normal file
|
@ -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
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
||||||
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
||||||
from tiramisu import Config
|
from tiramisu import Config
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rougail import Rougail
|
from rougail import Rougail
|
||||||
from rougail.config import get_rougail_config
|
from rougail.config import get_rougail_config
|
||||||
|
from rougail.update import RougailUpgrade
|
||||||
from rougail.utils import load_modules
|
from rougail.utils import load_modules
|
||||||
|
|
||||||
|
from .i18n import _
|
||||||
|
|
||||||
def main():
|
|
||||||
|
def _main():
|
||||||
rougailconfig = get_rougail_config(backward_compatibility=False, add_extra_options=False)
|
rougailconfig = get_rougail_config(backward_compatibility=False, add_extra_options=False)
|
||||||
cmd_config = rougailconfig.config
|
cmd_config = rougailconfig.config
|
||||||
cmd_config.property.read_write()
|
cmd_config.property.read_write()
|
||||||
|
@ -19,6 +40,9 @@ def main():
|
||||||
parser.parse_args()
|
parser.parse_args()
|
||||||
cmd_config.property.remove('not_for_commandline')
|
cmd_config.property.remove('not_for_commandline')
|
||||||
cmd_config.property.read_only()
|
cmd_config.property.read_only()
|
||||||
|
if rougailconfig['upgrade']:
|
||||||
|
RougailUpgrade(rougailconfig=rougailconfig).run()
|
||||||
|
return
|
||||||
user_data_names = rougailconfig['step.user_data']
|
user_data_names = rougailconfig['step.user_data']
|
||||||
output_name = rougailconfig['step.output']
|
output_name = rougailconfig['step.output']
|
||||||
# structural
|
# structural
|
||||||
|
@ -32,25 +56,35 @@ def main():
|
||||||
user_datas = None
|
user_datas = None
|
||||||
else:
|
else:
|
||||||
config.property.read_write()
|
config.property.read_write()
|
||||||
user_datas = {'errors': [],
|
user_datas = []
|
||||||
'warnings': [],
|
|
||||||
}
|
|
||||||
for user_data_name in user_data_names:
|
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():
|
if not path.is_file():
|
||||||
raise Exception(f'cannot find cli file for "user_data" module "{user_data_name}"')
|
raise Exception(_('cannot find "user_data" module "{0}"').format(user_data_name))
|
||||||
module = load_modules('rougail.user_data_' + user_data_name + '.cli', str(path))
|
module = load_modules('rougail.user_data_' + user_data_name, str(path))
|
||||||
module.run(rougailconfig,
|
user_datas.extend(module.RougailUserData(config,
|
||||||
config,
|
rougailconfig=rougailconfig,
|
||||||
user_datas,
|
).run())
|
||||||
)
|
if user_datas:
|
||||||
|
err_warn = rougail.user_datas(user_datas)
|
||||||
|
else:
|
||||||
|
err_warn = {'errors': [], 'warnings': []}
|
||||||
# output
|
# output
|
||||||
config.property.read_only()
|
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():
|
if not path.is_file():
|
||||||
raise Exception(f'cannot find cli file for "output_name" module "{output_name}"')
|
raise Exception(_('cannot find cli file for "output_name" module "{0}"').format(output_name))
|
||||||
module = load_modules('rougail.output_' + output_name + '.cli', str(path))
|
module = load_modules('rougail.output_' + output_name, str(path))
|
||||||
module.run(rougailconfig,
|
module.RougailOutput(config=config,
|
||||||
config,
|
rougailconfig=rougailconfig,
|
||||||
user_datas,
|
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)
|
||||||
|
|
25
src/rougail/cli/i18n.py
Normal file
25
src/rougail/cli/i18n.py
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from gettext import translation
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
t = translation('rougail_cli', str(Path(__file__).parent / 'locale'))
|
||||||
|
|
||||||
|
_ = t.gettext
|
||||||
|
|
BIN
src/rougail/cli/locale/fr/LC_MESSAGES/rougail_cli.mo
Normal file
BIN
src/rougail/cli/locale/fr/LC_MESSAGES/rougail_cli.mo
Normal file
Binary file not shown.
Loading…
Reference in a new issue