aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-09-20 16:53:39 +0300
committerBonfaceKilz2024-09-23 12:32:51 +0300
commitf55e7ec4cb7cffbe62a7a81612884e590a82dfa6 (patch)
tree357771ca2e8ffb4a9b17e779f5987ba6451b0852
parente4634e8cdc1ffdc518993d2aa8534690957ab565 (diff)
downloadgenenetwork3-f55e7ec4cb7cffbe62a7a81612884e590a82dfa6.tar.gz
Remove one-line if/else statement.
* gn3/db/rdf/wiki.py (__sanitize_result): When fetching pubmed_ids and categories, default to [] if the key misses, and remove the subsequent one-line if/else statement. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rw-r--r--gn3/db/rdf/wiki.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py
index 4464eed..6624886 100644
--- a/gn3/db/rdf/wiki.py
+++ b/gn3/db/rdf/wiki.py
@@ -40,13 +40,13 @@ def __sanitize_result(result: dict) -> dict:
"""Make sure `categories` and `pubmed_ids` are always arrays"""
if not result:
return {}
- categories = result.get("categories")
+ categories = result.get("categories", [])
if isinstance(categories, str):
- result["categories"] = [categories] if categories else []
+ result["categories"] = [categories]
result["categories"] = sorted(result["categories"])
- pmids = result.get("pubmed_ids")
+ pmids = result.get("pubmed_ids", [])
if isinstance(pmids, str):
- result["pubmed_ids"] = [pmids] if pmids else []
+ result["pubmed_ids"] = [pmids]
if isinstance(pmids, int):
result["pubmed_ids"] = [pmids]
result["pubmed_ids"] = [