jenkins-bot merged this change.

View Change

Approvals: D3r1ck01: Looks good to me, approved jenkins-bot: Verified
[cleanup] remove preleading empty string in front of format method

- remove superfluous preleading empty string in front of format method
- also remove Python 2.6 compatibility format string indices there

Change-Id: I9d06e06a92cc1ae3a2232066205f054ddc859c3d
---
M pywikibot/__init__.py
M pywikibot/page/__init__.py
M pywikibot/site/__init__.py
M pywikibot/textlib.py
M scripts/harvest_template.py
M scripts/redirect.py
M scripts/reflinks.py
M scripts/templatecount.py
M tests/wikistats_tests.py
9 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 6a0b4e1..80b0122 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1377,9 +1377,9 @@
try:
_putthread.join(1)
except KeyboardInterrupt:
- if input_yn('There are {0} pages remaining in the queue. '
- 'Estimated time remaining: {1}\nReally exit?'
- ''.format(*remaining()),
+ if input_yn('There are {} pages remaining in the queue. '
+ 'Estimated time remaining: {}\nReally exit?'
+ .format(*remaining()),
default=False, automatic_quit=False):
return

diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 573f24d..9d46cc3 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -2692,7 +2692,7 @@
**info.__dict__)
lines.append('| {timestamp} || {user} || {dimension} |'
'| <nowiki>{comment}</nowiki>'
- ''.format(dimension=dimension, **info.__dict__))
+ .format(dimension=dimension, **info.__dict__))
return ('{| class="wikitable"\n'
'! {{int:filehist-datetime}} || {{int:filehist-user}} |'
'| {{int:filehist-dimensions}} || {{int:filehist-comment}}\n'
@@ -4812,8 +4812,8 @@
if hasattr(page, '_item'):
return page._item
if not page.site.has_data_repository:
- raise pywikibot.WikiBaseError('{0} has no data repository'
- ''.format(page.site))
+ raise pywikibot.WikiBaseError('{} has no data repository'
+ .format(page.site))
if not lazy_load and not page.exists():
raise pywikibot.NoPage(page)

diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index d8896cb..7dcff1c 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -7811,8 +7811,8 @@
'Site method with baserevid', 'claim with on_item set', depth=3,
since='20150910')
if baserevid != claim.on_item.latest_revision_id:
- warn('Using baserevid {0} instead of claim baserevid {1}'
- ''.format(baserevid, claim.on_item.latest_revision_id),
+ warn('Using baserevid {} instead of claim baserevid {}'
+ .format(baserevid, claim.on_item.latest_revision_id),
UserWarning, 3)

return baserevid
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 79775dc..9054917 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -445,9 +445,9 @@
replacement += new[last:group_match.start()]
replacement += match.group(group_id) or ''
except IndexError:
- raise IndexError(
- 'Invalid group reference: {0}\nGroups found: {1}'
- ''.format(group_id, match.groups()))
+ raise IndexError('Invalid group reference: {}\n'
+ 'Groups found: {}'
+ .format(group_id, match.groups()))
last = group_match.end()
replacement += new[last:]

diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index ce50f91..e8606de 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -88,7 +88,7 @@
-multi
"""
#
-# (C) Pywikibot team, 2013-2019
+# (C) Pywikibot team, 2013-2020
#
# Distributed under the terms of MIT License.
#
@@ -335,8 +335,8 @@
image = pywikibot.FilePage(image.getRedirectTarget())
if not image.exists():
pywikibot.output(
- "{0} doesn't exist. I can't link to it"
- ''.format(image.title(as_link=True)))
+ "{} doesn't exist. I can't link to it"
+ .format(image.title(as_link=True)))
continue
claim.setTarget(image)
else:
diff --git a/scripts/redirect.py b/scripts/redirect.py
index acb4cc2..db3a69a 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -356,9 +356,9 @@
- datetime.timedelta(0, self.offset * 3600))
# self.offset hours ago
offset_time = start.strftime('%Y%m%d%H%M%S')
- pywikibot.output('Retrieving {0} moved pages...'
- ''.format(str(self.api_number)
- if self.api_number is not None else 'all'))
+ pywikibot.output('Retrieving {} moved pages...'
+ .format(self.api_number
+ if self.api_number is not None else 'all'))
move_gen = self.site.logevents(logtype='move', start=offset_time)
if self.api_number:
move_gen.set_maximum_items(self.api_number)
@@ -415,8 +415,8 @@
elif action == 'both':
self.treat_page = self.fix_double_or_delete_broken_redirect
else:
- raise NotImplementedError('No valid action "{0}" found.'
- ''.format(action))
+ raise NotImplementedError('No valid action "{}" found.'
+ .format(action))

def get_sd_template(self):
"""Look for speedy deletion template and return it.
@@ -442,8 +442,8 @@
if page.exists():
return sd
pywikibot.warning(
- 'No speedy deletion template {0}available.'
- ''.format('"{0}" '.format(title) if title else ''))
+ 'No speedy deletion template {}available.'
+ .format('"{}" '.format(title) if title else ''))
return None

