blob: f903fff291afcbef9e80a4e2433b316132afabab [file] [log] [blame]
#!/usr/bin/env python3
import sys
import difflib
import pprint
import os
S8A = os.path.join(sys.argv[1], 's8a')
S8B = os.path.join(sys.argv[1], 's8b')
assert os.path.exists(S8A), S8A
assert os.path.exists(S8B), S8B
s8a_files = list(sorted(os.listdir(S8A)))
s8b_files = list(sorted(os.listdir(S8B)))
toremove = []
for f in s8b_files:
if f not in s8a_files:
continue
if not f.endswith('.cor') and not f.endswith('.all'):
if ".cor" not in f and ".all" not in f:
print("Found in both:", f)
continue
af = os.path.join(S8A, f)
bf = os.path.join(S8B, f)
ac = open(af).readlines()
bc = open(bf).readlines()
adds = []
minus = []
for l in list(difflib.unified_diff(ac, bc))[2:]:
if l[1] in ('*',):
continue
if l[0] in (' ','@'):
continue
if l[0] == '-':
minus.append(l[1:])
elif l[0] == '+':
adds.append(l[1:])
assert not adds, (af, adds)
for m in minus:
if f.endswith('.all') and m.endswith('=0\n'):
continue
assert m.startswith('.include'), (af, m)
toremove.append(f)
print()
print("Will remove")
print("-"*75)
pprint.pprint(toremove)
print("-"*75)
print()
for fprefix in toremove:
for f in s8b_files:
if f.startswith(fprefix):
bf = os.path.join(S8B, f)
print("Removing", bf)
os.unlink(bf)