Coverage for csaf/config.py: 54.55%
9 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-04 16:28:45 +00:00
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-04 16:28:45 +00:00
1"""Configuration API for csaf."""
3import pathlib
4from typing import Any, Mapping, Union
6import msgspec
8TEMPLATE_EXAMPLE = """\
9{
10 "remote": {
11 "user": "",
12 "token": "",
13 "base_url": ""
14 },
15 "local": {
16 "bail_out": false,
17 "quiet": false,
18 "verbose": false,
19 "strict": false
20 }
21}
22"""
25def generate_template() -> str:
26 """Return template of a well-formed JSON configuration."""
27 return TEMPLATE_EXAMPLE
30def read_configuration(path: Union[pathlib.Path, str]) -> Union[Any, Mapping[str, object]]:
31 """LaterAlligator."""
32 with open(str(path), 'rb') as handle:
33 return msgspec.json.decode(handle.read())