Compare commits

...

77 commits

Author SHA1 Message Date
636cd59e7a bump: version 0.2.0a32 → 0.2.0a33 2025-11-21 08:18:34 +01:00
0500688079 feat: add inaccessible_read_write_modes and inaccessible_modes options 2025-11-21 08:18:19 +01:00
5ce01380bf bump: version 0.2.0a31 → 0.2.0a32 2025-11-08 10:04:40 +01:00
004e314c3f fix: execute interactive mode too 2025-11-08 10:04:26 +01:00
8aacb91433 bump: version 0.2.0a30 → 0.2.0a31 2025-11-07 13:05:36 +01:00
e56815f684 fix: better layers support 2025-11-07 13:05:28 +01:00
82df953c70 bump: version 0.2.0a29 → 0.2.0a30 2025-11-07 08:40:40 +01:00
5548144d2d feat: layers information is send to output 2025-11-07 08:40:30 +01:00
67876d77a4 bump: version 0.2.0a28 → 0.2.0a29 2025-11-06 06:32:23 +01:00
ca636fe7a6 feat: choice if invalid value or unknown variable in user data is a fatal error or not 2025-11-06 06:32:13 +01:00
ff58fc056a bump: version 0.2.0a27 → 0.2.0a28 2025-11-03 18:29:06 +01:00
ba82f91cc6 fix: do not display full help to early 2025-11-03 09:20:44 +01:00
ba0b326b56 feat: support layers 2025-11-02 18:44:17 +01:00
fe96019173 bump: version 0.2.0a26 → 0.2.0a27 2025-10-31 06:19:55 +01:00
1af9610734 fix: remove all warnings! 2025-10-31 06:19:45 +01:00
6d3759f3e4 fix: update tests with new output_doc module 2025-10-30 21:18:23 +01:00
b7dbaaa95d bump: version 0.2.0a25 → 0.2.0a26 2025-10-29 11:11:33 +01:00
de98071a53 fix: add default option for environment user datas 2025-10-29 11:11:13 +01:00
d5c229ec50 bump: version 0.2.0a24 → 0.2.0a25 2025-10-27 14:32:24 +01:00
83b20dc0c1 feat: can use .rougailcli.yml, env variable or command line argument from own script 2025-10-27 14:32:15 +01:00
97c87c24d3 bump: version 0.2.0a23 → 0.2.0a24 2025-10-10 08:16:23 +02:00
d9c197ca72 feat: use rougail-user-data-commandline and mix config use data 2025-10-06 21:40:38 +02:00
e0a45ad4a6 fix: remove force_apply_user_data support 2025-10-05 21:37:24 +02:00
52069f00c3 bump: version 0.2.0a22 → 0.2.0a23 2025-10-03 13:31:00 +02:00
358de23cb4 fix: config in read_only mode is asked 2025-10-03 13:30:51 +02:00
6946532f8d bump: version 0.2.0a21 → 0.2.0a22 2025-10-02 22:42:59 +02:00
8c8d16b1dd feat: limit warning when asked 2025-10-02 22:42:53 +02:00
01aa36c1d7 bump: version 0.2.0a20 → 0.2.0a21 2025-09-29 12:17:12 +02:00
dd08fb6e46 feat: add cli.read_write option 2025-09-29 12:16:49 +02:00
27ee7f0f1b bump: version 0.2.0a19 → 0.2.0a20 2025-09-22 14:35:19 +02:00
2e7ba5695f fix: dictionary => structure 2025-09-22 14:35:09 +02:00
e4e0cc987d bump: version 0.2.0a18 → 0.2.0a19 2025-09-03 17:48:27 +02:00
1c34145daf fix: do now set modified option in second round 2025-06-20 07:48:11 +03:00
346401912c bump: version 0.2.0a17 → 0.2.0a18 2025-05-14 08:33:11 +02:00
1576f105e0 feat: able to lad config_file name from environement variable 2025-05-14 08:27:11 +02:00
82e9e5bc30 feat: loads user datas before and after cli params 2025-05-12 19:23:27 +02:00
2bc7e3914c bump: version 0.2.0a16 → 0.2.0a17 2025-05-12 09:13:23 +02:00
c874fa8573 fix: upgrade translation 2025-05-12 08:45:07 +02:00
da6a816713 fix: black 2025-05-11 19:15:11 +02:00
57df91ebee bump: version 0.2.0a15 → 0.2.0a16 2025-05-09 08:23:35 +02:00
8751165a7c fix: description 2025-05-09 07:45:42 +02:00
63b2131908 bump: version 0.2.0a14 → 0.2.0a15 2025-05-05 16:59:45 +02:00
577f354e70 fix: do not raise if warning in cli 2025-05-05 16:59:25 +02:00
10d495c9a8 bump: version 0.2.0a13 → 0.2.0a14 2025-05-02 08:09:23 +02:00
e11885fbd7 fix: do not force use_data usage 2025-05-02 08:09:14 +02:00
9fb4cb8351 bump: version 0.2.0a12 → 0.2.0a13 2025-04-30 09:03:10 +02:00
0102eede49 fix: add first test + remove add_extra_options option in tiramisu-cmdline-parser 2025-04-29 22:54:52 +02:00
05fcb14364 fix: remove negative_description support 2025-04-29 22:53:29 +02:00
aa5c2f773c fix: display user-data instead of user_data in version 2025-04-27 10:30:00 +02:00
f5f85ba79f bump: version 0.2.0a11 → 0.2.0a12 2025-04-09 21:22:44 +02:00
cf0fc37aef fix: version 2025-04-09 21:22:41 +02:00
8ecc0e0f55 bump: version 0.2.0a10 → 0.2.0a11 2025-03-31 16:38:16 +02:00
0f1e1b9ea5 fix: translation 2025-03-31 16:38:01 +02:00
1036ccb358 bump: version 0.2.0a9 → 0.2.0a10 2025-03-31 10:25:20 +02:00
5327ff1917 fix: access to cli.config_file variable with commandline 2025-03-31 10:24:01 +02:00
c31652256f bump: version 0.2.0a8 → 0.2.0a9 2025-03-31 09:30:43 +02:00
8c924a7cba feat: cli loads .rougailcli.yml file 2025-03-31 09:30:29 +02:00
3f2920f37c bump: version 0.2.0a7 → 0.2.0a8 2025-02-17 11:17:43 +01:00
0010c9cf07 fix: add config.py file 2025-02-17 11:17:23 +01:00
fb7c3c3346 bump: version 0.2.0a6 → 0.2.0a7 2025-02-17 10:01:27 +01:00
e6582d6d9d fix: better error support 2025-02-17 10:01:23 +01:00
5cfa351e67 bump: version 0.2.0a5 → 0.2.0a6 2025-02-10 10:00:37 +01:00
e9b1ab5f85 feat: return 1 if output has problems 2025-02-10 10:00:09 +01:00
95da29454a bump: version 0.2.0a4 → 0.2.0a5 2025-02-05 11:58:25 +01:00
a530ff33d6 feat: user_data can be loaded after other plugins 2025-02-05 11:57:06 +01:00
dcbe1a99d6 bump: version 0.2.0a3 → 0.2.0a4 2025-01-04 12:33:31 +01:00
c0d103f2e8 fix: add and remove not_for_commandline property 2025-01-04 12:33:26 +01:00
e87bcbd4c8 bump: version 0.2.0a2 → 0.2.0a3 2025-01-04 12:00:02 +01:00
703b1ce70e fix: remove upgrade feature (now in formatter project) + better support of not_for_commandline feature 2025-01-04 11:59:43 +01:00
60ee2a6feb bump: version 0.2.0a1 → 0.2.0a2 2024-12-11 22:19:57 +01:00
6feebea664 fix: user_data and output are not plugins 2024-12-11 22:19:44 +01:00
b5c845f90c bump: version 0.2.0a0 → 0.2.0a1 2024-11-28 21:47:36 +01:00
c79975c5df fix: separation between run and print function 2024-11-28 21:47:22 +01:00
52cbfc1f15 bump: version 0.1.2a0 → 0.2.0a0 2024-11-27 10:24:53 +01:00
e62797c79f feat: load config from environment if rougail-user-data-environment is installed 2024-11-27 09:20:30 +01:00
8073ef9bc1 bump: version 0.1.1 → 0.1.2a0 2024-11-25 09:20:44 +01:00
ea0076279c fix: translation is not mandatory 2024-11-25 09:18:59 +01:00
39 changed files with 1069 additions and 63 deletions

