jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[cleanup] cleanup wikisourcetext.py

- use single quotes for string constants
- keep lines beneath 80 chars
- use str.format() instead of modulo operator for changed lines

Inspired from Xqt's work here: I75587eede55fc487.

Change-Id: Ifa48942772339903e51f672bf1a7f1831f1b4911
---
M scripts/wikisourcetext.py
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/scripts/wikisourcetext.py b/scripts/wikisourcetext.py
index 4e2151f..2daacfb 100644
--- a/scripts/wikisourcetext.py
+++ b/scripts/wikisourcetext.py
@@ -103,8 +103,8 @@
@raises: pywikibot.Error
"""
if not isinstance(page, ProofreadPage):
- raise pywikibot.Error('Page %s must be a ProofreadPage object.'
- % page)
+ raise pywikibot.Error('Page {} must be a ProofreadPage object.'
+ .format(page))

summary = self.getOption('summary')

@@ -118,7 +118,8 @@

if (page.exists() and
not (self.getOption('ocr') and self.getOption('force'))):
- pywikibot.output('Page %s already exists, not adding!' % page)
+ pywikibot.output('Page {} already exists, not adding!'
+ .format(page))
else:
self.userPut(page, old_text, page.text, summary=summary,
show_diff=self.getOption('showdiff'))
@@ -156,7 +157,7 @@
elif arg == '-always':
options['always'] = True
else:
- pywikibot.output('Unknown argument %s' % arg)
+ pywikibot.output('Unknown argument ' + arg)

# index is mandatory.
if not index:
@@ -170,13 +171,14 @@

site = pywikibot.Site()
if not site.has_extension('ProofreadPage'):
- pywikibot.error('Site %s must have ProofreadPage extension.' % site)
+ pywikibot.error('Site {} must have ProofreadPage extension.'
+ .format(site))
return False

index = IndexPage(site, index)

if not index.exists():
- pywikibot.error("Page %s doesn't exist." % index)
+ pywikibot.error("Page {} doesn't exist.".format(index))
return False

# Parse pages param.
@@ -200,7 +202,8 @@

gen = itertools.chain(*gen_list)

- pywikibot.output('\nUploading text to %s\n' % index.title(as_link=True))
+ pywikibot.output('\nUploading text to {}\n'
+ .format(index.title(as_link=True)))

bot = UploadTextBot(gen, site=index.site, **options)
bot.run()

To view, visit change 462209. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifa48942772339903e51f672bf1a7f1831f1b4911
Gerrit-Change-Number: 462209
Gerrit-PatchSet: 2
Gerrit-Owner: D3r1ck01 <alangiderick@gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick@gmail.com>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)