tests/filterpyflakes.py
author timeless <timeless@mozdev.org>
Sun, 01 May 2011 18:56:27 +0200
changeset 14173 419539ea79cb
parent 14140 82f0412ef7de
child 14175 b452abffcb15
permissions -rwxr-xr-x
test-pyflake: improve sorting algorithm

#!/usr/bin/env python

# Filter output by pyflakes to control which warnings we check

import sys, re

def makekey(message):
    # "path/file:line: message"
    match = re.search(r"(line \d+)", message)
    line = ''
    if match:
        line = match.group(0)
        message = re.sub(r"(line \d+)", '', message)
    return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
                  r'\3:\5:\4:\1:\2:' + line,
                  message)

lines = []
for line in sys.stdin:
    # We whitelist tests
    if not re.search("imported but unused", line):
        continue
    lines.append(line)

for line in sorted(lines, key = makekey):
    sys.stdout.write(line)
print