View file

@ -1,3 +1,226 @@
## 0.2.0a33 (2025-11-21)
### Feat
- add inaccessible_read_write_modes and inaccessible_modes options
## 0.2.0a32 (2025-11-08)
### Fix
- execute interactive mode too
## 0.2.0a31 (2025-11-07)
### Fix
- better layers support
## 0.2.0a30 (2025-11-07)
### Feat
- layers information is send to output
## 0.2.0a29 (2025-11-06)
### Feat
- choice if invalid value or unknown variable in user data is a fatal error or not
## 0.2.0a28 (2025-11-03)
### Feat
- support layers
### Fix
- do not display full help to early
## 0.2.0a27 (2025-10-31)
### Fix
- remove all warnings!
- update tests with new output_doc module
## 0.2.0a26 (2025-10-29)
### Fix
- add default option for environment user datas
## 0.2.0a25 (2025-10-27)
### Feat
- can use .rougailcli.yml, env variable or command line argument from own script
## 0.2.0a24 (2025-10-10)
### Feat
- use rougail-user-data-commandline and mix config use data
### Fix
- remove force_apply_user_data support
## 0.2.0a23 (2025-10-03)
### Fix
- config in read_only mode is asked
## 0.2.0a22 (2025-10-02)
### Feat
- limit warning when asked
## 0.2.0a21 (2025-09-29)
### Feat
- add cli.read_write option
## 0.2.0a20 (2025-09-22)
### Fix
- dictionary => structure
## 0.2.0a19 (2025-09-03)
### Fix
- do now set modified option in second round
## 0.2.0a18 (2025-05-14)
### Feat
- able to lad config_file name from environement variable
- loads user datas before and after cli params
## 0.2.0a17 (2025-05-12)
### Fix
- upgrade translation
- black
## 0.2.0a16 (2025-05-09)
### Fix
- description
## 0.2.0a15 (2025-05-05)
### Fix
- do not raise if warning in cli
## 0.2.0a14 (2025-05-02)
### Fix
- do not force use_data usage
## 0.2.0a13 (2025-04-30)
### Fix
- add first test + remove add_extra_options option in tiramisu-cmdline-parser
- remove negative_description support
- display user-data instead of user_data in version
## 0.2.0a12 (2025-04-09)
### Fix
- version
## 0.2.0a11 (2025-03-31)
### Fix
- translation
## 0.2.0a10 (2025-03-31)
### Fix
- access to cli.config_file variable with commandline
## 0.2.0a9 (2025-03-31)
### Feat
- cli loads .rougailcli.yml file
## 0.2.0a8 (2025-02-17)
### Fix
- add config.py file
## 0.2.0a7 (2025-02-17)
### Fix
- better error support
## 0.2.0a6 (2025-02-10)
### Feat
- return 1 if output has problems
## 0.2.0a5 (2025-02-05)
### Feat
- user_data can be loaded after other plugins
## 0.2.0a4 (2025-01-04)
### Fix
- add and remove not_for_commandline property
## 0.2.0a3 (2025-01-04)
### Fix
- remove upgrade feature (now in formatter project) + better support of not_for_commandline feature
## 0.2.0a2 (2024-12-11)
### Fix
- user_data and output are not plugins
## 0.2.0a1 (2024-11-28)
### Fix
- separation between run and print function
## 0.2.0a0 (2024-11-27)
### Feat
- load config from environment if rougail-user-data-environment is installed
### Fix
- translation is not mandatory
## 0.1.1 (2024-11-06)
## 0.1.1rc0 (2024-11-06)
### Fix

