jenkins-bot merged this change.

View Change

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

- use str.format(...) instead of modulo for type specifier
arguments
- use "+" to concatenate strings in some cases

Change-Id: I45e86cfdfbb625be5ab64c8a12f0e398a3049f41
---
M scripts/djvutext.py
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/scripts/djvutext.py b/scripts/djvutext.py
index 1ede95a..1c0a5d4 100644
--- a/scripts/djvutext.py
+++ b/scripts/djvutext.py
@@ -117,8 +117,9 @@
summary = self.getOption('summary')
if page.exists() and not self.getOption('force'):
pywikibot.output(
- 'Page %s already exists, not adding!\n'
- 'Use -force option to overwrite the output page.' % page)
+ 'Page {} already exists, not adding!\n'
+ 'Use -force option to overwrite the output page.'
+ .format(page))
else:
self.userPut(page, old_text, new_text, summary=summary)

@@ -153,7 +154,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:
@@ -164,7 +165,7 @@
djvu_path = os.path.expanduser(djvu_path)
djvu_path = os.path.abspath(djvu_path)
if not os.path.exists(djvu_path):
- pywikibot.error('No such file or directory: %s' % djvu_path)
+ pywikibot.error('No such file or directory: ' + djvu_path)
return False
if os.path.isdir(djvu_path):
djvu_path = os.path.join(djvu_path, index)
@@ -173,7 +174,8 @@
djvu = DjVuFile(djvu_path)

if not djvu.has_text():
- pywikibot.error('No text layer in djvu file %s' % djvu.file_djvu)
+ pywikibot.error('No text layer in djvu file {}'
+ .format(djvu.file_djvu))
return False

# Parse pages param.
@@ -189,7 +191,8 @@

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_page = pywikibot.Page(site, index, ns=site.proofread_index_ns)
@@ -197,8 +200,8 @@
if not index_page.exists():
raise pywikibot.NoPage(index)

- pywikibot.output('uploading text from %s to %s'
- % (djvu.file_djvu, index_page.title(as_link=True)))
+ pywikibot.output('uploading text from {} to {}'
+ .format(djvu.file_djvu, index_page.title(as_link=True)))

bot = DjVuTextBot(djvu, index_page, pages, **options)
bot.run()

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I45e86cfdfbb625be5ab64c8a12f0e398a3049f41
Gerrit-Change-Number: 462698
Gerrit-PatchSet: 4
Gerrit-Owner: D3r1ck01 <alangiderick@gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)