-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdepdiff.py
37 lines (29 loc) · 1.02 KB
/
depdiff.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
import sys
try:
deps_a_filename = sys.argv[1]
deps_b_filename = sys.argv[2]
except IndexError:
print("Usage: python depdiff.py <filename> <filename>")
sys.exit(1)
def parse_deps(filename):
deps = {}
with open(filename) as file:
for line in file:
line = line.strip()
if line:
for depver in line.split(','):
if depver.startswith('-e'):
continue
dep, ver = depver.split('==')
deps[dep] = ver
return deps
deps_a = parse_deps(deps_a_filename)
deps_b = parse_deps(deps_b_filename)
for dep, ver in deps_a.items():
if dep in deps_b and deps_b[dep] != ver:
print(f'Version mismatch {deps_a_filename} vs {deps_b_filename}: {dep}=={ver} vs. {dep}=={deps_b[dep]}')
if dep not in deps_b:
print(f'Extra dep in {deps_a_filename}: {dep}=={ver}')
for dep, ver in deps_b.items():
if dep not in deps_a:
print(f'Extra dep in {deps_b_filename}: {dep}=={ver}')