Binary file not shown.

View file

@ -5,8 +5,8 @@
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"
"POT-Creation-Date: 2025-05-14 08:22+0200\n"
"PO-Revision-Date: 2025-05-14 08:22+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
@ -16,14 +16,40 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.5\n"
#: src/rougail/cli/__main__.py:43
#: src/rougail/cli/__main__.py:170
msgid "cannot find \"user_data\" module \"{0}\""
msgstr "ne peut trouve le module \"user_data\" \"{0}\""
#: src/rougail/cli/__main__.py:56
#: src/rougail/cli/__main__.py:214
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
#: src/rougail/cli/__main__.py:240
msgid "ERROR: {0}"
msgstr "ERREUR : {0}"
#: src/rougail/cli/config.py:28
msgid "Command line options"
msgstr "Options de la ligne de commande"
#: src/rougail/cli/config.py:31
msgid "Loads command line parameters from a file"
msgstr "Charger les paramètres de la ligne de commande depuis un fichier"
#: src/rougail/cli/config.py:39
msgid "Displays debug informations"
msgstr "Afficher les informations de debug"
#: src/rougail/cli/config.py:43
msgid "Displays command line option warnings informations"
msgstr "Afficher les avertissements de chargement des options de la ligne de commande"
#: src/rougail/cli/config.py:47
msgid "Displays Rougail version and all its components"
msgstr "Afficher la version de Rougail et de tous ces composants"
#~ msgid "do not display debug informations"
#~ msgstr "ne pas afficher les informations de debug"
#~ msgid "do not display rougail version and all componants"
#~ msgstr "ne pas afficher la version de rougail et de tous ces composants"

View file

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-10-31 19:17+0100\n"
"POT-Creation-Date: 2025-05-14 08:25+0200\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"
@ -15,15 +15,35 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n"
#: src/rougail/cli/__main__.py:63
#: src/rougail/cli/__main__.py:170
msgid "cannot find \"user_data\" module \"{0}\""
msgstr ""
#: src/rougail/cli/__main__.py:76
#: src/rougail/cli/__main__.py:214
msgid "cannot find cli file for \"output_name\" module \"{0}\""
msgstr ""
#: src/rougail/cli/__main__.py:89
#: src/rougail/cli/__main__.py:240
msgid "ERROR: {0}"
msgstr ""
#: src/rougail/cli/config.py:28
msgid "Command line options"
msgstr ""
#: src/rougail/cli/config.py:31
msgid "Loads command line parameters from a file"
msgstr ""
#: src/rougail/cli/config.py:39
msgid "Displays debug informations"
msgstr ""
#: src/rougail/cli/config.py:43
msgid "Displays command line option warnings informations"
msgstr ""
#: src/rougail/cli/config.py:47
msgid "Displays Rougail version and all its components"
msgstr ""

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail.cli"
version = "0.1.1"
version = "0.2.0a33"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "CLI for Rougail"
@ -13,11 +13,10 @@ 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.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Natural Language :: English",
@ -26,7 +25,7 @@ classifiers = [
]
dependencies = [
"rougail >= 1.1,<2",
"tiramisu_cmdline_parser >= 0.6,<1",
"rougail-user-data-commandline",
]
[project.scripts]
@ -40,5 +39,9 @@ name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "pep440"
version_provider = "pep621"
#update_changelog_on_bump = true
version_files = [
"src/rougail/cli/__version__.py",
"pyproject.toml:version"
]
update_changelog_on_bump = true
changelog_merge_prerelease = true

