Thu Dec 15 09:15:27 EET 2005  [EMAIL PROTECTED]
  * Allow regexp flags for find and notfind.
New patches:

[Allow regexp flags for find and notfind.
[EMAIL PROTECTED] 
<
> {
hunk ./twill/commands.py 169
 
     raise TwillAssertionError("no links match to '%s'" % (what,))
 
-def find(what):
+def _parseFindFlags(flags):
+    KNOWN_FLAGS = {
+        'i': re.IGNORECASE,
+        'm': re.MULTILINE,
+        's': re.DOTALL,
+        }
+    finalFlags = 0
+    for char in flags:
+        try:
+            finalFlags |= KNOWN_FLAGS[char]
+        except IndexError:
+            raise TwillAssertionError("unknown 'find' flag %r" % char)
+    return finalFlags
+
+def find(what, flags=''):
     """
hunk ./twill/commands.py 185
-    >> find <regexp>
+    >> find <regexp> [<flags>]
     
     Succeed if the regular expression is on the page.  Sets the local
     variable __match__ to the matching text.
hunk ./twill/commands.py 189
+
+    Flags is a string consisting of the following characters:
+
+    * i: ignorecase
+    * m: multiline
+    * s: dotall
+
+    For explanations of these, please see the Python re module
+    documentation.
     """
hunk ./twill/commands.py 199
-    regexp = re.compile(what)
+    regexp = re.compile(what, _parseFindFlags(flags))
     page = browser.get_html()
 
     m = regexp.search(page)
hunk ./twill/commands.py 209
     global_dict, local_dict = get_twill_glocals()
     local_dict['__match__'] = m.group()
 
-def notfind(what):
+def notfind(what, flags=''):
     """
hunk ./twill/commands.py 211
-    >> notfind <regexp>
+    >> notfind <regexp> [<flags>]
     
     Fail if the regular expression is on the page.
     """
hunk ./twill/commands.py 215
-    regexp = re.compile(what)
+    regexp = re.compile(what, _parseFindFlags(flags))
     page = browser.get_html()
 
     if regexp.search(page):
}

Context:

[TAG release-0.8.1
[EMAIL PROTECTED] 
Patch bundle hash:
27362e425f21edfbd616c359b0301724b7987bb4
_______________________________________________
twill mailing list
[email protected]
http://lists.idyll.org/listinfo/twill

Reply via email to