[PATCH] tests: simplify and document the sorting of pyflake messages

Simon Heimberg simohe at besonet.ch
Fri Jun 14 17:07:15 CDT 2013


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1371247580 -7200
# Node ID 7a35b0923e5f76d96f8e789071adf81e4862301f
# Parent  f235457a184b6003495f1a5b6c1003590186f1ab
tests: simplify and document the sorting of pyflake messages

The pyflake messages are simply ordered by message type, path and line no.
The other details are not used for sorting.

The previous ordering looks complicated and illogically.
It was the following order ('\3:\5:\4:\1:\2:' + line):
  message (\3 and \5)
  var name (\4)
  path (\1)
  line no (\2)
  line reference
Ordering by var name before path looks illogically for me.

diff -r f235457a184b -r 7a35b0923e5f tests/filterpyflakes.py
--- a/tests/filterpyflakes.py	Sam Jun 15 00:04:51 2013 +0200
+++ b/tests/filterpyflakes.py	Sam Jun 15 00:06:20 2013 +0200
@@ -5,15 +5,12 @@
 import sys, re, os
 
 def makekey(message):
+    "order by: message type, path/file, lineno"
     # "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)
+    m = message.split(':', 2)
+    msg = re.sub("'.*'", "", re.sub(r"\([^\)]*\)", "", m[2]))
+        # dropped var name and bracket content from msg
+    return (msg, m[0], m[1])
 
 lines = []
 for line in sys.stdin:


More information about the Mercurial-devel mailing list