Revision: 6137
Author:   russblau
Date:     2008-12-10 19:03:37 +0000 (Wed, 10 Dec 2008)

Log Message:
-----------
use global link_regex

Modified Paths:
--------------
    branches/rewrite/pywikibot/page.py
    branches/rewrite/pywikibot/pagegenerators.py
    branches/rewrite/pywikibot/textlib.py

Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py  2008-12-10 18:56:59 UTC (rev 6136)
+++ branches/rewrite/pywikibot/page.py  2008-12-10 19:03:37 UTC (rev 6137)
@@ -716,12 +716,11 @@
         """
         # This function does not exist in the API, so it has to be
         # implemented by screen-scraping
-        Rlink = re.compile(r'\[\[(?P<title>[^\]|[#<>{}]*)(\|.*?)?\]\]')
         if expand:
             text = self.expand_text()
         else:
             text = self.text
-        for linkmatch in Rlink.finditer(
+        for linkmatch in pywikibot.link_regex.finditer(
                             pywikibot.textlib.removeDisabledParts(text)):
             linktitle = linkmatch.group("title")
             link = Link(linktitle, self.site())

Modified: branches/rewrite/pywikibot/pagegenerators.py
===================================================================
--- branches/rewrite/pywikibot/pagegenerators.py        2008-12-10 18:56:59 UTC 
(rev 6136)
+++ branches/rewrite/pywikibot/pagegenerators.py        2008-12-10 19:03:37 UTC 
(rev 6137)
@@ -548,7 +548,7 @@
     if site is None:
         site = pywikibot.Site()
     f = codecs.open(filename, 'r', config.textfile_encoding)
-    for linkmatch in Rlink.finditer(f.read()):
+    for linkmatch in pywikibot.link_regex.finditer(f.read()):
         # If the link is in interwiki format, the Page object may reside
         # on a different Site than the default.
         # This makes it possible to work on different wikis using a single

Modified: branches/rewrite/pywikibot/textlib.py
===================================================================
--- branches/rewrite/pywikibot/textlib.py       2008-12-10 18:56:59 UTC (rev 
6136)
+++ branches/rewrite/pywikibot/textlib.py       2008-12-10 19:03:37 UTC (rev 
6137)
@@ -599,7 +599,6 @@
     count = 0
     Rtemplate = re.compile(
                 ur'{{(msg:)?(?P<name>[^{\|]+?)(\|(?P<params>[^{]+?))?}}')
-    Rlink = re.compile(ur'\[\[[^\]]+\]\]')
     Rmath = re.compile(ur'<math>[^<]+</math>')
     Rmarker = re.compile(ur'%s(\d+)%s' % (marker, marker))
     Rmarker2 = re.compile(ur'%s(\d+)%s' % (marker2, marker2))
@@ -640,12 +639,12 @@
             params = {}
             numbered_param = 1
             if paramString:
-                # Replace links to markers
+                # Replace wikilinks with markers
                 links = {}
                 count2 = 0
-                for m2 in Rlink.finditer(paramString):
+                for m2 in pywikibot.link_regex.finditer(paramString):
                     count2 += 1
-                    text = m2.group()
+                    text = m2.group(0)
                     paramString = paramString.replace(text,
                                     '%s%d%s' % (marker2, count2, marker2))
                     links[count2] = text



_______________________________________________
Pywikipedia-l mailing list
[EMAIL PROTECTED]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l

Reply via email to