forked from hacs/default
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.py
47 lines (34 loc) · 963 Bytes
/
category.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
import json
DEFAULT = "/tmp/repositories/default"
CATEGORIES = [
"appdaemon",
"integration",
"netdaemon",
"plugin",
"python_script",
"template",
"theme",
]
CURRENT = {}
CHANGED = {}
def get_category():
for category in CATEGORIES:
with open(f"{DEFAULT}/{category}", "r") as default:
CURRENT[category] = json.loads(default.read())
for category in CATEGORIES:
with open(category, "r") as default:
CHANGED[category] = json.loads(default.read())
for category in CATEGORIES:
for repo in CURRENT[category]:
if repo in CHANGED[category]:
CHANGED[category].remove(repo)
changed = []
for category in CATEGORIES:
if CHANGED[category]:
changed.append(category)
if len(changed) != 1:
print(f"Bad data {changed}")
exit(1)
return changed.pop()
if __name__ == "__main__":
print(get_category())