View file

@ -1,6 +1,6 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024
Copyright (C) 2024-2025
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
@ -15,3 +15,5 @@ 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 .__version__ import __version__

View file

@ -1,6 +1,6 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024
Copyright (C) 2024-2025
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
@ -16,54 +16,211 @@ 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
import os
from warnings import filterwarnings
from pathlib import Path
from sys import exit
from warnings import warn
from rougail import Rougail, PropertiesOptionError
from tiramisu_cmdline_parser import TiramisuCmdlineParser
from tiramisu.error import PropertiesOptionError
from tiramisu import MetaConfig
from rougail import Rougail
from rougail.user_datas import UserDatas
from rougail.config import get_rougail_config
from rougail.update import RougailUpgrade
from rougail.utils import load_modules
from rougail.error import RougailWarning
try:
from rougail.user_data_yaml import RougailUserDataYaml
except ImportError:
RougailUserDataYaml = None
try:
from rougail.user_data_environment import RougailUserDataEnvironment
except ImportError:
RougailUserDataEnvironment = None
from .rougailconfig import load as rougailconfig_load
from .i18n import _
def _main():
ENV_PREFIX = "ROUGAILCLI"
def _main(arguments, do_not_print):
global print_traceback
rougailconfig = get_rougail_config(
backward_compatibility=False, add_extra_options=False
)
cmd_config = load_cmd_user_datas(rougailconfig, arguments)
print_traceback = rougailconfig["cli.debug"]
if rougailconfig["cli.versions"]:
versions = display_version(cmd_config)
if do_not_print:
return list(versions)
for version in versions:
print(version)
exit()
layer_datas, metaconfig, config, err_warn = load_user_datas(rougailconfig)
output = get_output(rougailconfig, metaconfig, config, err_warn, layer_datas)
if do_not_print:
return output.run()
ret = output.print()
if ret is False:
exit(1)
def load_cmd_user_datas(rougailconfig, arguments):
rougailconfig.generate_config()
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,
origin_prop = cmd_config.property.default("read_write", "append")
cmd_config.property.setdefault(
frozenset(origin_prop | {"not_for_commandline"}), "read_write", "append"
)
parser.parse_args()
cmd_config.property.remove("not_for_commandline")
cmd_config.property.read_write()
config_file = None
if RougailUserDataYaml:
_config_file = os.environ.pop(f"{ENV_PREFIX}_CLI.CONFIG_FILE", None)
if not _config_file:
_config_file = cmd_config.forcepermissive.option("cli.config_file").value.get()
if Path(_config_file).is_file():
config_file = _config_file
if RougailUserDataEnvironment:
env_prefix = ENV_PREFIX
else:
env_prefix = None
user_data = rougailconfig_load(rougailconfig, config_file, env_prefix, True, _arguments=arguments, _generate=False, _add_help=False)
display_warnings = rougailconfig["cli.warnings"]
manage_warnings(display_warnings)
if not cmd_config.option("cli.versions").value.get():
if display_warnings and user_data["warnings"]:
for warning in user_data["warnings"]:
warn(warning)
if manage_warnings:
# replays to display errors if needed
parser = TiramisuCmdlineParser(
cmd_config,
short_name_max_len=2,
)
parser.parse_args(arguments)
if user_data["errors"]:
raise Exception(user_data["errors"][0])
cmd_config.property.setdefault(origin_prop, "read_write", "append")
cmd_config.property.read_only()
if rougailconfig["upgrade"]:
RougailUpgrade(rougailconfig=rougailconfig).run()
return
cmd_config.property.remove("not_for_commandline")
return cmd_config
def display_version(cmd_config):
versions = []
from tiramisu import __version__
yield(f"tiramisu: {__version__}")
from tiramisu_cmdline_parser import __version__
yield(f"tiramisu-cmdline-parser: {__version__}")
from rougail import __version__
yield(f"rougail: {__version__}")
from . import __version__
yield(f"rougail-cli: {__version__}")
for step in ["structural", "user_data", "output"]:
display_step = step.replace("_", "-")
for step_name in sorted(cmd_config.unrestraint.option(f"step.{step}").value.list()):
path = (
Path(__file__).parent.parent
/ (step + "_" + step_name)
/ "__init__.py"
)
if path.is_file():
try:
module = load_modules(
"rougail." + step + "_" + step_name, str(path)
)
yield(
f"rougail-{display_step}-{step_name}: {module.__version__}"
)
except Exception as err:
pass
def manage_warnings(warnings):
if not warnings:
filterwarnings("ignore", category=DeprecationWarning)
filterwarnings("ignore", category=RougailWarning)
else:
filterwarnings("default", category=DeprecationWarning)
filterwarnings("default", category=RougailWarning)
def load_user_datas(rougailconfig):
layer_datas = {}
if not rougailconfig["cli.load_config"]:
return None, None, None, {"errors": [], "warnings": []}
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
has_layers = rougailconfig["cli.layers"]
if has_layers:
layers = [[ud] for ud in user_data_names]
last_layers = len(layers) - 1
else:
config.property.read_write()
layers = [user_data_names]
last_layers = 0
rougail = Rougail(rougailconfig)
layer_name = "_".join(layers[-1])
subconfig = rougail.run(name=layer_name)
try:
read_write = set()
read_only = set()
if rougailconfig["cli.inaccessible_read_write_modes"]:
read_write = set(rougailconfig["cli.inaccessible_read_write_modes"])
if rougailconfig["cli.inaccessible_modes"]:
read_only = set(rougailconfig["cli.inaccessible_modes"])
read_write |= read_only
if read_write:
subconfig.property.setdefault(
frozenset(subconfig.property.default("read_write", "append") | read_write), "read_write", "append"
)
subconfig.property.setdefault(
frozenset(subconfig.property.default("read_only", "remove") | (read_write - read_only)), "read_only", "remove"
)
subconfig.property.read_write()
if read_only:
subconfig.property.setdefault(
frozenset(subconfig.property.default("read_only", "append") | read_only), "read_only", "append"
)
subconfig.property.read_write()
except:
pass
metaconfig = subconfig
if last_layers:
for layer in layers[:-1]:
layer_name = "_".join(layer)
metaconfig = MetaConfig([metaconfig], name=layer_name)
metaconfig.owner.set(metaconfig.path())
subconfig = metaconfig
err_warn = {"errors": [], "warnings": []}
invalid_user_datas_error = rougailconfig["cli.invalid_user_datas_error"]
unknown_user_datas_error = rougailconfig["cli.unknown_user_datas_error"]
interactive_user_datas = {}
for idx, layer in enumerate(layers):
if idx:
subconfig = subconfig.config("_".join(layer))
layer_name = subconfig.path()
subconfig.owner.set(subconfig.path())
else:
layer_name = None
# data user
user_datas = []
for user_data_name in user_data_names:
if has_layers:
layer_datas[layer_name] = {}
for user_data_name in layer:
path = (
Path(__file__).parent.parent
/ ("user_data_" + user_data_name)
@ -74,35 +231,70 @@ def _main():
_('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,
rougail_user_datas = module.RougailUserData
if hasattr(rougail_user_datas, 'interactive_user_datas') and rougail_user_datas.interactive_user_datas:
interactive_user_datas.setdefault(layer_name, {})[user_data_name] = rougail_user_datas
continue
elif interactive_user_datas:
raise Exception(_(f'interactive user datas "{0}" is loader before uninteractive user datas "{1}"').format(list(interactive_user_datas), user_data_name))
for user_data in rougail_user_datas(
subconfig,
rougailconfig=rougailconfig,
).run()
)
if user_datas:
err_warn = rougail.user_datas(user_datas)
else:
err_warn = {"errors": [], "warnings": []}
).run():
if has_layers:
layer_datas[layer_name].setdefault(user_data_name, []).append(user_data["source"])
user_datas.append(user_data)
if user_datas:
new_err_warn = UserDatas(subconfig).user_datas(user_datas, invalid_user_datas_error=invalid_user_datas_error, unknown_user_datas_error=unknown_user_datas_error)
for level, datas in new_err_warn.items():
if datas:
err_warn[level].extend(datas)
for layer_name, interactive_user_data in interactive_user_datas.items():
for layer, rougail_user_datas in interactive_user_data.items():
if has_layers and len(layers) > 1:
subconfig = subconfig.config("_".join(layer))
subconfig.owner.set(subconfig.path())
for user_data in rougail_user_datas(
subconfig,
rougailconfig=rougailconfig,
).run():
if has_layers:
layer_datas[layer_name].setdefault(user_data_name, []).append(user_data["source"])
return layer_datas, metaconfig, subconfig, err_warn
def get_output(rougailconfig, metaconfig, config, err_warn, layer_datas):
# output
config.property.read_only()
if config and (not rougailconfig["cli.load_config"] or not rougailconfig["cli.read_write"]):
config.property.read_only()
output_name = rougailconfig["step.output"]
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(
output = module.RougailOutput(
config=config,
rougailconfig=rougailconfig,
user_data_errors=err_warn["errors"],
user_data_warnings=err_warn["warnings"],
).run()
config_owner_is_path=True,
metaconfig=metaconfig,
layer_datas=layer_datas,
)
return output
def main():
def main(arguments=None, do_not_print=False):
global print_traceback
print_traceback = True
try:
_main()
return _main(arguments, do_not_print)
except Exception as err:
print(_("ERROR: {0}").format(err))
exit(1)
if print_traceback:
import traceback
traceback.print_exc()
exit(_("ERROR: {0}").format(err))

