File: dialyzer_checker

package info (click to toggle)
yaws 2.0.8%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,084 kB
  • sloc: erlang: 42,190; sh: 2,543; javascript: 1,459; ansic: 890; makefile: 878; lisp: 79; python: 34; xml: 12; php: 1
file content (38 lines) | stat: -rwxr-xr-x 873 bytes parent folder | download | duplicates (2)
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)