jenkins-bot has submitted this change and it was merged.
Change subject: (bug 60610) define variables mysite, linktrail, pep8 changes
......................................................................
(bug 60610) define variables mysite, linktrail, pep8 changes
synchronized with core, rebased
Change-Id: I1b30397063e24f920b11ee6ae485cf0e72eb3fce
---
M disambredir.py
1 file changed, 8 insertions(+), 5 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
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: merged
Gerrit-Change-Id: I1b30397063e24f920b11ee6ae485cf0e72eb3fce
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Andre Engels <andreengels(a)gmail.com>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>