Compare commits
No commits in common. "73682273fe80457e3a4a716b90d72a20a6fd5c89" and "1d29366b7cd0808a1c893de0da893eb3af7fcc34" have entirely different histories.
73682273fe
...
1d29366b7c
27 changed files with 7 additions and 180 deletions
|
|
@ -1,9 +1,3 @@
|
||||||
## 0.2.0a18 (2026-01-21)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- warnings and errors support
|
|
||||||
|
|
||||||
## 0.2.0a17 (2026-01-14)
|
## 0.2.0a17 (2026-01-14)
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rougail.output_json"
|
name = "rougail.output_json"
|
||||||
version = "0.2.0a18"
|
version = "0.2.0a17"
|
||||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
description = "Rougail output json"
|
description = "Rougail output json"
|
||||||
|
|
|
||||||
|
|
@ -135,30 +135,15 @@ class RougailOutputJson:
|
||||||
self.errors.append(f" - {option.description()}")
|
self.errors.append(f" - {option.description()}")
|
||||||
|
|
||||||
def manage_warnings(self) -> None:
|
def manage_warnings(self) -> None:
|
||||||
if not self.warnings:
|
if self.warnings:
|
||||||
return
|
self.dico["_warnings"] = self.warnings
|
||||||
warnings = []
|
|
||||||
for w in self.warnings:
|
|
||||||
if isinstance(w, dict):
|
|
||||||
msg, opt = next(iter(w.items()))
|
|
||||||
warnings.append(_('{0}: {1}').format(opt.path, msg))
|
|
||||||
else:
|
|
||||||
warnings.append(w)
|
|
||||||
self.dico["_warnings"] = warnings
|
|
||||||
|
|
||||||
def manage_errors(self) -> bool:
|
def manage_errors(self) -> bool:
|
||||||
if not self.errors:
|
if not self.errors:
|
||||||
return True
|
return False
|
||||||
errors = []
|
self.dico = {"_errors": self.errors}
|
||||||
for e in self.errors:
|
|
||||||
if isinstance(e, dict):
|
|
||||||
msg, opt = next(iter(e.items()))
|
|
||||||
errors.append(_('{0}: {1}').format(opt.path, msg))
|
|
||||||
else:
|
|
||||||
errors.append(e)
|
|
||||||
self.dico = {"_errors": errors}
|
|
||||||
self.manage_warnings()
|
self.manage_warnings()
|
||||||
return False
|
return True
|
||||||
|
|
||||||
def parse_family(
|
def parse_family(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__version__ = "0.2.0a18"
|
__version__ = "0.2.0a17"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {
|
|
||||||
"a_first_variable": "default value"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {
|
|
||||||
"a_third_variable": "a value"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {
|
|
||||||
"a_second_variable": "a value"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
%YAML 1.2
|
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
a_first_variable: default value
|
|
||||||
|
|
||||||
a_second_variable: default value
|
|
||||||
|
|
||||||
a_third_variable: default value
|
|
||||||
...
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail": {}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"a_sub_family": {
|
|
||||||
"a_variable": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"a_sub_family": {
|
|
||||||
"a_variable": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
true
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
%YAML 1.2
|
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
a_family: # a family
|
|
||||||
|
|
||||||
a_sub_family: # a subfamily
|
|
||||||
|
|
||||||
a_variable: true # a variable inside a family
|
|
||||||
...
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
from pytest import fixture # , raises
|
from pytest import fixture # , raises
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from rougail import Rougail, RougailConfig
|
from rougail import Rougail, RougailConfig
|
||||||
from rougail.user_data_yaml import RougailUserDataYaml
|
|
||||||
from rougail.output_json import RougailOutputJson as RougailOutput
|
from rougail.output_json import RougailOutputJson as RougailOutput
|
||||||
|
|
||||||
from rougail_tests.utils import get_structures_list, get_rougail_config, get_values_for_config
|
from rougail_tests.utils import get_structures_list, get_rougail_config, get_values_for_config
|
||||||
|
|
@ -150,67 +149,3 @@ def test_subconfig_variable():
|
||||||
with output_file.open() as outfh:
|
with output_file.open() as outfh:
|
||||||
attented_output = outfh.read()
|
attented_output = outfh.read()
|
||||||
assert generated_output == attented_output, f'filename {output_file}'
|
assert generated_output == attented_output, f'filename {output_file}'
|
||||||
|
|
||||||
|
|
||||||
def test_warnings():
|
|
||||||
rougailconfig = get_rougail_config(Path('tests/warnings/structures'), True)
|
|
||||||
##################################
|
|
||||||
rougailconfig['step.output'] = 'json'
|
|
||||||
rougailconfig['step.user_data'] = ['yaml']
|
|
||||||
rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml']
|
|
||||||
extra_namespaces = rougailconfig["extra_namespaces"]
|
|
||||||
rougailconfig['extra_namespaces'] = extra_namespaces
|
|
||||||
##################################
|
|
||||||
rougail = Rougail(rougailconfig)
|
|
||||||
config = rougail.run()
|
|
||||||
generated_user_data = RougailUserDataYaml(config, rougailconfig=rougailconfig).run()
|
|
||||||
err_warn = rougail.user_data(generated_user_data)
|
|
||||||
output = RougailOutput(
|
|
||||||
config=config,
|
|
||||||
rougailconfig=rougailconfig,
|
|
||||||
user_data_errors=err_warn["errors"],
|
|
||||||
user_data_warnings=err_warn["warnings"],
|
|
||||||
)
|
|
||||||
ret = output.run()
|
|
||||||
assert ret[0] is True
|
|
||||||
output_file = Path(__file__).parent / "warnings" / 'results' / "warnings.yml"
|
|
||||||
if not output_file.is_file():
|
|
||||||
if not output_file.parent.is_dir():
|
|
||||||
output_file.parent.mkdir()
|
|
||||||
with output_file.open('w') as outfh:
|
|
||||||
outfh.write(ret[1])
|
|
||||||
with output_file.open() as outfh:
|
|
||||||
attented_output = outfh.read()
|
|
||||||
assert ret[1] == attented_output, f'filename {output_file}'
|
|
||||||
|
|
||||||
|
|
||||||
def test_errors():
|
|
||||||
rougailconfig = get_rougail_config(Path('tests/warnings/structures'), True)
|
|
||||||
##################################
|
|
||||||
rougailconfig['step.output'] = 'json'
|
|
||||||
rougailconfig['step.user_data'] = ['yaml']
|
|
||||||
rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml']
|
|
||||||
extra_namespaces = rougailconfig["extra_namespaces"]
|
|
||||||
rougailconfig['extra_namespaces'] = extra_namespaces
|
|
||||||
##################################
|
|
||||||
rougail = Rougail(rougailconfig)
|
|
||||||
config = rougail.run()
|
|
||||||
generated_user_data = RougailUserDataYaml(config, rougailconfig=rougailconfig).run()
|
|
||||||
err_warn = rougail.user_data(generated_user_data, unknown_user_data_error=True)
|
|
||||||
output = RougailOutput(
|
|
||||||
config=config,
|
|
||||||
rougailconfig=rougailconfig,
|
|
||||||
user_data_errors=err_warn["errors"],
|
|
||||||
user_data_warnings=err_warn["warnings"],
|
|
||||||
)
|
|
||||||
ret = output.run()
|
|
||||||
assert ret[0] is False
|
|
||||||
output_file = Path(__file__).parent / "warnings" / 'results' / "errors.yml"
|
|
||||||
if not output_file.is_file():
|
|
||||||
if not output_file.parent.is_dir():
|
|
||||||
output_file.parent.mkdir()
|
|
||||||
with output_file.open('w') as outfh:
|
|
||||||
outfh.write(ret[1])
|
|
||||||
with output_file.open() as outfh:
|
|
||||||
attented_output = outfh.read()
|
|
||||||
assert ret[1] == attented_output, f'filename {output_file}'
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"_errors": [
|
|
||||||
"rougail: variable or family \"an_unknown_var\" does not exist so cannot load \"rougail.an_unknown_var\", it has been loading from the YAML file \"tests/warnings/yaml/config.yml\""
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"_warnings": [
|
|
||||||
"rougail: variable or family \"an_unknown_var\" does not exist so cannot load \"rougail.an_unknown_var\", it will be ignored when loading from the YAML file \"tests/warnings/yaml/config.yml\""
|
|
||||||
],
|
|
||||||
"rougail": {
|
|
||||||
"a_var": "a_value"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
a_var:
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
---
|
|
||||||
rougail:
|
|
||||||
a_var: a_value
|
|
||||||
an_unknown_var: a_value
|
|
||||||
Loading…
Reference in a new issue