jenkins-bot merged this change.
[cleanup] cleanup scripts/interwikidata.py
- use "+" for string concatenation in some cases
- use str.format(...) instead of modulo for type specifier
arguments
Change-Id: I53c1a204dda6c7796aaa4365439b5290f417e890
---
M scripts/interwikidata.py
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py
index e9e3958..9944230 100644
--- a/scripts/interwikidata.py
+++ b/scripts/interwikidata.py
@@ -121,8 +121,8 @@
title = page.title()
data['sitelinks'][dbname] = {'site': dbname, 'title': title}
data['labels'][site.lang] = {'language': site.lang, 'value': title}
- summary = ('Bot: New item with sitelink(s) from %s'
- % self.current_page.title(as_link=True, insite=self.repo))
+ summary = ('Bot: New item with sitelink(s) from '
+ + self.current_page.title(as_link=True, insite=self.repo))
item = pywikibot.ItemPage(self.repo)
item.editEntity(data, new='item', summary=summary)
@@ -147,8 +147,8 @@
dbnames = [iw_site.dbName() for iw_site in self.iwlangs]
if set(dbnames) - set(self.current_item.sitelinks.keys()):
if not self.handle_complicated():
- warning('Interwiki conflict in %s, skipping...' %
- self.current_page.title(as_link=True))
+ warning('Interwiki conflict in {}, skipping...'
+ .format(self.current_page.title(as_link=True)))
return False
output('Cleaning up the page')
new_text = pywikibot.textlib.removeLanguageLinks(
@@ -160,14 +160,14 @@
wd_data = set()
for iw_page in self.iwlangs.values():
if not iw_page.exists():
- warning('Interwiki %s does not exist, skipping...' %
- iw_page.title(as_link=True))
+ warning('Interwiki {} does not exist, skipping...'
+ .format(iw_page.title(as_link=True)))
continue
try:
wd_data.add(pywikibot.ItemPage.fromPage(iw_page))
except pywikibot.NoPage:
- output('Interwiki %s does not have an item' %
- iw_page.title(as_link=True))
+ output('Interwiki {} does not have an item'
+ .format(iw_page.title(as_link=True)))
return wd_data
def try_to_add(self):
@@ -177,16 +177,16 @@
# will create a new item with interwiki
return None
if len(wd_data) > 1:
- warning('Interwiki conflict in %s, skipping...' %
- self.current_page.title(as_link=True))
+ warning('Interwiki conflict in {}, skipping...'
+ .format(self.current_page.title(as_link=True)))
return False
item = list(wd_data).pop()
if self.current_page.site.dbName() in item.sitelinks:
- warning('Interwiki conflict in %s, skipping...' %
- item.title(as_link=True))
+ warning('Interwiki conflict in {}, skipping...'
+ .format(item.title(as_link=True)))
return False
- output('Adding link to %s' % item.title())
- item.setSitelink(self.current_page, summary='Added %s' % (
+ output('Adding link to ' + item.title())
+ item.setSitelink(self.current_page, summary='Added ' + (
self.current_page.title(as_link=True, insite=item.site)))
return item
@@ -197,8 +197,8 @@
# todo: add links to item
return None
if len(wd_data) > 1:
- warning('Interwiki conflict in %s, skipping...' %
- self.current_page.title(as_link=True))
+ warning('Interwiki conflict in {}, skipping...'
+ .format(self.current_page.title(as_link=True)))
return False
target_item = list(wd_data).pop()
try:
To view, visit change 462516. To unsubscribe, or for help writing mail filters, visit settings.