View file

@ -0,0 +1 @@
__version__ = "0.2.0a33"

97
src/rougail/cli/config.py Normal file
View file

@ -0,0 +1,97 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2025
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program 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 Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from .i18n import _
def get_rougail_config(
*,
backward_compatibility: bool = True, # pylint: disable=unused-argument
) -> dict:
options = f"""
cli:
description: {_('Command line options')}
config_file:
description: {_('Loads command line parameters from a file')}
type: unix_filename
commandline: false
params:
allow_relative: true
default: .rougailcli.yml
debug: false # {_('Displays debug informations')}
warnings: true # {_('Displays command line option warnings informations')}
versions: false # {_('Displays Rougail version and all its components')}
invalid_user_datas_error: false # {_("Invalid value in user datas is not allowed")}
unknown_user_datas_error: false # {_("Unknown variable in user datas is not allowed")}
layers:
description: {_('Open each user datas in separate layers')}
default: false
hidden:
jinja: |-
{{{{ __.step.user_data is propertyerror or __.step.user_data | length < 2 }}}}
return_type: boolean
load_config:
default: true
hidden: true
read_write: false # {_('Configuration in output step is in read_write mode')}
inaccessible_read_write_modes:
description: {_('Modes that should not be accessible in read_write mode')}
multi: true
mandatory: false
disabled:
jinja: |
{{% if not modes_level %}}
No mode
{{% endif %}}
validators:
- type: jinja
jinja: |
{{% if _.inaccessible_read_write_modes not in modes_level %}}
not in modes_level ({{modes_level}})
{{% endif %}}
inaccessible_modes:
description: {_('Modes that should not be accessible')}
multi: true
mandatory: false
disabled:
jinja: |
{{% if not modes_level %}}
No mode
{{% endif %}}
validators:
- type: jinja
jinja: |
{{% if _.inaccessible_modes not in modes_level %}}
not in modes_level ({{modes_level}})
{{% endif %}}
"""
return {
"options": options,
"process": None,
}

