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 compat
Change-Id: I0ca73f541c4fbd018aa9f2db1bf2229c15f13f13 --- M scripts/disambredir.py 1 file changed, 14 insertions(+), 10 deletions(-)
Approvals: Huji: Verified; Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/disambredir.py b/scripts/disambredir.py index faafec1..0a60870 100644 --- a/scripts/disambredir.py +++ b/scripts/disambredir.py @@ -5,16 +5,16 @@ each link that goes to a redirect page whether it should be replaced. """ # -# (C) André Engels and others, 2006-2009 +# (c) André Engels and others, 2006-2009 +# (c) pywikibot team, 2006-2014 # # Distributed under the terms of the MIT license. # __version__ = '$Id$' # +import re import pywikibot from pywikibot import pagegenerators -import re -from pywikibot import catlib
msg = { 'ar': u'تغيير التحويلات في صفحة توضيح', @@ -37,11 +37,13 @@
def treat(text, linkedPage, targetPage): - """ - Based on the method of the same name in solve_disambiguation.py. - """ + """ 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 - linkR = re.compile(r'[[(?P<title>[^]|#]*)(?P<section>#[^]|]*)?(|(?P<label>[^]]*))?]](?P<linktrail>' + linktrail + ')') + mysite = pywikibot.Site() + linktrail = mysite.linktrail() + linkR = re.compile( + 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: @@ -68,7 +70,8 @@ '\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)" % targetPage.title()) + u"Option (N=do not change, y=change link to \03{lightpurple}%s\03{default}, r=change and replace text, u=unlink)" + % targetPage.title()) try: choice = choice[0] except: @@ -102,8 +105,8 @@ if link_text[0].isupper(): new_page_title = targetPage.title() else: - new_page_title = targetPage.title()[0].lower() + \ - targetPage.title()[1:] + new_page_title = (targetPage.title()[0].lower() + + targetPage.title()[1:]) if replaceit and trailing_chars: newlink = "[[%s%s]]%s" % (new_page_title, section, trailing_chars) elif replaceit or (new_page_title == link_text and not section): @@ -176,6 +179,7 @@ pagestoload = [] pagestodo = []
+ if __name__ == "__main__": try: main()
pywikibot-commits@lists.wikimedia.org