jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/445629 )
Change subject: [cleanup] Code cleanup
......................................................................
[cleanup] Code cleanup
- keep lines beneatch 80 chars
- remove preleading u from strings
- use single quotes
- use double quotes to prevent escape sequences
- use str.format() for changed lines
These parts are detached from Icd4c6a5
Change-Id: I57534cea11796f93dd9a9dfb758c47ba190ae917
---
M scripts/blockpageschecker.py
M scripts/disambredir.py
M scripts/editarticle.py
M scripts/flickrripper.py
M scripts/followlive.py
M tests/disambredir_tests.py
6 files changed, 295 insertions(+), 281 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index 0c4d5b8..bf22e22 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -79,8 +79,10 @@
templateSemiProtection = {
'cs': [r'\{\{(?:[Tt]emplate:|[Šš]ablona:|)([Dd]louhodobě[ _]p|[Pp])'
r'olozamčeno(|[^\}]*)\}\}\s*'],
- 'fr': [r'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Ss]emi[-
]?protection(|[^\}]*)\}\}'],
- 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccoparziale(?:|[
_]scad\|.*?|\|.*?)\}\}',
+ 'fr': [r'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Ss]emi[- ]?'
+ r'protection(|[^\}]*)\}\}'],
+ 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccoparziale'
+ r'(?:|[ _]scad\|.*?|\|.*?)\}\}',
r'\{\{(?:[Tt]emplate:|)[Aa]bp(?:|[ _]scad\|(?:.*?))\}\}'],
'ja': [r'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)半保護'
r'(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*'],
@@ -93,9 +95,11 @@
'fr':
[r'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Pp]rotection(|[^\}]*)\}\}',
r'\{\{(?:[Tt]emplate:|[Mm]odèle:|)(?:[Pp]age|[Aa]rchive|'
r'[Mm]odèle) protégée?(|[^\}]*)\}\}'],
- 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisoblocco(?:|[
_]scad\|(?:.*?)|minaccia|cancellata)\}\}',
+ 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisoblocco(?:|[ _]scad\|(?:.*?)'
+ r'|minaccia|cancellata)\}\}',
r'\{\{(?:[Tt]emplate:|)(?:[Cc][Tt]|[Cc]anc fatte|[Cc][Ee])\}\}',
- r'<div class="toccolours[ _]itwiki[ _]template[
_]avviso">\s*?[Qq]uesta pagina'],
+ r'<div class="toccolours[ _]itwiki[ _]template[
_]avviso">\s*?'
+ r'[Qq]uesta pagina'],
'ja': [r'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)保護(?:性急|)'
r'(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*'],
'sr': [r'\{\{(?:[Tt]emplate:|[Зз]акључано)\}\}']
@@ -103,14 +107,16 @@
# Regex to get the semi-protection move template
templateSemiMoveProtection = {
- 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[
_]scad\|.*?|\|.*?)\}\}'],
+ 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[
_]scad\|.*?'
+ r'|\|.*?)\}\}'],
'ja': [r'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動半保護'
r'(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*'],
}
# Regex to get the total-protection move template
templateTotalMoveProtection = {
- 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[
_]scad\|.*?|\|.*?)\}\}'],
+ 'it': [r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[
_]scad\|.*?'
+ r'|\|.*?)\}\}'],
'ja': [r'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動保護'
r'(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*'],
}
@@ -129,32 +135,33 @@
'fr': ['{{Semi-protection}}', '{{Protection}}', None, None,
None],
'it': ['{{Avvisobloccoparziale}}', '{{Avvisoblocco}}', None,
None,
'{{Protetta}}'],
- 'ja': [u'{{半保護}}', u'{{保護}}', u'{{移動半保護}}',
u'{{移動保護}}', None],
+ 'ja': ['{{半保護}}', '{{保護}}', '{{移動半保護}}',
'{{移動保護}}', None],
'sr': ['{{Закључано-анон}}', '{{Закључано}}', None, None,
None],
}
# Category where the bot will check
categoryToCheck = {
- 'ar': [u'تصنيف:محتويات محمية'],
+ 'ar': ['تصنيف:محتويات محمية'],
'cs': ['Kategorie:Wikipedie:Zamčené stránky',
'Kategorie:Wikipedie:Polozamčené stránky',
'Kategorie:Wikipedie:Dlouhodobě zamčené stránky',
'Kategorie:Wikipedie:Dlouhodobě polozamčené stránky'],
- 'fr': [u'Category:Page semi-protégée', u'Category:Page
protégée',
- u'Catégorie:Article protégé'],
- 'en': [u'Category:Wikipedia protected pages'],
- 'he': [u'קטגוריה:ויקיפדיה: דפים מוגנים',
- u'קטגוריה:ויקיפדיה: דפים מוגנים חלקית'],
- 'it': [u'Categoria:Pagine protette - scadute',
- u'Categoria:Pagine semiprotette', u'Categoria:Voci
protette'],
- 'ja': [u'Category:編集保護中の記事', u'Category:編集半保護中の記事',
- u'Category:移動保護中の記事'],
- 'pt': [u'Category:!Páginas protegidas',
- u'Category:!Páginas semiprotegidas'],
- 'sr': [u'Category:Странице закључане за анонимне кориснике',
u'Category:Закључане странице'],
+ 'fr': ['Category:Page semi-protégée', 'Category:Page
protégée',
+ 'Catégorie:Article protégé'],
+ 'en': ['Category:Wikipedia protected pages'],
+ 'he': ['קטגוריה:ויקיפדיה: דפים מוגנים',
+ 'קטגוריה:ויקיפדיה: דפים מוגנים חלקית'],
+ 'it': ['Categoria:Pagine protette - scadute',
+ 'Categoria:Pagine semiprotette', 'Categoria:Voci protette'],
+ 'ja': ['Category:編集保護中の記事', 'Category:編集半保護中の記事',
+ 'Category:移動保護中の記事'],
+ 'pt': ['Category:!Páginas protegidas',
+ 'Category:!Páginas semiprotegidas'],
+ 'sr': ['Category:Странице закључане за анонимне кориснике',
+ 'Category:Закључане странице'],
'ur': ['زمرہ:محفوظ شدہ صفحات'],
- 'zh': [u'Category:被保护的页面', u'Category:被保護的模板',
- u'Category:暂时不能移动的页面', u'Category:被半保护的页面'],
+ 'zh': ['Category:被保护的页面', 'Category:被保護的模板',
+ 'Category:暂时不能移动的页面', 'Category:被半保护的页面'],
}
# Check list to block the users that haven't set their preferences
@@ -197,7 +204,7 @@
def showQuest(page):
"""Ask for an editor and invoke it."""
quest = pywikibot.input_choice(
- u'Do you want to open the page?',
+ 'Do you want to open the page?',
[('with browser', 'b'), ('with gui', 'g'),
('no', 'n')], 'n',
automatic_quit=False)
if quest == 'b':
@@ -255,8 +262,8 @@
genFactory.handleArg(arg)
if config.mylang not in project_inserted:
- pywikibot.output(u"Your project is not supported by this script.\n"
- u"You have to edit the script and add it!")
+ pywikibot.output('Your project is not supported by this script.\n'
+ 'You have to edit the script and add it!')
return
site = pywikibot.Site()
@@ -277,7 +284,7 @@
generator = genFactory.getCombinedGenerator()
if not generator:
generator = []
- pywikibot.output(u'Loading categories...')
+ pywikibot.output('Loading categories...')
# Define the category if no other generator has been setted
for CAT in categories:
cat = pywikibot.Category(site, CAT)
@@ -285,7 +292,7 @@
gen = pagegenerators.CategorizedPageGenerator(cat)
for pageCat in gen:
generator.append(pageCat)
- pywikibot.output(u'Categories loaded, start!')
+ pywikibot.output('Categories loaded, start!')
# Main Loop
if not genFactory.nopreload:
generator = pagegenerators.PreloadingGenerator(generator,
@@ -299,7 +306,7 @@
pywikibot.output("%s doesn't exist! Skipping..." % pagename)
continue
except pywikibot.IsRedirectPage:
- pywikibot.output("%s is a redirect! Skipping..." % pagename)
+ pywikibot.output('{} is a redirect! Skipping...'.format(pagename))
if show:
showQuest(page)
continue
@@ -307,8 +314,9 @@
# PreloadingGenerator cannot set correctly page.editRestriction
# (see bug T57322)
# if not page.canBeEdited():
- # pywikibot.output("%s is sysop-protected : this account can't edit
"
- # "it! Skipping..." % pagename)
+ # pywikibot.output(
+ # "%s is sysop-protected : this account can't edit "
+ # "it! Skipping..." % pagename)
# continue
restrictions = page.protection()
try:
@@ -316,8 +324,8 @@
except KeyError:
editRestr = None
if not page.canBeEdited():
- pywikibot.output(u"%s is protected: "
- u"this account can't edit it! Skipping..."
+ pywikibot.output('%s is protected: '
+ "this account can't edit it! Skipping..."
% pagename)
continue
@@ -339,17 +347,17 @@
'"templateTotalProtection"'.format(site.sitename))
if TU:
- replaceToPerform = u'|'.join(TTP + TSP + TU)
+ replaceToPerform = '|'.join(TTP + TSP + TU)
else:
- replaceToPerform = u'|'.join(TTP + TSP)
+ replaceToPerform = '|'.join(TTP + TSP)
text, changes = re.subn('<noinclude>(%s)</noinclude>'
% replaceToPerform, '', text)
if changes == 0:
text, changes = re.subn('(%s)' % replaceToPerform, '',
text)
- msg = u'The page is editable for all'
+ msg = 'The page is editable for all'
if not moveBlockCheck:
- msg += u', deleting the template..'
- pywikibot.output(u'%s.' % msg)
+ msg += ', deleting the template..'
+ pywikibot.output(msg + '.')
elif editRestr[0] == 'sysop':
# total edit protection
@@ -366,8 +374,8 @@
'Missing "templateNoRegex"'.format(
site.sitename))
- pywikibot.output(u'The page is protected to the sysop, but the '
- u'template seems not correct. Fixing...')
+ pywikibot.output('The page is protected to the sysop, but the '
+ 'template seems not correct. Fixing...')
if TU:
text, changes = re.subn(TemplateInThePage[1], TNR[4], text)
else:
@@ -387,9 +395,9 @@
'This script is not localized to use it on \n{0}. '
'Missing "templateNoRegex"'.format(
site.sitename))
- pywikibot.output(u'The page is editable only for the '
- u'autoconfirmed users, but the template '
- u'seems not correct. Fixing...')
+ pywikibot.output('The page is editable only for the '
+ 'autoconfirmed users, but the template '
+ 'seems not correct. Fixing...')
if TU:
text, changes = re.subn(TemplateInThePage[1], TNR[4], text)
else:
@@ -408,30 +416,31 @@
changes = -1
if not moveRestr:
- pywikibot.output(u'The page is movable for all, deleting the '
- u'template...')
+ pywikibot.output('The page is movable for all, deleting the '
+ 'template...')
# Deleting the template because the page doesn't need it.
if TU:
- replaceToPerform = u'|'.join(TSMP + TTMP + TU)
+ replaceToPerform = '|'.join(TSMP + TTMP + TU)
else:
- replaceToPerform = u'|'.join(TSMP + TTMP)
+ replaceToPerform = '|'.join(TSMP + TTMP)
text, changes =
re.subn('<noinclude>(%s)</noinclude>'
% replaceToPerform, '', text)
if changes == 0:
- text, changes = re.subn('(%s)' % replaceToPerform,
'', text)
+ text, changes = re.subn('({})'.format(replaceToPerform),
+ '', text)
elif moveRestr[0] == 'sysop':
# move-total-protection
if (TemplateInThePage[0] == 'sysop-move' and TTMP) or \
(TemplateInThePage[0] == 'unique' and TU):
- pywikibot.output(u'The page is protected from moving to '
- u'the sysop, skipping...')
+ pywikibot.output('The page is protected from moving to '
+ 'the sysop, skipping...')
if TU:
# no changes needed, better to revert the old text.
text = oldtext
else:
- pywikibot.output(u'The page is protected from moving to '
- u'the sysop, but the template seems not '
- u'correct. Fixing...')
+ pywikibot.output('The page is protected from moving to '
+ 'the sysop, but the template seems not '
+ 'correct. Fixing...')
if TU:
text, changes = re.subn(TemplateInThePage[1], TNR[4],
text)
@@ -444,15 +453,15 @@
# move-semi-protection
if TemplateInThePage[0] == 'autoconfirmed-move' or \
TemplateInThePage[0] == 'unique':
- pywikibot.output(u'The page is movable only for the '
- u'autoconfirmed users, skipping...')
+ pywikibot.output('The page is movable only for the '
+ 'autoconfirmed users, skipping...')
if TU:
# no changes needed, better to revert the old text.
text = oldtext
else:
- pywikibot.output(u'The page is movable only for the '
- u'autoconfirmed users, but the template '
- u'seems not correct. Fixing...')
+ pywikibot.output('The page is movable only for the '
+ 'autoconfirmed users, but the template '
+ 'seems not correct. Fixing...')
if TU:
text, changes = re.subn(TemplateInThePage[1], TNR[4],
text)
@@ -461,7 +470,7 @@
text)
if changes == 0:
- # We tried to fix move-protection templates, but it did not work
+ # We tried to fix move-protection templates but it did not work
pywikibot.warning('No move-protection template could be found')
if oldtext != text:
@@ -470,8 +479,8 @@
'\n\n>>> {lightpurple}{0}{default} <<<',
page.title()))
pywikibot.showDiff(oldtext, text)
if not always:
- choice = pywikibot.input_choice(u'Do you want to accept these '
- u'changes?',
+ choice = pywikibot.input_choice('Do you want to accept these '
+ 'changes?',
[('Yes', 'y'),
('No', 'n'),
('All', 'a')],
'n')
if choice == 'a':
@@ -481,30 +490,30 @@
try:
page.put(text, commentUsed, force=True)
except pywikibot.EditConflict:
- pywikibot.output(u'Edit conflict! skip!')
+ pywikibot.output('Edit conflict! skip!')
break
except pywikibot.ServerError:
# Sometimes there is this error that's quite annoying
# because can block the whole process for nothing.
errorCount += 1
if errorCount < 5:
- pywikibot.output(u'Server Error! Wait..')
+ pywikibot.output('Server Error! Wait..')
time.sleep(3)
continue
else:
# Prevent Infinite Loops
- raise pywikibot.ServerError(u'Fifth Server Error!')
+ raise pywikibot.ServerError('Fifth Server Error!')
except pywikibot.SpamfilterError as e:
- pywikibot.output(u'Cannot change %s because of '
- u'blacklist entry %s'
+ pywikibot.output('Cannot change %s because of '
+ 'blacklist entry %s'
% (page.title(), e.url))
break
except pywikibot.LockedPage:
- pywikibot.output(u'The page is still protected. '
- u'Skipping...')
+ pywikibot.output('The page is still protected. '
+ 'Skipping...')
break
except pywikibot.PageNotSaved as error:
- pywikibot.output(u'Error putting page: %s'
+ pywikibot.output('Error putting page: %s'
% (error.args,))
break
else:
@@ -513,5 +522,5 @@
break
-if __name__ == "__main__":
+if __name__ == '__main__':
main()
diff --git a/scripts/disambredir.py b/scripts/disambredir.py
index e6a5590..cbb1920 100755
--- a/scripts/disambredir.py
+++ b/scripts/disambredir.py
@@ -12,7 +12,7 @@
"""
#
# (C) André Engels, 2006-2009
-# (C) Pywikibot team, 2006-2017
+# (C) Pywikibot team, 2006-2018
#
# Distributed under the terms of the MIT license.
#
@@ -41,15 +41,16 @@
return replace_callback
def treat_page(self):
- """Iterate over the linked pages and replace redirects
conditionally."""
+ """Iterate over linked pages and replace redirects
conditionally."""
text = self.current_page.text
for linked_page in self.current_page.linkedPages():
try:
target = linked_page.getRedirectTarget()
except (pywikibot.Error, pywikibot.SectionError):
continue
- # TODO: Work on all links at the same time (would mean that the user
- # doesn't get them ordered like in links but how they appear in the
page)
+ # TODO: Work on all links at the same time (would mean that the
+ # user doesn't get them ordered like in links but how they appear
+ # in the page)
text = textlib.replace_links(
text, self._create_callback(linked_page, target),
self.current_page.site)
@@ -85,5 +86,5 @@
bot.run()
-if __name__ == "__main__":
+if __name__ == '__main__':
main()
diff --git a/scripts/editarticle.py b/scripts/editarticle.py
index df951ad..4918e8d 100755
--- a/scripts/editarticle.py
+++ b/scripts/editarticle.py
@@ -56,18 +56,18 @@
my_args = pywikibot.handle_args(args)
parser = argparse.ArgumentParser(add_help=False)
- parser.add_argument("-r", "--edit_redirect",
"--edit-redirect",
- action="store_true", help="Ignore/edit
redirects")
- parser.add_argument("-p", "--page", help="Page to
edit")
- parser.add_argument("-w", "--watch",
action="store_true",
- help="Watch article after edit")
+ parser.add_argument('-r', '--edit_redirect',
'--edit-redirect',
+ action='store_true', help='Ignore/edit
redirects')
+ parser.add_argument('-p', '--page', help='Page to edit')
+ parser.add_argument('-w', '--watch',
action='store_true',
+ help='Watch article after edit')
# convenience positional argument so we can act like a normal editor
- parser.add_argument("wikipage", nargs="?", help="Page to
edit")
+ parser.add_argument('wikipage', nargs='?', help='Page to
edit')
self.options = parser.parse_args(my_args)
if self.options.page and self.options.wikipage:
- pywikibot.error("Multiple pages passed. Please specify a single "
- "page to edit.")
+ pywikibot.error('Multiple pages passed. Please specify a single '
+ 'page to edit.')
sys.exit(1)
self.options.page = self.options.page or self.options.wikipage
@@ -84,8 +84,8 @@
with open(fn, 'w') as fp:
fp.write(new)
pywikibot.output(
- "An edit conflict has arisen. Your edit has been saved to %s. "
- "Please try again." % fn)
+ 'An edit conflict has arisen. Your edit has been saved to {}. '
+ 'Please try again.'.format(fn))
def run(self):
"""Run the bot."""
@@ -93,12 +93,12 @@
try:
old = self.page.get(get_redirect=self.options.edit_redirect)
except pywikibot.NoPage:
- old = ""
+ old = ''
text_editor = TextEditor()
new = text_editor.edit(old)
if new and old != new:
pywikibot.showDiff(old, new)
- changes = pywikibot.input("What did you change?")
+ changes = pywikibot.input('What did you change?')
comment = i18n.twtranslate(self.site, 'editarticle-edit',
{'description': changes})
try:
@@ -107,7 +107,7 @@
except pywikibot.EditConflict:
self.handle_edit_conflict(new)
else:
- pywikibot.output("Nothing changed")
+ pywikibot.output('Nothing changed')
def main(*args):
@@ -123,5 +123,5 @@
app.run()
-if __name__ == "__main__":
+if __name__ == '__main__':
main()
diff --git a/scripts/flickrripper.py b/scripts/flickrripper.py
index 8453231..b75ec67 100755
--- a/scripts/flickrripper.py
+++ b/scripts/flickrripper.py
@@ -90,7 +90,7 @@
# xml.etree.ElementTree.dump(photoSizes)
return photoInfo, photoSizes
except flickrapi.exceptions.FlickrError:
- pywikibot.output(u'Flickr api problem, sleeping')
+ pywikibot.output('Flickr api problem, sleeping')
pywikibot.sleep(30)
@@ -169,14 +169,14 @@
'http://wikipedia.ramselehof.de/flinfo.php?%s' % parameters).text
-def getFilename(photoInfo, site=None, project=u'Flickr'):
+def getFilename(photoInfo, site=None, project='Flickr'):
"""Build a good filename for the upload based on the username and
title.
Prevents naming collisions.
"""
if not site:
- site = pywikibot.Site(u'commons', u'commons')
+ site = pywikibot.Site('commons', 'commons')
username =
photoInfo.find('photo').find('owner').attrib['username']
title = photoInfo.find('photo').find('title').text
if title:
@@ -196,10 +196,10 @@
description = description[:items]
title = cleanUpTitle(description)
else:
- title = u''
+ title = ''
# Should probably have the id of the photo as last resort.
- if pywikibot.Page(site, u'File:%s - %s - %s.jpg'
+ if pywikibot.Page(site, 'File:%s - %s - %s.jpg'
% (title, project, username)).exists():
i = 1
while True:
@@ -209,7 +209,7 @@
else:
return name
else:
- return u'%s - %s - %s.jpg' % (title, project, username)
+ return '{} - {} - {}.jpg'.format(title, project, username)
def cleanUpTitle(title):
@@ -239,43 +239,44 @@
return title
-def buildDescription(flinfoDescription=u'', flickrreview=False,
reviewer=u'',
- override=u'', addCategory=u'',
removeCategories=False):
+def buildDescription(flinfoDescription='', flickrreview=False,
reviewer='',
+ override='', addCategory='',
removeCategories=False):
"""Build the final description for the image.
The description is based on the info from flickrinfo and improved.
"""
- description = u'== {{int:filedesc}} ==\n%s' % flinfoDescription
+ description = '== {{int:filedesc}} ==\n%s' % flinfoDescription
if removeCategories:
description = textlib.removeCategoryLinks(description,
pywikibot.Site(
'commons',
'commons'))
if override:
- description = description.replace(u'{{cc-by-sa-2.0}}\n', u'')
- description = description.replace(u'{{cc-by-2.0}}\n', u'')
- description = description.replace(u'{{flickrreview}}\n', u'')
+ description = description.replace('{{cc-by-sa-2.0}}\n', '')
+ description = description.replace('{{cc-by-2.0}}\n', '')
+ description = description.replace('{{flickrreview}}\n', '')
description = description.replace(
'{{copyvio|Flickr, licensed as "All Rights Reserved" which is
not '
'a free license --~~~~}}\n',
'')
- description = description.replace(u'=={{int:license}}==',
- u'=={{int:license}}==\n' + override)
+ description = description.replace('=={{int:license}}==',
+ '=={{int:license}}==\n' + override)
elif flickrreview:
if reviewer:
description = description.replace(
'{{flickrreview}}',
'{{flickrreview|' + reviewer +
-
'|{{subst:CURRENTYEAR}}-{{subst:CURRENTMONTH}}-{{subst:CURRENTDAY2}}}}')
+ '|{{subst:CURRENTYEAR}}-{{subst:CURRENTMONTH}}'
+ '-{{subst:CURRENTDAY2}}}}')
if addCategory:
- description = description.replace(u'{{subst:unc}}\n', u'')
- description = description + u'\n[[Category:' + addCategory +
']]\n'
- description = description.replace(u'\r\n', u'\n')
+ description = description.replace('{{subst:unc}}\n', '')
+ description = description + '\n[[Category:' + addCategory +
']]\n'
+ description = description.replace('\r\n', '\n')
return description
-def processPhoto(flickr, photo_id=u'', flickrreview=False, reviewer=u'',
- override=u'', addCategory=u'', removeCategories=False,
+def processPhoto(flickr, photo_id='', flickrreview=False, reviewer='',
+ override='', addCategory='', removeCategories=False,
autonomous=False):
"""Process a single Flickr photo."""
if photo_id:
@@ -290,7 +291,8 @@
# Don't upload duplicate images, should add override option
duplicates = findDuplicateImages(photo)
if duplicates:
- pywikibot.output(u'Found duplicate image at %s' % duplicates.pop())
+ pywikibot.output('Found duplicate image at {}'
+ .format(duplicates.pop()))
else:
filename = getFilename(photoInfo)
flinfoDescription = getFlinfoDescription(photo_id)
@@ -316,14 +318,11 @@
newPhotoDescription = photoDescription
newFilename = filename
skip = False
- # pywikibot.output(newPhotoDescription)
- # if (pywikibot.Page(title=u'File:'+ filename,
site=pywikibot.Site()).exists()):
- # TODO: Check if the hash is the same and if not upload it under a different
name
- # pywikibot.output(u'File:' + filename + u' already exists!')
- # else:
+
# Do the actual upload
- # Would be nice to check before I upload if the file is already at Commons
- # Not that important for this program, but maybe for derived programs
+ # Would be nice to check before I upload if the file is already at
+ # Commons. Not that important for this program, but maybe for
+ # derived programs
if not skip:
bot = UploadRobot(photoUrl,
description=newPhotoDescription,
@@ -333,12 +332,12 @@
bot.upload_image(debug=False)
return 1
else:
- pywikibot.output(u'Invalid license')
+ pywikibot.output('Invalid license')
return 0
-def getPhotos(flickr, user_id=u'', group_id=u'',
photoset_id=u'',
- start_id='', end_id='', tags=u''):
+def getPhotos(flickr, user_id='', group_id='', photoset_id='',
+ start_id='', end_id='', tags=''):
"""Loop over a set of Flickr photos."""
found_start_id = not start_id
@@ -388,7 +387,7 @@
yield photo.attrib['id']
except flickrapi.exceptions.FlickrError:
gotPhotos = False
- pywikibot.output(u'Flickr api problem, sleeping')
+ pywikibot.output('Flickr api problem, sleeping')
pywikibot.sleep(30)
return
@@ -400,12 +399,12 @@
TODO : Need more.
"""
- pywikibot.output(
- u"Flickrripper is a tool to transfer flickr photos to Wikimedia
Commons")
- pywikibot.output(u"-group_id:<group_id>\n")
- pywikibot.output(u"-photoset_id:<photoset_id>\n")
- pywikibot.output(u"-user_id:<user_id>\n")
- pywikibot.output(u"-tags:<tag>\n")
+ pywikibot.output('Flickrripper is a tool to transfer flickr photos to '
+ 'Wikimedia Commons')
+ pywikibot.output('-group_id:<group_id>\n')
+ pywikibot.output('-photoset_id:<photoset_id>\n')
+ pywikibot.output('-user_id:<user_id>\n')
+ pywikibot.output('-tags:<tag>\n')
return
@@ -424,22 +423,24 @@
if not config.flickr['api_key']:
pywikibot.output('Flickr api key not found! Get yourself an api key')
pywikibot.output(
- 'Any flickr user can get a key at
https://www.flickr.com/services/api/keys/apply/')
+ 'Any flickr user can get a key at '
+ 'https://www.flickr.com/services/api/keys/apply/')
return
if 'api_secret' in config.flickr and config.flickr['api_secret']:
- flickr = flickrapi.FlickrAPI(config.flickr['api_key'],
config.flickr['api_secret'])
+ flickr = flickrapi.FlickrAPI(config.flickr['api_key'],
+ config.flickr['api_secret'])
else:
pywikibot.output('Accessing public content only')
flickr = flickrapi.FlickrAPI(config.flickr['api_key'])
- group_id = u''
- photoset_id = u''
- user_id = u''
- start_id = u''
- end_id = u''
- tags = u''
- addCategory = u''
+ group_id = ''
+ photoset_id = ''
+ user_id = ''
+ start_id = ''
+ end_id = ''
+ tags = ''
+ addCategory = ''
removeCategories = False
autonomous = False
totalPhotos = 0
@@ -460,61 +461,62 @@
elif 'commons' in config.usernames['commons']:
reviewer = config.usernames['commons']['commons']
else:
- reviewer = u''
+ reviewer = ''
# Should be renamed to overrideLicense or something like that
- override = u''
+ override = ''
for arg in local_args:
if arg.startswith('-group_id'):
if len(arg) == 9:
- group_id = pywikibot.input(u'What is the group_id of the pool?')
+ group_id = pywikibot.input('What is the group_id of the pool?')
else:
group_id = arg[10:]
elif arg.startswith('-photoset_id'):
if len(arg) == 12:
- photoset_id = pywikibot.input(u'What is the photoset_id?')
+ photoset_id = pywikibot.input('What is the photoset_id?')
else:
photoset_id = arg[13:]
elif arg.startswith('-user_id'):
if len(arg) == 8:
user_id = pywikibot.input(
- u'What is the user_id of the flickr user?')
+ 'What is the user_id of the flickr user?')
else:
user_id = arg[9:]
elif arg.startswith('-start_id'):
if len(arg) == 9:
start_id = pywikibot.input(
- u'What is the id of the photo you want to start at?')
+ 'What is the id of the photo you want to start at?')
else:
start_id = arg[10:]
elif arg.startswith('-end_id'):
if len(arg) == 7:
end_id = pywikibot.input(
- u'What is the id of the photo you want to end at?')
+ 'What is the id of the photo you want to end at?')
else:
end_id = arg[8:]
elif arg.startswith('-tags'):
if len(arg) == 5:
tags = pywikibot.input(
- u'What is the tag you want to filter out (currently only one
supported)?')
+ 'What is the tag you want to filter out (currently only '
+ 'one supported)?')
else:
tags = arg[6:]
elif arg == '-flickrreview':
flickrreview = True
elif arg.startswith('-reviewer'):
if len(arg) == 9:
- reviewer = pywikibot.input(u'Who is the reviewer?')
+ reviewer = pywikibot.input('Who is the reviewer?')
else:
reviewer = arg[10:]
elif arg.startswith('-override'):
if len(arg) == 9:
- override = pywikibot.input(u'What is the override text?')
+ override = pywikibot.input('What is the override text?')
else:
override = arg[10:]
elif arg.startswith('-addcategory'):
if len(arg) == 12:
addCategory = pywikibot.input(
- u'What category do you want to add?')
+ 'What category do you want to add?')
else:
addCategory = arg[13:]
elif arg == '-removecategories':
@@ -531,10 +533,10 @@
totalPhotos += 1
else:
usage()
- pywikibot.output(u'Finished running')
- pywikibot.output(u'Total photos: ' + str(totalPhotos))
- pywikibot.output(u'Uploaded photos: ' + str(uploadedPhotos))
+ pywikibot.output('Finished running')
+ pywikibot.output('Total photos: ' + str(totalPhotos))
+ pywikibot.output('Uploaded photos: ' + str(uploadedPhotos))
-if __name__ == "__main__":
+if __name__ == '__main__':
main()
diff --git a/scripts/followlive.py b/scripts/followlive.py
index 677546d..354ad32 100644
--- a/scripts/followlive.py
+++ b/scripts/followlive.py
@@ -107,37 +107,37 @@
'pos': 'top'},
},
'fr': {
- u'{{suppression}}': {
- 'msg': u'à l\'aide du robot: cet article devrait être
supprimé',
+ '{{suppression}}': {
+ 'msg': "à l'aide du robot: cet article devrait être
supprimé",
'pos': 'top'},
- u'{{à vérifier}}': {
- 'msg': u'à l\'aide du robot: cet article est à
vérifier',
+ '{{à vérifier}}': {
+ 'msg': "à l'aide du robot: cet article est à
vérifier",
'pos': 'top'},
- u'{{ébauche}}': {
- 'msg': u'à l\'aide du robot: cet article est une
ébauche',
+ '{{ébauche}}': {
+ 'msg': "à l'aide du robot: cet article est une
ébauche",
'pos': 'top'},
},
'he': {
- u'{{מחק}}': {
- 'msg': u'יש למחוק ערך זה',
+ '{{מחק}}': {
+ 'msg': 'יש למחוק ערך זה',
'pos': 'top'
},
- u'{{לשכתב}}': {
- 'msg': u'ערך זה דורש שכתוב',
+ '{{לשכתב}}': {
+ 'msg': 'ערך זה דורש שכתוב',
'pos': 'top'
},
- u'{{קצרמר}}': {
- 'msg': u'ערך זה הוא קצרמר',
+ '{{קצרמר}}': {
+ 'msg': 'ערך זה הוא קצרמר',
'pos': 'bottom'
},
- u'{{הבהרת חשיבות}}': {
- 'msg': u'חשיבותו של ערך זה אינה ברורה.',
+ '{{הבהרת חשיבות}}': {
+ 'msg': 'חשיבותו של ערך זה אינה ברורה.',
'pos': 'top'
},
- u'{{עריכה}}': {
- 'msg': u'ערך זה דורש עריכה',
+ '{{עריכה}}': {
+ 'msg': 'ערך זה דורש עריכה',
'pos': 'top'},
},
'ia': {
@@ -154,110 +154,110 @@
'pos': 'bottom'},
},
'nl': {
- u'{{weg}}': {
+ '{{weg}}': {
'msg': '{weg}',
'pos': 'top'
},
- u'{{nuweg}}': {
+ '{{nuweg}}': {
'msg': '{nuweg}',
'pos': 'top'
},
- u'{{wiu}}': {
+ '{{wiu}}': {
'msg': '{wiu}',
'pos': 'top'
},
- u'{{beg}}': {
+ '{{beg}}': {
'msg': '{beg}',
'pos': 'bottom'
},
- u'{{wikify}}': {
+ '{{wikify}}': {
'msg': '{wikify}',
'pos': 'top'
},
- u'{{wb}}': {
+ '{{wb}}': {
'msg': '{wb}',
'pos': 'top'
},
},
'pl': {
- u'{{ek}}': {
- 'msg': u'[[Kategoria:Ekspresowe kasowanko|ek]]',
+ '{{ek}}': {
+ 'msg': '[[Kategoria:Ekspresowe kasowanko|ek]]',
'pos': 'top'
},
- u'{{dopracować}}': {
- 'msg': u'Dopracować',
+ '{{dopracować}}': {
+ 'msg': 'Dopracować',
'pos': 'top'
},
- u'{{linki}}': {
- 'msg': u'Linki wewnętrzne do dodania',
+ '{{linki}}': {
+ 'msg': 'Linki wewnętrzne do dodania',
'pos': 'top'
},
- u'{{źródła}}': {
- 'msg': u'W artykule brakuje źródeł',
+ '{{źródła}}': {
+ 'msg': 'W artykule brakuje źródeł',
'pos': 'top'
},
- u'{{stub}}': {
- 'msg': u'stub (zalążek)',
+ '{{stub}}': {
+ 'msg': 'stub (zalążek)',
'pos': 'bottom'
},
},
'pt': {
- u'{{wikificar}}': {
+ '{{wikificar}}': {
'msg': 'Assistida por bot: {{wikificar}}',
'pos': 'top'},
- u'{{reciclar}}': {
+ '{{reciclar}}': {
'msg': 'Assistida por bot: {{reciclar}}',
'pos': 'top'},
- u'{{lixo|~~~~}}': {
+ '{{lixo|~~~~}}': {
'msg': 'Assistida por bot: {{lixo}}',
'pos': 'top'},
- u'{{revisão}}': {
+ '{{revisão}}': {
'msg': 'Assistida por bot: {{revisão}}',
'pos': 'top'},
- u'{{impróprio}}': {
+ '{{impróprio}}': {
'msg': 'Assistida por bot: {{impróprio}}',
'pos': 'top'},
- u'{{apagar vaidade}}': {
+ '{{apagar vaidade}}': {
'msg': 'Assistida por bot: {{apagar vaidade}}',
'pos': 'top'},
},
'sv': {
- u'{{radera}}': {
- 'msg': u'Robotkoll: Artikeln bör raderas',
+ '{{radera}}': {
+ 'msg': 'Robotkoll: Artikeln bör raderas',
'pos': 'top'},
- u'{{städa}}': {
- 'msg': u'Robotkoll: Artikeln bör städas',
+ '{{städa}}': {
+ 'msg': 'Robotkoll: Artikeln bör städas',
'pos': 'top'},
- u'{{stub}}': {
- 'msg': u'Robotkoll: Artikeln är en stubbe',
+ '{{stub}}': {
+ 'msg': 'Robotkoll: Artikeln är en stubbe',
'pos': 'bottom'},
- u'{{subst:relevanskontroll}}': {
+ '{{subst:relevanskontroll}}': {
'msg': 'Robotkoll: Artikeln bör kollas mot '
'[[WP:REL|Wikipedias relevanskriterier]].',
'pos': 'top'},
- u'{{verifieras}}': {
- 'msg': u'Robotkoll: Artikeln bör verifieras',
+ '{{verifieras}}': {
+ 'msg': 'Robotkoll: Artikeln bör verifieras',
'pos': 'top'},
- u'{{språkvård}}': {
- 'msg': u'Robotkoll: Artikeln bör språkvårdas',
+ '{{språkvård}}': {
+ 'msg': 'Robotkoll: Artikeln bör språkvårdas',
'pos': 'top'},
- u'{{Källor}}': {
- 'msg': u'Robotkoll: Artikeln behöver källor',
+ '{{Källor}}': {
+ 'msg': 'Robotkoll: Artikeln behöver källor',
'pos': 'bottom'},
- u'{{wikify}}': {
- 'msg': u'Robotkoll: Artikeln behöver wikifieras',
+ '{{wikify}}': {
+ 'msg': 'Robotkoll: Artikeln behöver wikifieras',
'pos': 'top'},
},
'ur': {
@@ -278,57 +278,57 @@
'pos': 'top'},
},
'zh': {
- u'{{Delete}}': {
- 'msg': u'機器人掛上模板: 本文應被刪除。',
+ '{{Delete}}': {
+ 'msg': '機器人掛上模板: 本文應被刪除。',
'pos': 'top'},
- u'{{subst:Cleanup/auto}}': {
- 'msg': u'機器人掛上模板: 本文需清理',
+ '{{subst:Cleanup/auto}}': {
+ 'msg': '機器人掛上模板: 本文需清理',
'pos': 'top'},
- u'{{subst:Uncategorized/auto}}': {
- 'msg': u'機器人掛上模板: 本頁需要適當的頁面分類',
- 'pos': u'bottom'},
-
- u'{{subst:Notability/auto}}': {
- 'msg': u'機器人掛上模板: 本條目主題未突顯其知名度或顯著性',
- 'pos': 'top'},
-
- u'{{subst:refimprove/auto}}': {
- 'msg': u'機器人掛上模板: 本條目参考文献不足',
- 'pos': 'top'},
-
- u'{{copyedit}}': {
- 'msg': u'機器人掛上模板: 本條目或段落需要校對',
- 'pos': 'top'},
-
- u'{{subst:Unreferenced/auto}}': {
- 'msg': u'機器人掛上模板: 本條目沒有列出任何參考或來源',
- 'pos': 'top'},
-
- u'{{subst:wikify/auto}}': {
- 'msg': u'機器人掛上模板: 本條目需要維基化',
- 'pos': 'top'},
-
- u'{{subst:Notchinese/auto}}': {
- 'msg': u'機器人掛上模板: 本条目没有翻译',
- 'pos': 'top'},
-
- u'{{subst:Substub/auto}}': {
- 'msg': u'機器人掛上模板: 小小作品',
- 'pos': 'top'},
-
- u'{{stub}}': {
- 'msg': u'機器人掛上模板: 本文是小作品',
+ '{{subst:Uncategorized/auto}}': {
+ 'msg': '機器人掛上模板: 本頁需要適當的頁面分類',
'pos': 'bottom'},
- u'{{notchinesetitle}}': {
- 'msg': u'機器人掛上模板: 本条目名称需要翻译成中文',
+
+ '{{subst:Notability/auto}}': {
+ 'msg': '機器人掛上模板: 本條目主題未突顯其知名度或顯著性',
'pos': 'top'},
- u'{{subst:Translating/auto}}': {
- 'msg': u'機器人掛上模板: 本条目没有翻译完成',
+
+ '{{subst:refimprove/auto}}': {
+ 'msg': '機器人掛上模板: 本條目参考文献不足',
'pos': 'top'},
- u'{{fansite}}': {
- 'msg': u'機器人掛上模板: 本条目內容類似愛好者網站',
+
+ '{{copyedit}}': {
+ 'msg': '機器人掛上模板: 本條目或段落需要校對',
+ 'pos': 'top'},
+
+ '{{subst:Unreferenced/auto}}': {
+ 'msg': '機器人掛上模板: 本條目沒有列出任何參考或來源',
+ 'pos': 'top'},
+
+ '{{subst:wikify/auto}}': {
+ 'msg': '機器人掛上模板: 本條目需要維基化',
+ 'pos': 'top'},
+
+ '{{subst:Notchinese/auto}}': {
+ 'msg': '機器人掛上模板: 本条目没有翻译',
+ 'pos': 'top'},
+
+ '{{subst:Substub/auto}}': {
+ 'msg': '機器人掛上模板: 小小作品',
+ 'pos': 'top'},
+
+ '{{stub}}': {
+ 'msg': '機器人掛上模板: 本文是小作品',
+ 'pos': 'bottom'},
+ '{{notchinesetitle}}': {
+ 'msg': '機器人掛上模板: 本条目名称需要翻译成中文',
+ 'pos': 'top'},
+ '{{subst:Translating/auto}}': {
+ 'msg': '機器人掛上模板: 本条目没有翻译完成',
+ 'pos': 'top'},
+ '{{fansite}}': {
+ 'msg': '機器人掛上模板: 本条目內容類似愛好者網站',
'pos': 'top'},
},
@@ -336,7 +336,7 @@
# do nothing if this is in it
done = {
- 'ar': (u'{{شطب}}', u'{{حذف}}', u'{{خرق}}'),
+ 'ar': ('{{شطب}}', '{{حذف}}', '{{خرق}}'),
'en': ('{{VfD}}', '{{AfD}}', '{{AfD1}}',
'{{cleanup}}', '{{nonsense}}',
'{{deletedpage}}', '{{db-reason}}', '{{notability}}',
'{{not verified}}', '{{unreferenced}}',
'{{db-empty}}',
@@ -360,21 +360,21 @@
'{{db-contact}}', '{{db-i2}}', '{{db-i1}}',
'{{communityuseonly}}',
'{{db-disparage}}', '{{db-web}}', '{{db-userreq}}',
'{{db-nouser}}',
'{{db-u3}}', '{{db-unfree}}'),
- 'fr': (u'{{suppression}}', u'{{à vérifier}}',
u'{{ébauche}}'),
- 'ia': (u'{{Eliminar}}', u'{{Revision}}',
u'{{Stub}}'),
- 'he': (u'{{מחק}}', u'{{פירושונים}}', u'{{הצבעת
מחיקה}}'),
+ 'fr': ('{{suppression}}', '{{à vérifier}}',
'{{ébauche}}'),
+ 'ia': ('{{Eliminar}}', '{{Revision}}', '{{Stub}}'),
+ 'he': ('{{מחק}}', '{{פירושונים}}', '{{הצבעת
מחיקה}}'),
'nl': ('{{nuweg}}', '{{weg}}', '{{wb}}',
'{{wiu}}', '{{nocat}}'),
- 'pl': ('{{ek}}', u'{{dopracować}}', '{{linki}}',
u'{{źródła}}',
- u'{{stub}}'),
- 'pt': ('{{wikificar}}', '{{reciclar}}', '{{lixo}}',
u'{{revisão}}',
- u'{{impróprio}}', u'{{apagar vaidade}}'),
- 'sv': (u'{{radera', u'{{Radera', u'{{städa}}',
u'{{stub}}',
- u'{{verifieras}}', u'{{språkvård}}', u'{{Källor',
u'{{källor',
- u'{{wikify}}', u'{{Ickewiki}}', u'{{ickewiki}}',
u'{{Wikify}}'),
- 'zh': (u'{{VfD}}', u'{{AfD}}', u'{{unreferenced}}',
u'{{db-reason}}',
+ 'pl': ('{{ek}}', '{{dopracować}}', '{{linki}}',
'{{źródła}}',
+ '{{stub}}'),
+ 'pt': ('{{wikificar}}', '{{reciclar}}', '{{lixo}}',
'{{revisão}}',
+ '{{impróprio}}', '{{apagar vaidade}}'),
+ 'sv': ('{{radera', '{{Radera', '{{städa}}',
'{{stub}}',
+ '{{verifieras}}', '{{språkvård}}', '{{Källor',
'{{källor',
+ '{{wikify}}', '{{Ickewiki}}', '{{ickewiki}}',
'{{Wikify}}'),
+ 'zh': ('{{VfD}}', '{{AfD}}', '{{unreferenced}}',
'{{db-reason}}',
'{{cleanup}}', '{{stub}}', '{{uncategorized}}',
'{{notability}}',
- u'{{copyedit}}', u'{{unreferenced}}', u'{{wikify}}',
- u'{{Translating}}', u'{{copyvio}}',
u'{{Notchinese}}'),
+ '{{copyedit}}', '{{unreferenced}}', '{{wikify}}',
+ '{{Translating}}', '{{copyvio}}', '{{Notchinese}}'),
}
# TODO: merge 'done' with 'templates' above
@@ -416,16 +416,16 @@
try:
self.content = self.page.get()
except pywikibot.IsRedirectPage:
- pywikibot.output(u'Already redirected, skipping.')
+ pywikibot.output('Already redirected, skipping.')
return
except pywikibot.NoPage:
- pywikibot.output(u'Already deleted')
+ pywikibot.output('Already deleted')
return
for d in pywikibot.translate(self.site.code, done):
if d in self.content:
pywikibot.output(
- u'Found: "%s" in content, nothing necessary' % d)
+ 'Found: "{}" in content, nothing
necessary'.format(d))
return
pywikibot.output('---- Start content ----------------')
pywikibot.output(self.content)
@@ -439,7 +439,7 @@
if answer == 'q':
raise QuitKeyboardInterrupt
if answer == 'd':
- pywikibot.output(u'Trying to delete page [[%s]].'
+ pywikibot.output('Trying to delete page [[%s]].'
% self.page.title())
self.page.delete()
return
@@ -450,7 +450,8 @@
self.userPut(self.page, old, new, summary=msg)
return
if answer == 'b':
- pywikibot.output(u'Blanking page [[%s]].' % self.page.title())
+ pywikibot.output('Blanking page [[{}]].'
+ .format(self.page.title()))
try:
self.page.put('',
summary=i18n.twtranslate(
@@ -466,14 +467,14 @@
pywikibot.output('Page correct ! Proceeding with next pages.')
return
# Check user input:
- if answer[0] == 'u':
+ if answer[0] == '':
# Answer entered as an utf8 string
answer = answer[1:]
try:
choices = answer.split(',')
except ValueError:
# User entered wrong value
- pywikibot.error(u'"%s" is not valid' % answer)
+ pywikibot.error('"{}" is not
valid'.format(answer))
continue
# test input
for choice in choices:
@@ -484,9 +485,9 @@
else:
answered = (x >= 1 and x <= len(self.questionlist))
if not answered:
- pywikibot.error(u'"%s" is not valid' % answer)
+ pywikibot.error('"{}" is not valid'.format(answer))
continue
- summary = u''
+ summary = ''
for choice in choices:
answer = int(choice)
# grab the template parameters
@@ -507,7 +508,7 @@
pywikibot.output('Probably added %s' % self.questionlist[answer])
self.page.put(self.content, summary=summary)
- pywikibot.output(u'with comment %s\n' % summary)
+ pywikibot.output('with comment {}\n'.format(summary))
def treat_page(self):
"""Process one page."""
diff --git a/tests/disambredir_tests.py b/tests/disambredir_tests.py
index 8e108bf..4a8af06 100644
--- a/tests/disambredir_tests.py
+++ b/tests/disambredir_tests.py
@@ -5,7 +5,7 @@
These tests write to the wiki.
"""
#
-# (C) Pywikibot team, 2015
+# (C) Pywikibot team, 2015-2018
#
# Distributed under the terms of the MIT license.
#
@@ -25,9 +25,9 @@
"""
Test cases for DisambigurationRedirectBot.
- It patches the bot instances in such a way that there is no user interaction
- required and it can be run autonomously. It also does not actually write to
- the wiki.
+ It patches the bot instances in such a way that there is no user
+ interaction required and it can be run autonomously. It also does not
+ actually write to the wiki.
"""
family = 'wikipedia'
@@ -133,12 +133,13 @@
"""Test replacing target including section."""
self._patch_create_callback('s')
self.bot.run()
- self.assertEqual(self.page.text,
- '[[Main Page|Bar]]\n'
- '[[Main Page|Baz]]\n'
- '[[Main Page#What we do on this
wiki|User:BobBot/Redir2]]\n'
- '[[Main Page#What we do on this
wiki|user:BobBot/Redir2]]\n'
- '[[Main Page|Label]]\n')
+ self.assertEqual(
+ self.page.text,
+ '[[Main Page|Bar]]\n'
+ '[[Main Page|Baz]]\n'
+ '[[Main Page#What we do on this wiki|User:BobBot/Redir2]]\n'
+ '[[Main Page#What we do on this wiki|user:BobBot/Redir2]]\n'
+ '[[Main Page|Label]]\n')
def test_replace_all(self):
"""Test replacing target including section and
label."""
--
To view, visit
https://gerrit.wikimedia.org/r/445629
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I57534cea11796f93dd9a9dfb758c47ba190ae917
Gerrit-Change-Number: 445629
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot