This repository has been archived by the owner on Jul 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
executable file
·69 lines (52 loc) · 1.89 KB
/
test.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
65
66
67
68
69
#!/usr/bin/env python3
from json import loads
from os import listdir
from os.path import isdir, isfile, join
from update_index import BASE_PATH, hash_directory
def fail(msg):
print(msg)
exit(1)
with open(join(BASE_PATH, "index.json")) as f:
index = loads(f.read())
for plugin in listdir(BASE_PATH):
if (
not isdir(join(BASE_PATH, plugin))
or plugin == ".git"
or plugin == "__pycache__"
):
continue
print("{plugin}: checking...".format(plugin=plugin))
# read plugin manifest
with open(join(BASE_PATH, plugin, "manifest.json")) as f:
manifest = loads(f.read())
# hash plugin directory
dir_hash = hash_directory(join(BASE_PATH, plugin))
if dir_hash != index[plugin]["checksum"]:
fail(
"{plugin}: Checksum doesn't match. "
"Did you run update_index.py?".format(plugin=plugin)
)
if manifest["version"] != index[plugin]["version"]:
fail(
"{plugin}: Version doesn't match. "
"Did you run update_index.py?".format(plugin=plugin)
)
for file_path in manifest["provides"]:
if file_path in ("groups.py", "nodes.py"):
fail(
"{plugin}: must not overwrite {path}".format(
path=file_path, plugin=plugin
)
)
if not isfile(join(BASE_PATH, plugin, file_path)):
fail(
"{plugin}: '{file}' listed in manifest, but doesn't exist".format(
plugin=plugin, file=file_path
)
)
if not isfile(join(BASE_PATH, plugin, "AUTHORS")):
fail("{plugin}: missing AUTHORS".format(plugin=plugin))
if not isfile(join(BASE_PATH, plugin, "LICENSE")):
fail("{plugin}: missing LICENSE".format(plugin=plugin))
print("{plugin}: OK".format(plugin=plugin))
print("Everything seems to be in order.")