-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathconfiguration.py
64 lines (54 loc) · 1.58 KB
/
configuration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from jsonmerge import Merger
from utils.colors import Color
def merge(base: dict, head: dict) -> dict:
"""
Merge base with head dict.
:param base: dict to get merged with head.
:type base: dict
:param head: dict to merge in base.
:type head: dict
:return: The merged dict.
:rtype: dict
"""
merger = Merger(
{
"oneOf": [
{"type": "array", "mergeStrategy": "append"},
{"type": "object", "additionalProperties": {"$ref": "#"}},
{"type": "string"},
{"type": "number"},
]
}
)
return merger.merge(base, head)
def pretty(d, indent: int = 0, is_list: bool = False):
"""
Pretty print dict.
:param d: Dict or list to print in pretty mode
:param indent: Intentation level.
:type indent: int
:param is_list: is it a list? recursive parameter
:type is_list: bool
"""
if not is_list:
for key, value in d.items():
print("\t" * indent + f"{Color.CBEIGE} {key}{Color.ENDC}")
__print_pretty_value(value, indent)
else:
for value in d:
__print_pretty_value(value, indent)
def __print_pretty_value(value, indent):
"""
Print a list of dicts in pretty mode.
"""
if isinstance(value, dict):
pretty(value, indent + 1)
elif isinstance(value, list):
pretty(value, indent + 1, is_list=True)
else:
print("\t" * (indent + 1) + f"{value}")
def get_aliases():
aliases = {
"poodle" : ["tlspoodle","sslpoodle"]
}
return aliases