comparison tests/filterpyflakes.py @ 14173:419539ea79cb

test-pyflake: improve sorting algorithm
author timeless <timeless@mozdev.org>
date Sun, 01 May 2011 18:56:27 +0200
parents 82f0412ef7de
children b452abffcb15
comparison
equal deleted inserted replaced
14172:1a919c3271bf 14173:419539ea79cb
2 2
3 # Filter output by pyflakes to control which warnings we check 3 # Filter output by pyflakes to control which warnings we check
4 4
5 import sys, re 5 import sys, re
6 6
7 def makekey(message):
8 # "path/file:line: message"
9 match = re.search(r"(line \d+)", message)
10 line = ''
11 if match:
12 line = match.group(0)
13 message = re.sub(r"(line \d+)", '', message)
14 return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
15 r'\3:\5:\4:\1:\2:' + line,
16 message)
17
18 lines = []
7 for line in sys.stdin: 19 for line in sys.stdin:
8 # We whitelist tests 20 # We whitelist tests
9 if not re.search("imported but unused", line): 21 if not re.search("imported but unused", line):
10 continue 22 continue
23 lines.append(line)
24
25 for line in sorted(lines, key = makekey):
11 sys.stdout.write(line) 26 sys.stdout.write(line)
12 print 27 print