[Checkins] SVN: z3c.testsetup/branches/new_markers/src/z3c/testsetup/util.py Accept restructured text comments as marker strings.

Uli Fouquet uli at gnufix.de
Tue Jan 6 19:06:10 EST 2009


Log message for revision 94555:
  Accept restructured text comments as marker strings.

Changed:
  U   z3c.testsetup/branches/new_markers/src/z3c/testsetup/util.py

-=-
Modified: z3c.testsetup/branches/new_markers/src/z3c/testsetup/util.py
===================================================================
--- z3c.testsetup/branches/new_markers/src/z3c/testsetup/util.py	2009-01-06 21:25:32 UTC (rev 94554)
+++ z3c.testsetup/branches/new_markers/src/z3c/testsetup/util.py	2009-01-07 00:06:10 UTC (rev 94555)
@@ -14,6 +14,7 @@
 """Helper functions for testsetup.
 """
 import sys
+import re
 from inspect import getmro, ismethod, getargspec
 from martian.scan import resolve
 
@@ -59,13 +60,20 @@
     Returns the found value or `None`. A markerstring has the form::
 
      :<Tag>: <Value>
+
+    or
+
+     .. :<Tag>: <Value>
+    
     """
     marker = ":%s:" % marker.lower()
+    rexp = re.compile('^(\.\.\s+)?%s(.*)$' % (marker,), re.IGNORECASE)
     for line in text.split('\n'):
         line = line.strip()
-        if not line.lower().startswith(marker):
+        result = rexp.match(line)
+        if result is None:
             continue
-        result = line[len(marker):].strip()
+        result = result.groups()[1].strip()
         return unicode(result)
     return None
 
@@ -77,7 +85,7 @@
      :<Tag>: <Value>
 
     """
-    return get_marker_from_string(marker, open(filepath, 'r').read())
+    return get_marker_from_string(marker, open(filepath, 'rb').read())
 
 def warn(text):
     print "Warning: ", text



More information about the Checkins mailing list