fix: black
This commit is contained in:
parent
d0b0d5691c
commit
09c158bf01
4 changed files with 61 additions and 35 deletions
|
@ -5,16 +5,28 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
[project]
|
||||
name = "rougail.cli"
|
||||
version = "0.1.0rc0"
|
||||
authors = [
|
||||
{name = "Emmanuel Garette", email = "gnunux@gnunux.info"},
|
||||
]
|
||||
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 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 = [
|
||||
"rougail ~= 1.1.0",
|
||||
"tiramisu_cmdline_parser ~= 0.6.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
@ -29,3 +41,4 @@ tag_format = "$version"
|
|||
version_scheme = "pep440"
|
||||
version_provider = "pep621"
|
||||
update_changelog_on_bump = true
|
||||
changelog_merge_prerelease = true
|
||||
|
|
|
@ -15,4 +15,3 @@ 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/>.
|
||||
"""
|
||||
|
||||
|
|
|
@ -29,27 +29,30 @@ from .i18n import _
|
|||
|
||||
|
||||
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.property.read_write()
|
||||
cmd_config.property.add('not_for_commandline')
|
||||
parser = TiramisuCmdlineParser(cmd_config,
|
||||
add_extra_options=False,
|
||||
short_name_max_len=2,
|
||||
)
|
||||
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.remove("not_for_commandline")
|
||||
cmd_config.property.read_only()
|
||||
if rougailconfig['upgrade']:
|
||||
if rougailconfig["upgrade"]:
|
||||
RougailUpgrade(rougailconfig=rougailconfig).run()
|
||||
return
|
||||
user_data_names = rougailconfig['step.user_data']
|
||||
output_name = rougailconfig['step.output']
|
||||
user_data_names = rougailconfig["step.user_data"]
|
||||
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)
|
||||
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:
|
||||
|
@ -58,33 +61,45 @@ def _main():
|
|||
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'
|
||||
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())
|
||||
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': []}
|
||||
err_warn = {"errors": [], "warnings": []}
|
||||
# output
|
||||
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():
|
||||
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()
|
||||
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))
|
||||
print(_("ERROR: {0}").format(err))
|
||||
exit(1)
|
||||
|
|
|
@ -19,7 +19,6 @@ 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 = translation("rougail_cli", str(Path(__file__).parent / "locale"))
|
||||
|
||||
_ = t.gettext
|
||||
|
||||
|
|
Loading…
Reference in a new issue