[Pywikipedia-l] SVN: [5694] trunk/pywikipedia/wikipedia.py

russblau at svn.wikimedia.org russblau at svn.wikimedia.org
Tue Jul 8 20:42:20 UTC 2008


Revision: 5694
Author:   russblau
Date:     2008-07-08 20:42:20 +0000 (Tue, 08 Jul 2008)

Log Message:
-----------
Update redirectRegex() for MW 1.13 allowing spaces before the #REDIRECT directive

Modified Paths:
--------------
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2008-07-08 12:26:17 UTC (rev 5693)
+++ trunk/pywikipedia/wikipedia.py	2008-07-08 20:42:20 UTC (rev 5694)
@@ -5294,8 +5294,13 @@
         # arbitrary stuff, then a wikilink. The wikilink may contain
         # a label, although this is not useful.
 
-        return re.compile('\n*#' + redirKeywordsR +
-                                   '.*?\[\[(.+?)(?:\|.*?)?\]\]',
+        if self.versionnumber() > 12:
+            # in MW 1.13 (at least) a redirect directive can follow whitespace
+            prefix = r'[\n ]*'
+        else:
+            prefix = r'\n*'
+        return re.compile(prefix + '#' + redirKeywordsR
+                                 + '.*?\[\[(.+?)(?:\|.*?)?\]\]',
                           re.IGNORECASE | re.UNICODE | re.DOTALL)
 
     # The following methods are for convenience, so that you can access





More information about the Pywikipedia-l mailing list