-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versions.py
executable file
·61 lines (51 loc) · 1.49 KB
/
versions.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
#!/usr/bin/env python3
import os
import re
import yaml
ignored = [
'matrix_synapse_default_room_version',
]
prefixes = [
'matrix_',
'custom_',
'int_',
'synapse_default_',
'synapse_ext_',
'mailer_container_',
'bot_',
'client_',
'mautrix_',
'devture_',
'beeper_',
'backup_borg_',
]
suffixes = [
'_version',
]
def find_versions():
matches = {}
for root, dirs, files in os.walk('.'):
if root.endswith('defaults'):
for file in files:
if file.endswith('main.yml'):
path = os.path.join(root, file)
with open(path, 'r') as f:
data = yaml.safe_load(f)
for key, value in data.items():
if key.endswith('_version') and value and not re.search(r'{{|master|main|""', str(value)) and key not in ignored:
sanitized_key = sanitize_key(key)
matches[sanitized_key] = value
return matches
def sanitize_key(key):
for prefix in prefixes:
key = key.removeprefix(prefix)
for suffix in suffixes:
key = key.removesuffix(suffix)
return key.replace('_', ' ').title()
def generate_versions():
versions = find_versions()
with open(os.path.join(os.getcwd(), 'VERSIONS.md'), 'w') as f:
for key, value in sorted(versions.items()):
f.write(f'* {key}: {value}\n')
if __name__ == "__main__":
generate_versions()