jenkins-bot merged this change.
[cleanup] cleanup scripts/illustrate_wikidata.py
- use single quotes for string literals
- use str.format(...) instead of modulo for type specifier
arguments
- remove preleading "u" from strings
- use "+" to concatenate strings in some cases
Change-Id: I0bffc9d7ef2061921bec86e789e545b3e114652e
---
M scripts/illustrate_wikidata.py
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/scripts/illustrate_wikidata.py b/scripts/illustrate_wikidata.py
index 7fc95a0..350ec36 100755
--- a/scripts/illustrate_wikidata.py
+++ b/scripts/illustrate_wikidata.py
@@ -48,12 +48,12 @@
claim = pywikibot.Claim(self.repo, self.wdproperty)
if claim.type != 'commonsMedia':
- raise ValueError(u'%s is of type %s, should be commonsMedia'
- % (self.wdproperty, claim.type))
+ raise ValueError('{} is of type {}, should be commonsMedia'
+ .format(self.wdproperty, claim.type))
def treat_page_and_item(self, page, item):
"""Treat a page / item."""
- pywikibot.output(u'Found %s' % item.title())
+ pywikibot.output('Found ' + item.title())
imagename = page.properties().get('page_image_free')
if not imagename:
@@ -61,12 +61,12 @@
claims = item.get().get('claims')
if self.wdproperty in claims:
- pywikibot.output('Item %s already contains image (%s)'
- % (item.title(), self.wdproperty))
+ pywikibot.output('Item {} already contains image ({})'
+ .format(item.title(), self.wdproperty))
return
newclaim = pywikibot.Claim(self.repo, self.wdproperty)
- commonssite = pywikibot.Site("commons", "commons")
+ commonssite = pywikibot.Site('commons', 'commons')
imagelink = pywikibot.Link(imagename, source=commonssite,
default_namespace=6)
image = pywikibot.FilePage(imagelink)
@@ -74,8 +74,8 @@
image = pywikibot.FilePage(image.getRedirectTarget())
if not image.exists():
- pywikibot.output("%s doesn't exist so I can't link to it"
- % image.title(as_link=True))
+ pywikibot.output("{} doesn't exist so I can't link to it"
+ .format(image.title(as_link=True)))
return
newclaim.setTarget(image)
@@ -96,13 +96,13 @@
local_args = pywikibot.handle_args(args)
generator_factory = pagegenerators.GeneratorFactory()
- wdproperty = u'P18'
+ wdproperty = 'P18'
for arg in local_args:
if arg.startswith('-property'):
if len(arg) == 9:
wdproperty = pywikibot.input(
- u'Please enter the property you want to add:')
+ 'Please enter the property you want to add:')
else:
wdproperty = arg[10:]
else:
@@ -118,5 +118,5 @@
return True
-if __name__ == "__main__":
+if __name__ == '__main__':
main()
To view, visit change 462565. To unsubscribe, or for help writing mail filters, visit settings.