Xqt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/110331

Change subject: (bug 60610) define variables mysite, linkrail, pep8 changes
......................................................................

(bug 60610) define variables mysite, linkrail, pep8 changes

synchronized with core

Change-Id: I1b30397063e24f920b11ee6ae485cf0e72eb3fce
---
M disambredir.py
1 file changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat 
refs/changes/31/110331/1

diff --git a/disambredir.py b/disambredir.py
index ff120d9..373295a 100644
--- a/disambredir.py
+++ b/disambredir.py
@@ -40,8 +40,11 @@
 def treat(text, linkedPage, targetPage):
     """ Based on the method of the same name in solve_disambiguation.py. """
     # make a backup of the original text so we can show the changes later
+    mysite = pywikibot.getSite()
+    linktrail = mysite.linktrail()
     linkR = re.compile(
-        
r'\[\[(?P<title>[^\]\|#]*)(?P<section>#[^\]\|]*)?(\|(?P<label>[^\]]*))?\]\](?P<linktrail>'
 + linktrail + ')')
+        
r'\[\[(?P<title>[^\]\|#]*)(?P<section>#[^\]\|]*)?(\|(?P<label>[^\]]*))?\]\](?P<linktrail>%s)'
+        % linktrail)
     curpos = 0
     # This loop will run until we have finished the current page
     while True:
@@ -54,7 +57,7 @@
         if m.group('title') == '' or mysite.isInterwikiLink(m.group('title')):
             continue
         else:
-            actualLinkPage = pywikibot.Page(page.site(), m.group('title'))
+            actualLinkPage = pywikibot.Page(page.site, m.group('title'))
             # Check whether the link found is to page.
             if actualLinkPage != linkedPage:
                 continue
@@ -63,9 +66,9 @@
         context = 30
         # at the beginning of the link, start red color.
         # at the end of the link, reset the color to default
-        pywikibot.output(text[max(0, m.start() - context):m.start()] +
-                         '\03{lightred}' + text[m.start():m.end()] +
-                         '\03{default}' + text[m.end():m.end() + context])
+        pywikibot.output(text[max(0, m.start() - context): m.start()] +
+                         '\03{lightred}' + text[m.start(): m.end()] +
+                         '\03{default}' + text[m.end(): m.end() + context])
         while True:
             choice = pywikibot.input(
                 u"Option (N=do not change, y=change link to 
\03{lightpurple}%s\03{default}, r=change and replace text, u=unlink)"

-- 
To view, visit https://gerrit.wikimedia.org/r/110331
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b30397063e24f920b11ee6ae485cf0e72eb3fce
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to