Browse files

Changes to eliminate long path names.

The new filtering capability allows the filenames to be
changed while processing the new output line.
  • Loading branch information...
1 parent 9df5965 commit 370b9d52007a1505e872addb39ac11216a49d72e @whart222 whart222 committed Nov 11, 2012
Showing with 20 additions and 1 deletion.
  1. +20 −1 doc/examples/test_examples.py
View
21 doc/examples/test_examples.py
@@ -4,12 +4,31 @@
import os
from os.path import dirname, abspath, basename
import sys
+import re
currdir = dirname(abspath(__file__))+os.sep
datadir = currdir
+compilerre = re.compile("^(?P<path>[^:]+)(?P<rest>:.*)$")
+dirre = re.compile("^([^%s]*/)*" % re.escape(os.sep))
+failure = re.compile("^(?P<prefix>.+)file=\"(?P<path>[^\"]+)\"(?P<suffix>.*)$")
+
+#print "FOO", dirre
def filter(line):
- return 'Running' in line or "IGNORE" in line
+ if 'Running' in line or "IGNORE" in line:
+ return True
+ pathmatch = compilerre.match(line) # see if we can remove the basedir
+ failmatch = failure.match(line) # see if we can remove the basedir
+ #print "HERE", pathmatch, failmatch
+ if failmatch:
+ parts = failmatch.groupdict()
+ #print "X", parts
+ line = "%s file=\"%s\" %s" % (parts['prefix'], dirre.sub("", parts['path']), parts['suffix'])
+ elif pathmatch:
+ parts = pathmatch.groupdict()
+ #print "Y", parts
+ line = dirre.sub("", parts['path']) + parts['rest']
+ return line
# Declare an empty TestCase class
class Test(unittest.TestCase): pass

0 comments on commit 370b9d5

Please sign in to comment.