def init_page(self, item):
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 5829e94..b7c721d 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -460,8 +460,8 @@

def httpError(self, err_num, link, pagetitleaslink):
"""Log HTTP Error."""
- pywikibot.stdout('HTTP error ({0}) for {1} on {2}'
- ''.format(err_num, link, pagetitleaslink))
+ pywikibot.stdout('HTTP error ({}) for {} on {}'
+ .format(err_num, link, pagetitleaslink))

def getPDFTitle(self, ref, f):
"""Use pdfinfo to retrieve title from a PDF.
diff --git a/scripts/templatecount.py b/scripts/templatecount.py
index 1ba1341..8bb513c 100755
--- a/scripts/templatecount.py
+++ b/scripts/templatecount.py
@@ -34,7 +34,7 @@

"""
#
-# (C) Pywikibot team, 2006-2018
+# (C) Pywikibot team, 2006-2020
#
# Distributed under the terms of the MIT license.
#
@@ -74,8 +74,8 @@
pywikibot.stdout(format.format(key, count))
total += count
pywikibot.stdout(format.format('TOTAL', total))
- pywikibot.stdout('Report generated on {0}'
- ''.format(datetime.datetime.utcnow().isoformat()))
+ pywikibot.stdout('Report generated on {}'
+ .format(datetime.datetime.utcnow().isoformat()))

@classmethod
def listTemplates(cls, templates, namespaces):
@@ -100,9 +100,9 @@
for page in template_dict[key]:
pywikibot.stdout(page.title())
total += 1
- pywikibot.output('Total page count: {0}'.format(total))
- pywikibot.stdout('Report generated on {0}'
- ''.format(datetime.datetime.utcnow().isoformat()))
+ pywikibot.output('Total page count: {}'.format(total))
+ pywikibot.stdout('Report generated on {}'
+ .format(datetime.datetime.utcnow().isoformat()))

@classmethod
def template_dict(cls, templates, namespaces):
diff --git a/tests/wikistats_tests.py b/tests/wikistats_tests.py
index 241e81d..4bfa370 100644
--- a/tests/wikistats_tests.py
+++ b/tests/wikistats_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Test cases for the WikiStats dataset."""
#
-# (C) Pywikibot team, 2014-2019
+# (C) Pywikibot team, 2014-2020
#
# Distributed under the terms of the MIT license.
#
@@ -55,8 +55,8 @@
curr = int(data[code]['good'])
self.assertGreaterEqual(
last, curr,
- '{0} ({1}) is greater than {2} ({3}).'
- ''.format(code, curr, last_code, last))
+ '{} ({}) is greater than {} ({}).'
+ .format(code, curr, last_code, last))
last = curr
last_code = code


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9d06e06a92cc1ae3a2232066205f054ddc859c3d
Gerrit-Change-Number: 597238
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)