annotate unixSoft/bin/epylint @ 401:89c7236a0899

make-greek-tree: import shell script I've used on and off for years
author Augie Fackler <raf@durin42.com>
date Tue, 05 Apr 2016 10:21:19 -0400
parents 7f67cf332537
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import re
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import sys
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 from subprocess import Popen, PIPE
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 p = Popen("pylint -f parseable -r n --disable-msg-cat=C,R %s" %
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 sys.argv[1], shell = True, stdout = PIPE).stdout
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 for line in p.readlines():
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 match = re.search("\\[([WE])(, (.+?))?\\]", line)
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 if match:
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 kind = match.group(1)
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 func = match.group(3)
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 if kind == "W":
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 msg = "Warning"
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 else:
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 msg = "Error"
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 if func:
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 line = re.sub("\\[([WE])(, (.+?))?\\]",
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 "%s (%s):" % (msg, func), line)
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 else:
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 line = re.sub("\\[([WE])?\\]", "%s:" % msg, line)
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 print line,
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26
7f67cf332537 Started using pylint.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 p.close()