Handle revisions without text
This commit is contained in:
parent
1db581725b
commit
7cf5b013da
1 changed files with 3 additions and 6 deletions
|
|
@ -20,17 +20,14 @@ def process_page(page):
|
||||||
info["redirect"] = page.redirect
|
info["redirect"] = page.redirect
|
||||||
else:
|
else:
|
||||||
[revision] = list(page) # Every page has exactly one revision
|
[revision] = list(page) # Every page has exactly one revision
|
||||||
|
if revision.text is not None:
|
||||||
|
info["length"] = len(revision.text)
|
||||||
|
|
||||||
length = len(revision.text)
|
|
||||||
info["length"] = length
|
|
||||||
|
|
||||||
# Parsing may fail for articles with length 0
|
|
||||||
if length > 0:
|
|
||||||
links = []
|
links = []
|
||||||
for link in wtp.parse(revision.text).wikilinks:
|
for link in wtp.parse(revision.text).wikilinks:
|
||||||
start, end = link.span
|
start, end = link.span
|
||||||
links.append((link.title, start, end))
|
links.append((link.title, start, end))
|
||||||
info["links"] = links
|
info["links"] = links
|
||||||
|
|
||||||
print(json.dumps(info, check_circular=False, separators=(",", ":")))
|
print(json.dumps(info, check_circular=False, separators=(",", ":")))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue