Coverage for csaf/config.py: 66.67%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-18 20:12:48 +00:00

1"""Configuration API for csaf.""" 

2 

3import pathlib 

4from typing import Any, Mapping, Union 

5 

6import msgspec 

7 

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""" 

23 

24 

25def generate_template() -> str: 

26 """Return template of a well-formed JSON configuration.""" 

27 return TEMPLATE_EXAMPLE 

28 

29 

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())