John Vandenberg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/181881
Change subject: Allow cacheSources to fail loading JSON data
......................................................................
Allow cacheSources to fail loading JSON data
WikidataBot.getSource already does not return a value if
the site is not in the JSON data.
Change-Id: I3198f1bbddbc532faa626281823bb0e156a1fd3a
---
M pywikibot/bot.py
1 file changed, 8 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/81/181881/1
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 21eb4a4..7016ab0 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1148,7 +1148,14 @@
It is stored internally and reused by getSource()
"""
page = pywikibot.Page(self.repo, u'List of wikis/python', ns=4)
- self.source_values = json.loads(page.get())
+ try:
+ data = page.get()
+ except pywikibot.NoPage as e:
+ pywikibot.warning(u'cacheSources: Could not load sources: %s' % e)
+ self.source_values = {}
+ return
+
+ self.source_values = json.loads(data)
for family_code, family in self.source_values.items():
for source_lang in family:
self.source_values[family_code][source_lang] =
pywikibot.ItemPage(self.repo,
--
To view, visit https://gerrit.wikimedia.org/r/181881
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3198f1bbddbc532faa626281823bb0e156a1fd3a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits