jenkins-bot has submitted this change and it was merged.
Change subject: Safer use of mementos returned data structure
......................................................................
Safer use of mementos returned data structure
Bug: T112250
Change-Id: Ia36e0e88142c59a7f625b90c1be0b8f5a3c26614
---
M scripts/weblinkchecker.py
1 file changed, 13 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 64a01a3..a918601 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -178,7 +178,19 @@
mc.timegate_uri = timegate_uri
memento_info = mc.get_memento_info(url, when)
- return
memento_info.get('mementos').get('closest').get('uri')[0]
+ mementos = memento_info.get('mementos')
+ if not mementos:
+ raise Exception(
+ 'mementos not found for {0} via {1}'.format(url, timegate_uri))
+ if 'closest' not in mementos:
+ raise Exception(
+ 'closest memento not found for {0} via {1}'.format(
+ url, timegate_uri))
+ if 'uri' not in mementos['closest']:
+ raise Exception(
+ 'closest memento uri not found for {0} via {1}'.format(
+ url, timegate_uri))
+ return mementos['closest']['uri'][0]
def get_archive_url(url):
--
To view, visit
https://gerrit.wikimedia.org/r/238999
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia36e0e88142c59a7f625b90c1be0b8f5a3c26614
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>