script: work around a KeyError exception in Python Wikipedia lib.

Even the test `if hasattr(page, 'links')` would trigger this exception.
So I try the approach "Easier to Ask Forgiveness than Permission".
Weird stuff but well…
Note: I had this exception when running it on the Maltese data.
This commit is contained in:
Jehan 2016-09-21 02:13:50 +02:00
parent 2700cf3a83
commit 26024e5c82

View File

@ -257,7 +257,10 @@ def visit_pages(titles, depth, lang, logfd):
logfd.write("\n{} (revision {})".format(title, page.revision_id))
process_text(page.content, lang)
next_titles += page.links
try:
next_titles += page.links
except KeyError:
pass
if depth >= options.max_depth:
return