View file

@ -1,6 +1,6 @@
"""Internationalisation utilities
Silique (https://www.silique.fr)
Copyright (C) 2024
Copyright (C) 2024-2025
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
@ -19,6 +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"), fallback=True)
_ = t.gettext

View file

@ -0,0 +1,82 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2025
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 rougail.user_datas import UserDatas
def load(rougailconfig: "RougailConfig",
yaml_file: str=None,
env_prefix: str=None,
commandline: bool=False,
_arguments=None,
_add_help=True,
_generate=True
):
if _generate:
rougailconfig.generate_config()
cmd_config = rougailconfig.config
origin_prop = cmd_config.property.exportation()
cmd_config.property.read_write()
user_datas = []
if yaml_file:
user_datas.extend(from_yaml(cmd_config, yaml_file))
if env_prefix:
user_datas.extend(from_env(cmd_config, env_prefix))
if commandline:
user_datas.extend(from_cmdline(cmd_config, _arguments, _add_help))
user_data = UserDatas(cmd_config).user_datas(user_datas)
cmd_config.property.importation(origin_prop)
return user_data
def from_yaml(cmd_config, yaml_file):
from rougail.user_data_yaml import RougailUserDataYaml
fake_rougail_config = {
"step.user_data": ["yaml"],
"yaml.filename": [yaml_file],
"yaml.file_with_secrets": "all",
}
return RougailUserDataYaml(cmd_config,
rougailconfig=fake_rougail_config,
).run()
def from_env(cmd_config, env_prefix):
from rougail.user_data_environment import RougailUserDataEnvironment
fake_rougail_config = {
"main_namespace": None,
"step.user_data": ["environment"],
"environment.default_environment_name": env_prefix,
"environment.custom_separator": None,
}
return RougailUserDataEnvironment(
cmd_config,
rougailconfig=fake_rougail_config,
).run()
def from_cmdline(cmd_config, arguments, add_help):
from rougail.user_data_commandline import RougailUserDataCommandline
fake_rougail_config = {
"step.user_data": ["commandline"],
}
return RougailUserDataCommandline(cmd_config,
rougailconfig=fake_rougail_config,
short_name_max_len=2,
arguments=arguments,
add_help=add_help,
).run()

5
tests/cli/result.txt Normal file
View file

@ -0,0 +1,5 @@
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 a description: my_value

View file

@ -0,0 +1,7 @@
╭────────────── Caption ───────────────╮
│ Variable Modified value │
│ (⏳ Original default value) │
╰──────────────────────────────────────╯
Variables:
┗━━ 📓 a description: a yaml value ◀ loaded from the YAML file "yaml/file.yml"
 (⏳ my_value)

View file

@ -0,0 +1,7 @@
╭────────────── Caption ───────────────╮
│ Variable Modified value │
│ (⏳ Original default value) │
╰──────────────────────────────────────╯
Variables:
┗━━ 📓 a description: a yaml value ◀ loaded from the YAML file "yaml/file.yml"
 (⏳ my_value)

View file

@ -0,0 +1,11 @@
╭────────────── Caption ───────────────╮
│ Variable Modified value │
│ (⏳ Original default value) │
╰──────────────────────────────────────╯
╭─────────── Layers ────────────╮
│ environment variable │
│ the YAML file "yaml/file.yml" │
╰───────────────────────────────╯
Variables:
┗━━ 📓 a description: a yaml value ◀ loaded from the YAML file "yaml/file.yml"
 (⏳ my env value ◀ loaded from environment variable ⏳ my env value)

View file

@ -0,0 +1,4 @@
---
version: 1.1
my_variable: my_value # a description

1
tests/cli/versions.txt Normal file
View file

@ -0,0 +1 @@
["tiramisu", "tiramisu-cmdline-parser", "rougail", "rougail-cli", "rougail-structural-bitwarden", "rougail-user-data-ansible", "rougail-user-data-bitwarden", "rougail-user-data-commandline", "rougail-user-data-environment", "rougail-user-data-questionary", "rougail-user-data-yaml", "rougail-output-ansible", "rougail-output-console", "rougail-output-doc", "rougail-output-json"]

2
tests/cli/yaml/file.yml Normal file
View file

@ -0,0 +1,2 @@
---
my_variable: a yaml value

View file

@ -0,0 +1,7 @@
---
main_structural_directories:
- structures
step:
output: doc
doc:
output_format: json

View file

@ -0,0 +1 @@
"\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n\u2503\u001b[1m \u001b[0m\u001b[1mVariable \u001b[0m\u001b[1m \u001b[0m\u2503\u001b[1m \u001b[0m\u001b[1mDescription \u001b[0m\u001b[1m \u001b[0m\u2503\n\u2521\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2529\n\u2502 \u001b[1mmy_variable\u001b[0m \u2502 A description. \u2502\n\u2502 \u001b[1;7m string \u001b[0m \u001b[1;7m mandatory \u001b[0m \u2502 \u001b[1mDefault\u001b[0m: my_value \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"

View file

@ -0,0 +1,7 @@
---
main_structural_directories:
- structures
step:
output: doc
doc:
output_format: console

View file

@ -0,0 +1 @@
"[cols=\"1a,1a\"]\n|====\n| Variable | Description \n| **my_variable** +\n`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `mandatory` | A description. +\n**Default**: my_value \n|====\n\n"

View file

@ -0,0 +1,6 @@
---
main_structural_directories:
- structures
doc:
output_format: console

View file

@ -0,0 +1,4 @@
---
version: 1.1
my_variable: my_value # a description

View file

@ -0,0 +1,9 @@
---
version: 1.1
my_variable:
redefine: true
validators: # validators in jinja without description makes warnings
- jinja: |-
{{ _.my_variable != "my_value" }}
warnings: true

View file

@ -0,0 +1 @@
["family \"configuration rougail-json\" is disabled, \"test mandatories variables before display in json\" will be ignored when loading from the YAML file \"warnings.yml\""]

View file

@ -0,0 +1,7 @@
---
main_structural_directories:
- structures
doc:
output_format: console
json:
mandatory: true

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1,9 @@
---
main_structural_directories:
- structures
doc:
output_format: console
json:
mandatory: true
cli:
warnings: false

View file

@ -0,0 +1 @@
["family \"configuration rougail-json\" is disabled, \"test mandatories variables before display in json\" will be ignored when loading from the YAML file \"warnings3.yml\"", "\"validators\" is a calculation for my_variable but has no description in \"structures/file.yml\" and \"structures_warnings/file.yml\""]

View file

@ -0,0 +1,8 @@
---
main_structural_directories:
- structures
- structures_warnings
doc:
output_format: console
json:
mandatory: true

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1,10 @@
---
main_structural_directories:
- structures
- structures_warnings
doc:
output_format: console
json:
mandatory: true
cli:
warnings: false

View file

@ -0,0 +1 @@
"{\n \"my_variable\": {\n \"type\": \"variable\",\n \"default\": {\n \"name\": \"Default\",\n \"values\": \"my_value\"\n },\n \"properties\": [\n {\n \"type\": \"type\",\n \"name\": \"string\"\n },\n {\n \"type\": \"property\",\n \"name\": \"mandatory\"\n }\n ],\n \"path\": \"my_variable\",\n \"names\": [\n \"my_variable\"\n ],\n \"description\": \"A description.\",\n \"gen_examples\": [\n \"my_value\"\n ],\n \"mandatory_without_value\": false\n }\n}"

View file

@ -0,0 +1,3 @@
---
doc:
output_format: json

View file

@ -0,0 +1,4 @@
---
version: 1.1
my_variable: my_value # a description

View file

@ -0,0 +1 @@
"{\n \"my_variable\": {\n \"type\": \"variable\",\n \"default\": {\n \"name\": \"Default\",\n \"values\": \"my_value\"\n },\n \"properties\": [\n {\n \"type\": \"type\",\n \"name\": \"string\"\n },\n {\n \"type\": \"property\",\n \"name\": \"mandatory\"\n }\n ],\n \"path\": \"my_variable\",\n \"names\": [\n \"my_variable\"\n ],\n \"description\": \"A description.\",\n \"gen_examples\": [\n \"my_value\"\n ],\n \"mandatory_without_value\": false\n }\n}"

241
tests/test_load.py Normal file
View file

@ -0,0 +1,241 @@
import os
import warnings
from pathlib import Path
from contextlib import chdir
from json import dumps, loads
from rougail.cli.__main__ import main
test_dir = Path(__file__).parent
os.environ['COLUMNS'] = '80'
def test_cli():
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures'], do_not_print=True)
filename = Path('result.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data), str(filename.absolute())
def test_cli_boolean():
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures', '--console.mandatory'], do_not_print=True)
filename = Path('result.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data), str(filename.absolute())
def test_cli_boolean_no():
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures', '--console.no-mandatory'], do_not_print=True)
filename = Path('result.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data), str(filename.absolute())
def test_cli_version():
with chdir(test_dir / 'cli'):
ret = main(['--cli.version'], do_not_print=True)
ret = [r.rsplit(': ', 1)[0] for r in ret]
filename = Path('versions.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data, str(filename.absolute())
def test_cli_version_user_data_disabled():
with chdir(test_dir / 'cli'):
ret = main(['--cli.version', '--step.output', 'doc'], do_not_print=True)
ret = [r.rsplit(': ', 1)[0] for r in ret]
filename = Path('versions.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data, str(filename.absolute())
def test_cli_version_user_data_disabled_2():
with chdir(test_dir / 'second_step'):
ret = main(['--main_structural_directories', 'structures', '--step.output', 'doc'], do_not_print=True)
filename = Path('yaml.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data), str(filename.absolute())
def test_cli_user_data():
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures', '--step.user_data', 'yaml', '--yaml.filename', 'yaml/file.yml'], do_not_print=True)
filename = Path('result_user_data.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data), str(filename.absolute())
def test_cli_user_datas():
save = os.environ.copy()
os.environ["MY_VARIABLE"] = "my env value"
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures', '--step.user_data', 'environment', 'yaml', '--yaml.filename', 'yaml/file.yml'], do_not_print=True)
filename = Path('result_user_datas.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data), str(filename.absolute())
save = os.environ.copy()
def test_cli_user_datas_user_datas_layers():
save = os.environ.copy()
os.environ["ROUGAIL_MY_VARIABLE"] = "my env value"
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures', '--cli.layers', '--step.user_data', 'environment', 'yaml', '--yaml.filename', 'yaml/file.yml'], do_not_print=True)
filename = Path('result_user_datas_layers.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data), str(filename.absolute())
save = os.environ.copy()
def test_cli_rougailcli():
with chdir(test_dir / 'rougailcli_file'):
ret = main([], do_not_print=True)
filename = Path('yaml.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data), str(filename.absolute())
def test_cli_alt_rougailcli():
save = os.environ.copy()
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'alt_rougailcli.yml'
ret = main([], do_not_print=True)
filename = Path('alt_console.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data), str(filename.absolute())
os.environ = save
def test_cli_rougailcli_mix():
save = os.environ.copy()
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'mix_rougailcli.yml'
ret = main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
filename = Path('mix_console.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data), str(filename.absolute())
os.environ = save
def test_cli_rougailcli_warning():
save = os.environ.copy()
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings.yml'
with warnings.catch_warnings(record=True) as rougail_wn:
warnings.simplefilter("always", UserWarning)
main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
ret = [str(w.message) for w in rougail_wn]
filename = Path('warnings.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps([str(w.message) for w in rougail_wn]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data, str(filename.absolute())
os.environ = save
def test_cli_rougailcli_not_warning():
save = os.environ.copy()
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings2.yml'
with warnings.catch_warnings(record=True) as rougail_wn:
warnings.simplefilter("always", UserWarning)
main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
filename = Path('warnings2.txt')
ret = [str(w.message) for w in rougail_wn]
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data, str(filename.absolute())
os.environ = save
def test_cli_rougailcli_warning2():
save = os.environ.copy()
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings3.yml'
with warnings.catch_warnings(record=True) as rougail_wn:
warnings.simplefilter("always", UserWarning)
main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
ret = [str(w.message) for w in rougail_wn]
filename = Path('warnings3.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data, str(filename.absolute())
os.environ = save
def test_cli_rougailcli_not_warning2():
save = os.environ.copy()
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings4.yml'
with warnings.catch_warnings(record=True) as rougail_wn:
warnings.simplefilter("always", UserWarning)
main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
filename = Path('warnings4.txt')
ret = [str(w.message) for w in rougail_wn]
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data, str(filename.absolute())
os.environ = save