jenkins-bot merged this change.

View Change

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

- use str.format(...) instead of modulo for type specifier
arguments.
- use single quotes for string literals
- remove preleading "u" fron strings

Change-Id: Icef015b13646c2d763002f4f01b64df1c62af27c
---
M scripts/commons_link.py
1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/scripts/commons_link.py b/scripts/commons_link.py
index e07e058..f23c778 100755
--- a/scripts/commons_link.py
+++ b/scripts/commons_link.py
@@ -81,39 +81,40 @@

# for Commons/Commonscat template
s = self.findTemplate.search(text)
- s2 = getattr(self, 'findTemplate%d'
- % (2, 3)[catmode]).search(text)
+ s2 = getattr(self, 'findTemplate{}'.format(
+ (2, 3)[catmode]).search(text))
if s or s2:
- pywikibot.output(u'** Already done.')
+ pywikibot.output('** Already done.')
else:
cats = textlib.getCategoryLinks(text,
site=page.site)
text = textlib.replaceCategoryLinks(
- u'%s{{commons%s|%s}}'
+ '%s{{commons%s|%s}}'
% (text, ('', 'cat')[catmode], pagetitle),
cats, site=page.site)
comment = i18n.twtranslate(
- page.site, 'commons_link%s-template-added'
- % ('', '-cat')[catmode])
+ page.site, 'commons_link{}-template-added'
+ .format(('', '-cat')[catmode]))
try:
self.userPut(page, old_text, text,
summary=comment)
except pywikibot.EditConflict:
pywikibot.output(
- u'Skipping %s because of edit conflict'
- % page.title())
+ 'Skipping {} because of edit conflict'
+ .format(page.title()))

except pywikibot.NoPage:
- pywikibot.output(u'%s does not exist in Commons'
- % page.__class__.__name__)
+ pywikibot.output('{} does not exist in Commons'
+ .format(page.__class__.__name__))

except pywikibot.NoPage:
- pywikibot.output(u'Page %s does not exist' % page.title())
+ pywikibot.output('Page {} does not exist'
+ .format(page.title()))
except pywikibot.IsRedirectPage:
- pywikibot.output(u'Page %s is a redirect; skipping.'
- % page.title())
+ pywikibot.output('Page {} is a redirect; skipping.'
+ .format(page.title()))
except pywikibot.LockedPage:
- pywikibot.output(u'Page %s is locked' % page.title())
+ pywikibot.output('Page {} is locked'.format(page.title()))


def main(*args):
@@ -149,5 +150,5 @@
return False


-if __name__ == "__main__":
+if __name__ == '__main__':
main()

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Icef015b13646c2d763002f4f01b64df1c62af27c
Gerrit-Change-Number: 462767
Gerrit-PatchSet: 2
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)