Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c1f757c124 | |||
| 3a741e92bd | |||
| 30aa3fd947 | |||
| 385687fb11 |
5 changed files with 200 additions and 351 deletions
316
CHANGELOG.md
316
CHANGELOG.md
|
|
@ -1,307 +1,69 @@
|
||||||
## 0.2.0a45 (2026-06-15)
|
## 1.0.0 (2026-06-21)
|
||||||
|
|
||||||
### Feat
|
### Feat
|
||||||
|
|
||||||
- support commandline user data
|
- support commandline user data
|
||||||
|
|
||||||
## 0.2.0a44 (2026-05-04)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- multi layers
|
- multi layers
|
||||||
|
|
||||||
## 0.2.0a43 (2026-03-26)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- better mandatories support (centralized)
|
- better mandatories support (centralized)
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- better warnings
|
|
||||||
|
|
||||||
## 0.2.0a42 (2026-01-21)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- update tests
|
|
||||||
|
|
||||||
## 0.2.0a41 (2026-01-12)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- tiramisu_cache has to be defined in cli namespace
|
- tiramisu_cache has to be defined in cli namespace
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- add test with rougailcli that assign a symlinkoption
|
|
||||||
|
|
||||||
## 0.2.0a40 (2026-01-04)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- add cli.root option to limit output from a specified family
|
- add cli.root option to limit output from a specified family
|
||||||
|
|
||||||
## 0.2.0a39 (2026-01-03)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- load tiramisu objects from cache
|
- load tiramisu objects from cache
|
||||||
|
|
||||||
## 0.2.0a38 (2026-01-01)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- more than two layers
|
|
||||||
|
|
||||||
## 0.2.0a37 (2025-12-30)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- update doc
|
|
||||||
- update tests
|
|
||||||
|
|
||||||
## 0.2.0a36 (2025-12-22)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- add permissive properties for unaccessible modes
|
|
||||||
|
|
||||||
## 0.2.0a35 (2025-12-22)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- documentation
|
|
||||||
|
|
||||||
## 0.2.0a34 (2025-12-22)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- multi rougailcli.yml files
|
- multi rougailcli.yml files
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- user_datas => user_data
|
|
||||||
|
|
||||||
## 0.2.0a33 (2025-11-21)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- add inaccessible_read_write_modes and inaccessible_modes options
|
- 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
|
- 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
|
- 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
|
- 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
|
- 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
|
- 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
|
- limit warning when asked
|
||||||
|
|
||||||
## 0.2.0a21 (2025-09-29)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- add cli.read_write option
|
- 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
|
- able to lad config_file name from environement variable
|
||||||
- loads user datas before and after cli params
|
- 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
|
- 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
|
- return 1 if output has problems
|
||||||
|
|
||||||
## 0.2.0a5 (2025-02-05)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- user_data can be loaded after other plugins
|
- 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
|
- load config from environment if rougail-user-data-environment is installed
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
|
||||||
|
- rougail dependencies
|
||||||
|
- black
|
||||||
|
- better warnings
|
||||||
|
- update tests
|
||||||
|
- add test with rougailcli that assign a symlinkoption
|
||||||
|
- more than two layers
|
||||||
|
- update doc
|
||||||
|
- update tests
|
||||||
|
- add permissive properties for unaccessible modes
|
||||||
|
- documentation
|
||||||
|
- user_datas => user_data
|
||||||
|
- execute interactive mode too
|
||||||
|
- better layers support
|
||||||
|
- do not display full help to early
|
||||||
|
- remove all warnings!
|
||||||
|
- update tests with new output_doc module
|
||||||
|
- add default option for environment user datas
|
||||||
|
- remove force_apply_user_data support
|
||||||
|
- config in read_only mode is asked
|
||||||
|
- dictionary => structure
|
||||||
|
- do now set modified option in second round
|
||||||
|
- upgrade translation
|
||||||
|
- black
|
||||||
|
- description
|
||||||
|
- do not raise if warning in cli
|
||||||
|
- do not force use_data usage
|
||||||
|
- 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
|
||||||
|
- version
|
||||||
|
- translation
|
||||||
|
- access to cli.config_file variable with commandline
|
||||||
|
- add config.py file
|
||||||
|
- better error support
|
||||||
|
- add and remove not_for_commandline property
|
||||||
|
- remove upgrade feature (now in formatter project) + better support of not_for_commandline feature
|
||||||
|
- user_data and output are not plugins
|
||||||
|
- separation between run and print function
|
||||||
- translation is not mandatory
|
- translation is not mandatory
|
||||||
|
|
||||||
## 0.1.1 (2024-11-06)
|
## 0.1.1 (2024-11-06)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rougail.cli"
|
name = "rougail.cli"
|
||||||
version = "0.2.0a45"
|
version = "1.0.0"
|
||||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
description = "CLI for Rougail"
|
description = "CLI for Rougail"
|
||||||
|
|
@ -24,8 +24,8 @@ classifiers = [
|
||||||
|
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rougail >= 1.1,<2",
|
"rougail >= 1.2.0,<2",
|
||||||
"rougail-user-data-commandline",
|
"rougail-user-data-commandline >= 1.0.0,<2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,14 @@ def _main(arguments, do_not_print):
|
||||||
print(version)
|
print(version)
|
||||||
exit()
|
exit()
|
||||||
layer_datas, metaconfig, config, err_warn = load_user_data(rougailconfig, parser)
|
layer_datas, metaconfig, config, err_warn = load_user_data(rougailconfig, parser)
|
||||||
if config and (not rougailconfig["cli.load_config"] or not rougailconfig["cli.read_write"]):
|
if config and (
|
||||||
|
not rougailconfig["cli.load_config"] or not rougailconfig["cli.read_write"]
|
||||||
|
):
|
||||||
config.property.read_only()
|
config.property.read_only()
|
||||||
if config and rougailconfig["cli.mandatory"]:
|
if config and rougailconfig["cli.mandatory"]:
|
||||||
mandatories(config, err_warn["errors"])
|
mandatories(config, err_warn["errors"])
|
||||||
output = get_output(rougailconfig,
|
output = get_output(
|
||||||
|
rougailconfig,
|
||||||
metaconfig,
|
metaconfig,
|
||||||
config,
|
config,
|
||||||
err_warn,
|
err_warn,
|
||||||
|
|
@ -93,17 +96,31 @@ def load_cmd_user_data(rougailconfig, arguments):
|
||||||
if RougailUserDataYaml:
|
if RougailUserDataYaml:
|
||||||
_config_files = os.environ.pop(f"{ENV_PREFIX}_CLI.CONFIG_FILE", None)
|
_config_files = os.environ.pop(f"{ENV_PREFIX}_CLI.CONFIG_FILE", None)
|
||||||
if _config_files:
|
if _config_files:
|
||||||
_config_files = _config_files.split(',')
|
_config_files = _config_files.split(",")
|
||||||
else:
|
else:
|
||||||
_config_files = cmd_config.forcepermissive.option("cli.config_file").value.get()
|
_config_files = cmd_config.forcepermissive.option(
|
||||||
_config_files = [_config_file for _config_file in _config_files if Path(_config_file).is_file()]
|
"cli.config_file"
|
||||||
|
).value.get()
|
||||||
|
_config_files = [
|
||||||
|
_config_file
|
||||||
|
for _config_file in _config_files
|
||||||
|
if Path(_config_file).is_file()
|
||||||
|
]
|
||||||
if _config_files:
|
if _config_files:
|
||||||
config_files = _config_files
|
config_files = _config_files
|
||||||
if RougailUserDataEnvironment:
|
if RougailUserDataEnvironment:
|
||||||
env_prefix = ENV_PREFIX
|
env_prefix = ENV_PREFIX
|
||||||
else:
|
else:
|
||||||
env_prefix = None
|
env_prefix = None
|
||||||
user_data = rougailconfig_load(rougailconfig, config_files, env_prefix, True, _arguments=arguments, _generate=False, _add_help=False)
|
user_data = rougailconfig_load(
|
||||||
|
rougailconfig,
|
||||||
|
config_files,
|
||||||
|
env_prefix,
|
||||||
|
True,
|
||||||
|
_arguments=arguments,
|
||||||
|
_generate=False,
|
||||||
|
_add_help=False,
|
||||||
|
)
|
||||||
display_warnings = rougailconfig["cli.warnings"]
|
display_warnings = rougailconfig["cli.warnings"]
|
||||||
manage_warnings(display_warnings)
|
manage_warnings(display_warnings)
|
||||||
if not cmd_config.option("cli.versions").value.get():
|
if not cmd_config.option("cli.versions").value.get():
|
||||||
|
|
@ -112,7 +129,16 @@ def load_cmd_user_data(rougailconfig, arguments):
|
||||||
if isinstance(warning, dict):
|
if isinstance(warning, dict):
|
||||||
for w, var in warning.items():
|
for w, var in warning.items():
|
||||||
if var:
|
if var:
|
||||||
warn(UserWarning(_('unable to load {0}, {1}').format(var.option.impl_get_display_name(var, with_quote=True), w)))
|
warn(
|
||||||
|
UserWarning(
|
||||||
|
_("unable to load {0}, {1}").format(
|
||||||
|
var.option.impl_get_display_name(
|
||||||
|
var, with_quote=True
|
||||||
|
),
|
||||||
|
w,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
warn(w)
|
warn(w)
|
||||||
else:
|
else:
|
||||||
|
|
@ -124,7 +150,10 @@ def load_cmd_user_data(rougailconfig, arguments):
|
||||||
short_name_max_len=2,
|
short_name_max_len=2,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
is_commandline = "commandline" in cmd_config.unrestraint.option(f'step.user_data').value.get()
|
is_commandline = (
|
||||||
|
"commandline"
|
||||||
|
in cmd_config.unrestraint.option(f"step.user_data").value.get()
|
||||||
|
)
|
||||||
except:
|
except:
|
||||||
is_commandline = False
|
is_commandline = False
|
||||||
if is_commandline:
|
if is_commandline:
|
||||||
|
|
@ -147,33 +176,35 @@ def load_cmd_user_data(rougailconfig, arguments):
|
||||||
def display_version(cmd_config):
|
def display_version(cmd_config):
|
||||||
versions = []
|
versions = []
|
||||||
from tiramisu import __version__
|
from tiramisu import __version__
|
||||||
yield(f"tiramisu: {__version__}")
|
|
||||||
|
yield (f"tiramisu: {__version__}")
|
||||||
|
|
||||||
from tiramisu_cmdline_parser import __version__
|
from tiramisu_cmdline_parser import __version__
|
||||||
yield(f"tiramisu-cmdline-parser: {__version__}")
|
|
||||||
|
yield (f"tiramisu-cmdline-parser: {__version__}")
|
||||||
|
|
||||||
from rougail import __version__
|
from rougail import __version__
|
||||||
yield(f"rougail: {__version__}")
|
|
||||||
|
yield (f"rougail: {__version__}")
|
||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
yield(f"rougail-cli: {__version__}")
|
|
||||||
|
yield (f"rougail-cli: {__version__}")
|
||||||
|
|
||||||
for step in ["structural", "user_data", "output"]:
|
for step in ["structural", "user_data", "output"]:
|
||||||
display_step = step.replace("_", "-")
|
display_step = step.replace("_", "-")
|
||||||
for step_name in sorted(cmd_config.unrestraint.option(f"step.{step}").value.list()):
|
for step_name in sorted(
|
||||||
|
cmd_config.unrestraint.option(f"step.{step}").value.list()
|
||||||
|
):
|
||||||
path = (
|
path = (
|
||||||
Path(__file__).parent.parent
|
Path(__file__).parent.parent / (step + "_" + step_name) / "__init__.py"
|
||||||
/ (step + "_" + step_name)
|
|
||||||
/ "__init__.py"
|
|
||||||
)
|
)
|
||||||
if path.is_file():
|
if path.is_file():
|
||||||
try:
|
try:
|
||||||
module = load_modules(
|
module = load_modules(
|
||||||
"rougail." + step + "_" + step_name, str(path)
|
"rougail." + step + "_" + step_name, str(path)
|
||||||
)
|
)
|
||||||
yield(
|
yield (f"rougail-{display_step}-{step_name}: {module.__version__}")
|
||||||
f"rougail-{display_step}-{step_name}: {module.__version__}"
|
|
||||||
)
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -220,16 +251,29 @@ def load_user_data(rougailconfig, cmdline_parser):
|
||||||
read_write |= modes
|
read_write |= modes
|
||||||
if read_write:
|
if read_write:
|
||||||
metaconfig.property.setdefault(
|
metaconfig.property.setdefault(
|
||||||
frozenset(metaconfig.property.default("read_write", "append") | read_write), "read_write", "append"
|
frozenset(
|
||||||
|
metaconfig.property.default("read_write", "append") | read_write
|
||||||
|
),
|
||||||
|
"read_write",
|
||||||
|
"append",
|
||||||
)
|
)
|
||||||
metaconfig.property.setdefault(
|
metaconfig.property.setdefault(
|
||||||
frozenset(metaconfig.property.default("read_only", "remove") | (read_write - read_only)), "read_only", "remove"
|
frozenset(
|
||||||
|
metaconfig.property.default("read_only", "remove")
|
||||||
|
| (read_write - read_only)
|
||||||
|
),
|
||||||
|
"read_only",
|
||||||
|
"remove",
|
||||||
)
|
)
|
||||||
for p in read_write:
|
for p in read_write:
|
||||||
metaconfig.permissive.add(p)
|
metaconfig.permissive.add(p)
|
||||||
if read_only:
|
if read_only:
|
||||||
metaconfig.property.setdefault(
|
metaconfig.property.setdefault(
|
||||||
frozenset(metaconfig.property.default("read_only", "append") | read_only), "read_only", "append"
|
frozenset(
|
||||||
|
metaconfig.property.default("read_only", "append") | read_only
|
||||||
|
),
|
||||||
|
"read_only",
|
||||||
|
"append",
|
||||||
)
|
)
|
||||||
for p in read_only:
|
for p in read_only:
|
||||||
metaconfig.permissive.add(p)
|
metaconfig.permissive.add(p)
|
||||||
|
|
@ -237,7 +281,9 @@ def load_user_data(rougailconfig, cmdline_parser):
|
||||||
metaconfig.property.read_write()
|
metaconfig.property.read_write()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
metaconfig.information.set("description_type", rougailconfig["cli.description_type"])
|
metaconfig.information.set(
|
||||||
|
"description_type", rougailconfig["cli.description_type"]
|
||||||
|
)
|
||||||
rougail_user_datas = {}
|
rougail_user_datas = {}
|
||||||
interactive_user_datas = {}
|
interactive_user_datas = {}
|
||||||
for ud_idx, user_data_name in enumerate(reversed(user_data_names)):
|
for ud_idx, user_data_name in enumerate(reversed(user_data_names)):
|
||||||
|
|
@ -252,19 +298,31 @@ def load_user_data(rougailconfig, cmdline_parser):
|
||||||
)
|
)
|
||||||
module = load_modules("rougail.user_data_" + user_data_name, str(path))
|
module = load_modules("rougail.user_data_" + user_data_name, str(path))
|
||||||
rougail_user_data = module.RougailUserData
|
rougail_user_data = module.RougailUserData
|
||||||
has_several_layers = hasattr(rougail_user_data, 'has_several_layers') and rougail_user_data.has_several_layers
|
has_several_layers = (
|
||||||
|
hasattr(rougail_user_data, "has_several_layers")
|
||||||
|
and rougail_user_data.has_several_layers
|
||||||
|
)
|
||||||
if has_layers and has_several_layers:
|
if has_layers and has_several_layers:
|
||||||
layers_len = rougail_user_data(None, rougailconfig=rougailconfig).count_layers()
|
layers_len = rougail_user_data(
|
||||||
|
None, rougailconfig=rougailconfig
|
||||||
|
).count_layers()
|
||||||
else:
|
else:
|
||||||
layers_len = 1
|
layers_len = 1
|
||||||
for idx in range(layers_len):
|
for idx in range(layers_len):
|
||||||
if ud_idx and has_layers:
|
if ud_idx and has_layers:
|
||||||
metaconfig = MetaConfig([metaconfig], name=user_data_name)
|
metaconfig = MetaConfig([metaconfig], name=user_data_name)
|
||||||
if not idx:
|
if not idx:
|
||||||
has_interactive_user_data = hasattr(rougail_user_data, 'interactive_user_data') and rougail_user_data.interactive_user_data
|
has_interactive_user_data = (
|
||||||
|
hasattr(rougail_user_data, "interactive_user_data")
|
||||||
|
and rougail_user_data.interactive_user_data
|
||||||
|
)
|
||||||
if has_interactive_user_data:
|
if has_interactive_user_data:
|
||||||
if rougail_user_datas:
|
if rougail_user_datas:
|
||||||
raise Exception(_('interactive user data "{0}" is loader before uninteractive user data "{1}"').format(list(interactive_user_datas), user_data_name))
|
raise Exception(
|
||||||
|
_(
|
||||||
|
'interactive user data "{0}" is loader before uninteractive user data "{1}"'
|
||||||
|
).format(list(interactive_user_datas), user_data_name)
|
||||||
|
)
|
||||||
interactive_user_datas[user_data_name] = rougail_user_data
|
interactive_user_datas[user_data_name] = rougail_user_data
|
||||||
else:
|
else:
|
||||||
rougail_user_datas[user_data_name] = rougail_user_data
|
rougail_user_datas[user_data_name] = rougail_user_data
|
||||||
|
|
@ -279,30 +337,41 @@ def load_user_data(rougailconfig, cmdline_parser):
|
||||||
if idx:
|
if idx:
|
||||||
metaconfig = metaconfig.config(user_data_name)
|
metaconfig = metaconfig.config(user_data_name)
|
||||||
metaconfig.owner.set(metaconfig.path())
|
metaconfig.owner.set(metaconfig.path())
|
||||||
if user_data_name == 'commandline':
|
if user_data_name == "commandline":
|
||||||
extras = {"parents": [cmdline_parser],
|
extras = {
|
||||||
|
"parents": [cmdline_parser],
|
||||||
"add_help": False,
|
"add_help": False,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
extras = {}
|
extras = {}
|
||||||
for ud_idx, user_data in enumerate(rougail_user_data(
|
for ud_idx, user_data in enumerate(
|
||||||
|
rougail_user_data(
|
||||||
subconfig,
|
subconfig,
|
||||||
rougailconfig=rougailconfig,
|
rougailconfig=rougailconfig,
|
||||||
**extras,
|
**extras,
|
||||||
).run()):
|
).run()
|
||||||
|
):
|
||||||
if has_layers and ud_idx:
|
if has_layers and ud_idx:
|
||||||
metaconfig = metaconfig.config(user_data_name)
|
metaconfig = metaconfig.config(user_data_name)
|
||||||
metaconfig.owner.set(metaconfig.path())
|
metaconfig.owner.set(metaconfig.path())
|
||||||
if has_layers:
|
if has_layers:
|
||||||
layer_datas.append(user_data["source"])
|
layer_datas.append(user_data["source"])
|
||||||
new_err_warn = UserData(metaconfig).user_data([user_data], invalid_user_data_error=invalid_user_data_error, unknown_user_data_error=unknown_user_data_error)
|
new_err_warn = UserData(metaconfig).user_data(
|
||||||
|
[user_data],
|
||||||
|
invalid_user_data_error=invalid_user_data_error,
|
||||||
|
unknown_user_data_error=unknown_user_data_error,
|
||||||
|
)
|
||||||
for level, datas in new_err_warn.items():
|
for level, datas in new_err_warn.items():
|
||||||
if datas:
|
if datas:
|
||||||
err_warn[level].extend(datas)
|
err_warn[level].extend(datas)
|
||||||
else:
|
else:
|
||||||
user_datas.append(user_data)
|
user_datas.append(user_data)
|
||||||
if user_datas and not has_layers:
|
if user_datas and not has_layers:
|
||||||
new_err_warn = UserData(metaconfig).user_data(user_datas, invalid_user_data_error=invalid_user_data_error, unknown_user_data_error=unknown_user_data_error)
|
new_err_warn = UserData(metaconfig).user_data(
|
||||||
|
user_datas,
|
||||||
|
invalid_user_data_error=invalid_user_data_error,
|
||||||
|
unknown_user_data_error=unknown_user_data_error,
|
||||||
|
)
|
||||||
for level, datas in new_err_warn.items():
|
for level, datas in new_err_warn.items():
|
||||||
if datas:
|
if datas:
|
||||||
err_warn[level].extend(datas)
|
err_warn[level].extend(datas)
|
||||||
|
|
@ -313,23 +382,33 @@ def load_user_data(rougailconfig, cmdline_parser):
|
||||||
if idx:
|
if idx:
|
||||||
metaconfig = metaconfig.config(user_data_name)
|
metaconfig = metaconfig.config(user_data_name)
|
||||||
metaconfig.owner.set(metaconfig.path())
|
metaconfig.owner.set(metaconfig.path())
|
||||||
for ud_idx, user_data in enumerate(rougail_user_data(
|
for ud_idx, user_data in enumerate(
|
||||||
|
rougail_user_data(
|
||||||
subconfig,
|
subconfig,
|
||||||
rougailconfig=rougailconfig,
|
rougailconfig=rougailconfig,
|
||||||
).run()):
|
).run()
|
||||||
|
):
|
||||||
if has_layers and ud_idx:
|
if has_layers and ud_idx:
|
||||||
metaconfig = metaconfig.config(user_data_name)
|
metaconfig = metaconfig.config(user_data_name)
|
||||||
metaconfig.owner.set(metaconfig.path())
|
metaconfig.owner.set(metaconfig.path())
|
||||||
if has_layers:
|
if has_layers:
|
||||||
layer_datas.append(user_data["source"])
|
layer_datas.append(user_data["source"])
|
||||||
new_err_warn = UserData(metaconfig).user_data([user_data], invalid_user_data_error=invalid_user_data_error, unknown_user_data_error=unknown_user_data_error)
|
new_err_warn = UserData(metaconfig).user_data(
|
||||||
|
[user_data],
|
||||||
|
invalid_user_data_error=invalid_user_data_error,
|
||||||
|
unknown_user_data_error=unknown_user_data_error,
|
||||||
|
)
|
||||||
for level, datas in new_err_warn.items():
|
for level, datas in new_err_warn.items():
|
||||||
if datas:
|
if datas:
|
||||||
err_warn[level].extend(datas)
|
err_warn[level].extend(datas)
|
||||||
else:
|
else:
|
||||||
user_datas.append(user_data)
|
user_datas.append(user_data)
|
||||||
if user_datas and not has_layers:
|
if user_datas and not has_layers:
|
||||||
new_err_warn = UserData(metaconfig).user_data(user_datas, invalid_user_data_error=invalid_user_data_error, unknown_user_data_error=unknown_user_data_error)
|
new_err_warn = UserData(metaconfig).user_data(
|
||||||
|
user_datas,
|
||||||
|
invalid_user_data_error=invalid_user_data_error,
|
||||||
|
unknown_user_data_error=unknown_user_data_error,
|
||||||
|
)
|
||||||
for level, datas in new_err_warn.items():
|
for level, datas in new_err_warn.items():
|
||||||
if datas:
|
if datas:
|
||||||
err_warn[level].extend(datas)
|
err_warn[level].extend(datas)
|
||||||
|
|
@ -371,5 +450,6 @@ def main(arguments=None, do_not_print=False):
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
if print_traceback:
|
if print_traceback:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
exit(_("ERROR: {0}").format(err))
|
exit(_("ERROR: {0}").format(err))
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__version__ = "0.2.0a45"
|
__version__ = "1.0.0"
|
||||||
|
|
|
||||||
|
|
@ -15,17 +15,19 @@ 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/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from rougail.user_data import UserData
|
from rougail.user_data import UserData
|
||||||
|
|
||||||
|
|
||||||
def load(rougailconfig: "RougailConfig",
|
def load(
|
||||||
yaml_files: list[str]=None,
|
rougailconfig: "RougailConfig",
|
||||||
env_prefix: str=None,
|
yaml_files: list[str] = None,
|
||||||
commandline: bool=False,
|
env_prefix: str = None,
|
||||||
|
commandline: bool = False,
|
||||||
_arguments=None,
|
_arguments=None,
|
||||||
_add_help=True,
|
_add_help=True,
|
||||||
_generate=True
|
_generate=True,
|
||||||
):
|
):
|
||||||
if _generate:
|
if _generate:
|
||||||
rougailconfig.generate_config()
|
rougailconfig.generate_config()
|
||||||
cmd_config = rougailconfig.config
|
cmd_config = rougailconfig.config
|
||||||
|
|
@ -46,18 +48,21 @@ def load(rougailconfig: "RougailConfig",
|
||||||
|
|
||||||
def from_yaml(cmd_config, yaml_file):
|
def from_yaml(cmd_config, yaml_file):
|
||||||
from rougail.user_data_yaml import RougailUserDataYaml
|
from rougail.user_data_yaml import RougailUserDataYaml
|
||||||
|
|
||||||
fake_rougail_config = {
|
fake_rougail_config = {
|
||||||
"step.user_data": ["yaml"],
|
"step.user_data": ["yaml"],
|
||||||
"yaml.filename": [yaml_file],
|
"yaml.filename": [yaml_file],
|
||||||
"yaml.file_with_secrets": "all",
|
"yaml.file_with_secrets": "all",
|
||||||
}
|
}
|
||||||
return RougailUserDataYaml(cmd_config,
|
return RougailUserDataYaml(
|
||||||
|
cmd_config,
|
||||||
rougailconfig=fake_rougail_config,
|
rougailconfig=fake_rougail_config,
|
||||||
).run()
|
).run()
|
||||||
|
|
||||||
|
|
||||||
def from_env(cmd_config, env_prefix):
|
def from_env(cmd_config, env_prefix):
|
||||||
from rougail.user_data_environment import RougailUserDataEnvironment
|
from rougail.user_data_environment import RougailUserDataEnvironment
|
||||||
|
|
||||||
fake_rougail_config = {
|
fake_rougail_config = {
|
||||||
"main_namespace": None,
|
"main_namespace": None,
|
||||||
"step.user_data": ["environment"],
|
"step.user_data": ["environment"],
|
||||||
|
|
@ -72,10 +77,12 @@ def from_env(cmd_config, env_prefix):
|
||||||
|
|
||||||
def from_cmdline(cmd_config, arguments, add_help):
|
def from_cmdline(cmd_config, arguments, add_help):
|
||||||
from rougail.user_data_commandline import RougailUserDataCommandline
|
from rougail.user_data_commandline import RougailUserDataCommandline
|
||||||
|
|
||||||
fake_rougail_config = {
|
fake_rougail_config = {
|
||||||
"step.user_data": ["commandline"],
|
"step.user_data": ["commandline"],
|
||||||
}
|
}
|
||||||
return RougailUserDataCommandline(cmd_config,
|
return RougailUserDataCommandline(
|
||||||
|
cmd_config,
|
||||||
rougailconfig=fake_rougail_config,
|
rougailconfig=fake_rougail_config,
|
||||||
short_name_max_len=2,
|
short_name_max_len=2,
|
||||||
arguments=arguments,
|
arguments=arguments,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue