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
|
#!/usr/bin/env python3
import os
import re
import sys
warnings = 'dialyzer_warnings'
count = 0
checked = 0
if not os.path.isfile(warnings):
print('%s: file %s does not exist, exiting' % (sys.argv[0], warnings))
exit(0)
with open('known_dialyzer_warnings') as kw:
known = [line for line in [line.strip() for line in kw.readlines()] if line]
try:
with open(warnings) as dw:
for warn in dw:
warn = warn.strip()
if not warn:
continue
matched = None
if known:
pat = known.pop(0)
matched = re.match(pat, warn)
if not matched:
print(warn)
count += 1
checked += 1
except Exception as e:
print('%s: unexpected error: %s' % (sys.argv[0], str(e)), file=sys.stderr)
finally:
if checked and count == 0:
os.remove(warnings)
exit(count)
|