-
Notifications
You must be signed in to change notification settings - Fork 10
/
check-uses.py
executable file
·35 lines (31 loc) · 1.16 KB
/
check-uses.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
#!/usr/bin/env python3
from github import Github
import json
import os
import pygit2
import semantic_version
def main():
data = json.load(open("index.json"))
versionsWeHave = {}
for lib in data["libs"].keys():
versionsWeHave[lib] = set()
versions = data["libs"][lib]["versions"]
for version in versions.keys():
versionsWeHave[lib].add(semantic_version.Version.coerce(version).truncate())
for provide in versions[version].get("provides",[]):
versionsWeHave[lib].add(semantic_version.Version.coerce(provide).truncate())
print(versionsWeHave)
for lib in data["libs"].keys():
versions = data["libs"][lib]["versions"]
for version in versions.keys():
uses = versions[version].get("uses",{})
for use in uses.keys():
if use not in versionsWeHave:
print("%s %s uses unknown library %s %s" % (lib, version, use, uses[use]))
continue
if semantic_version.Version.coerce(uses[use]).truncate() not in versionsWeHave[use]:
print("%s %s uses %s %s" % (lib, version, use, uses[use]))
else:
pass # print("Have %s %s" % (use, uses[use]))
if __name__ == '__main__':
main()