aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-09-10 10:49:50 +0300
committerBonfaceKilz2024-09-11 10:30:57 +0300
commita7d9165a7ca1e6b9e7fdeb6fba61ebf335c6a0d3 (patch)
treed5832c702c41244e7de94e78b5dfcda256c0447f
parent0b07792d38e83ee36a942b80fefb7de81778aa9f (diff)
downloadgenenetwork3-a7d9165a7ca1e6b9e7fdeb6fba61ebf335c6a0d3.tar.gz
Handle case when result is empty when sanitizing json-ld result.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rw-r--r--gn3/db/rdf/wiki.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py
index 03945ec..7d0b3f3 100644
--- a/gn3/db/rdf/wiki.py
+++ b/gn3/db/rdf/wiki.py
@@ -31,8 +31,10 @@ WIKI_CONTEXT = BASE_CONTEXT | {
}
-def __sanitize_result(result: dict):
+def __sanitize_result(result: dict) -> dict:
"""Make sure `categories` and `pubmed_ids` are always arrays"""
+ if not result:
+ return {}
categories = result.get("categories")
if isinstance(categories, str):
result["categories"] = [categories] if categories else []