fix: black

This commit is contained in:
egarette@silique.fr 2024-11-01 10:34:46 +01:00
parent d0b0d5691c
commit 09c158bf01
4 changed files with 61 additions and 35 deletions

View file

@ -5,16 +5,28 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail.cli" name = "rougail.cli"
version = "0.1.0rc0" version = "0.1.0rc0"
authors = [ authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
{name = "Emmanuel Garette", email = "gnunux@gnunux.info"},
]
readme = "README.md" readme = "README.md"
description = "CLI for Rougail" description = "CLI for Rougail"
requires-python = ">=3.8"
license = {file = "LICENSE"} license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"] 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 = [ dependencies = [
"rougail ~= 1.1.0", "rougail ~= 1.1.0",
"tiramisu_cmdline_parser ~= 0.6.0",
] ]
[project.scripts] [project.scripts]
@ -29,3 +41,4 @@ tag_format = "$version"
version_scheme = "pep440" version_scheme = "pep440"
version_provider = "pep621" version_provider = "pep621"
update_changelog_on_bump = true update_changelog_on_bump = true
changelog_merge_prerelease = true

View file

@ -15,4 +15,3 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Mtools. If not, see <http://www.gnu.org/licenses/>. along with Mtools. If not, see <http://www.gnu.org/licenses/>.
""" """

View file

@ -29,27 +29,30 @@ 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()
cmd_config.property.add('not_for_commandline') cmd_config.property.add("not_for_commandline")
parser = TiramisuCmdlineParser(cmd_config, parser = TiramisuCmdlineParser(
cmd_config,
add_extra_options=False, add_extra_options=False,
short_name_max_len=2, short_name_max_len=2,
) )
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']: if rougailconfig["upgrade"]:
RougailUpgrade(rougailconfig=rougailconfig).run() RougailUpgrade(rougailconfig=rougailconfig).run()
return 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
rougail = Rougail(rougailconfig) rougail = Rougail(rougailconfig)
for user_data_name in user_data_names: for user_data_name in user_data_names:
rougail.converted.plugins.append('user_data_' + user_data_name) rougail.converted.plugins.append("user_data_" + user_data_name)
rougail.converted.plugins.append('output_' + output_name) rougail.converted.plugins.append("output_" + output_name)
config = rougail.get_config() config = rougail.get_config()
# data user # data user
if not user_data_names: if not user_data_names:
@ -58,27 +61,39 @@ def _main():
config.property.read_write() config.property.read_write()
user_datas = [] user_datas = []
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) / '__init__.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(_('cannot find "user_data" module "{0}"').format(user_data_name)) raise Exception(
module = load_modules('rougail.user_data_' + user_data_name, str(path)) _('cannot find "user_data" module "{0}"').format(user_data_name)
user_datas.extend(module.RougailUserData(config, )
module = load_modules("rougail.user_data_" + user_data_name, str(path))
user_datas.extend(
module.RougailUserData(
config,
rougailconfig=rougailconfig, rougailconfig=rougailconfig,
).run()) ).run()
)
if user_datas: if user_datas:
err_warn = rougail.user_datas(user_datas) err_warn = rougail.user_datas(user_datas)
else: else:
err_warn = {'errors': [], 'warnings': []} err_warn = {"errors": [], "warnings": []}
# output # output
config.property.read_only() config.property.read_only()
path = Path(__file__).parent.parent / ('output_' + output_name) / '__init__.py' path = Path(__file__).parent.parent / ("output_" + output_name) / "__init__.py"
if not path.is_file(): if not path.is_file():
raise Exception(_('cannot find cli file for "output_name" module "{0}"').format(output_name)) raise Exception(
module = load_modules('rougail.output_' + output_name, str(path)) _('cannot find cli file for "output_name" module "{0}"').format(output_name)
module.RougailOutput(config=config, )
module = load_modules("rougail.output_" + output_name, str(path))
module.RougailOutput(
config=config,
rougailconfig=rougailconfig, rougailconfig=rougailconfig,
user_data_errors = err_warn['errors'], user_data_errors=err_warn["errors"],
user_data_warnings = err_warn['warnings'], user_data_warnings=err_warn["warnings"],
).run() ).run()
@ -86,5 +101,5 @@ def main():
try: try:
_main() _main()
except Exception as err: except Exception as err:
print(_('ERROR: {0}').format(err)) print(_("ERROR: {0}").format(err))
exit(1) exit(1)

View file

@ -19,7 +19,6 @@ along with Mtools. If not, see <http://www.gnu.org/licenses/>.
from gettext import translation from gettext import translation
from pathlib import Path from pathlib import Path
t = translation('rougail_cli', str(Path(__file__).parent / 'locale')) t = translation("rougail_cli", str(Path(__file__).parent / "locale"))
_ = t.gettext _ = t.gettext