Compare commits

...

11 commits

10 changed files with 281 additions and 0 deletions

22
CHANGELOG.md Normal file
View file

@ -0,0 +1,22 @@
## 0.1.1rc0 (2024-11-06)
### Fix
- update tiramisu_cmdline_parser dans rougail dependencies
- do not raise if user_data is not present
## 0.1.0 (2024-11-01)
### Fix
- black
## 0.1.0rc0 (2024-10-31)
### Feat
- improvemnt + translation
### Fix
- remove extra options in commandline parser

8
bin/rougail Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env python3
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())

Binary file not shown.

View 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
View 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 ""

44
pyproject.toml Normal file
View file

@ -0,0 +1,44 @@
[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail.cli"
version = "0.1.1"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "CLI for Rougail"
requires-python = ">=3.8"
license = {file = "LICENSE"}
classifiers = [
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Natural Language :: English",
"Natural Language :: French",
]
dependencies = [
"rougail >= 1.1,<2",
"tiramisu_cmdline_parser >= 0.6,<1",
]
[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
changelog_merge_prerelease = true

View file

@ -0,0 +1,17 @@
"""
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/>.
"""

108
src/rougail/cli/__main__.py Normal file
View file

@ -0,0 +1,108 @@
"""
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 import Config
from pathlib import Path
from rougail import Rougail, PropertiesOptionError
from rougail.config import get_rougail_config
from rougail.update import RougailUpgrade
from rougail.utils import load_modules
from .i18n import _
def _main():
rougailconfig = get_rougail_config(
backward_compatibility=False, add_extra_options=False
)
cmd_config = rougailconfig.config
cmd_config.property.read_write()
cmd_config.property.add("not_for_commandline")
parser = TiramisuCmdlineParser(
cmd_config,
add_extra_options=False,
short_name_max_len=2,
)
parser.parse_args()
cmd_config.property.remove("not_for_commandline")
cmd_config.property.read_only()
if rougailconfig["upgrade"]:
RougailUpgrade(rougailconfig=rougailconfig).run()
return
try:
user_data_names = rougailconfig["step.user_data"]
except PropertiesOptionError:
user_data_names = []
output_name = rougailconfig["step.output"]
# structural
rougail = Rougail(rougailconfig)
for user_data_name in user_data_names:
rougail.converted.plugins.append("user_data_" + user_data_name)
rougail.converted.plugins.append("output_" + output_name)
config = rougail.get_config()
# data user
if not user_data_names:
user_datas = None
else:
config.property.read_write()
user_datas = []
for user_data_name in user_data_names:
path = (
Path(__file__).parent.parent
/ ("user_data_" + user_data_name)
/ "__init__.py"
)
if not path.is_file():
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) / "__init__.py"
if not path.is_file():
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)

24
src/rougail/cli/i18n.py Normal file
View file

@ -0,0 +1,24 @@
"""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

Binary file not shown.