Files
default/scripts/changed/category.py
T
Joakim Sørensen 9e8788c060 Add preflight (#490)
* Add preflight

* fix syntax

* move check

* get event

* print

* return event

* use path

* tt

* move to helper

* add issue_comment

* remove should run

* check owner

* add more information to the logs

* test

* add finished

* move keys

* Update errors

* remove repo

* fix JQ run

* filter
2020-05-28 16:53:45 +02:00

47 lines
947 B
Python

import json
DEFAULT = "/tmp/repositories/default"
CATEGORIES = [
"appdaemon",
"integration",
"netdaemon",
"plugin",
"python_script",
"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())