jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/361458 )
Change subject: [IMPR] Create items with interwiki using interwikidata.py ......................................................................
[IMPR] Create items with interwiki using interwikidata.py
If no foreign page had item, the script reported a conflict. Now a new item is created with the page's interwiki.
I also removed InvalidTitle exception from the try statement since it's already handled in textlib.getLanguageLinks.
Bug: T168575 Change-Id: Ic708890337ab8523f4fb2326771ce37b32fcc20c --- M scripts/interwikidata.py 1 file changed, 12 insertions(+), 6 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py index e2fea57..9d46edf 100644 --- a/scripts/interwikidata.py +++ b/scripts/interwikidata.py @@ -111,7 +111,14 @@ 'value': self.current_page.title()} } } - summary = (u'Bot: New item with sitelink from %s' + for site, page in self.iwlangs.values(): + if not page.exists(): + continue + dbname = site.dbName() + 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(asLink=True, insite=self.repo))
item = pywikibot.ItemPage(self.repo) @@ -155,11 +162,10 @@ warning('Interwiki %s does not exist, skipping...' % iw_page.title(asLink=True)) continue - except pywikibot.InvalidTitle: - warning('Invalid title %s, skipping...' % - iw_page.title(asLink=True)) - continue - if len(wd_data) != 1: + if not wd_data: + # will create a new item with interwiki + return None + if len(wd_data) > 1: warning('Interwiki conflict in %s, skipping...' % self.current_page.title(asLink=True)) return False
pywikibot-commits@lists.wikimedia.org