summaryrefslogtreecommitdiffstats
path: root/core/ld.py
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-16 06:53:39 -0700
committerAndrew Godwin2022-11-16 13:53:40 -0700
commit495e955378d62dc439c4c210785e5d401bc77f64 (patch)
tree859813b06314f387470295e752d1f1b3828830a7 /core/ld.py
parent906ed2f27c9105dbd78f416930f1aa2b49497567 (diff)
downloadtakahe-495e955378d62dc439c4c210785e5d401bc77f64.tar.gz
takahe-495e955378d62dc439c4c210785e5d401bc77f64.tar.bz2
takahe-495e955378d62dc439c4c210785e5d401bc77f64.zip
Tag and visibility handling
Diffstat (limited to 'core/ld.py')
-rw-r--r--core/ld.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/ld.py b/core/ld.py
index 346708c..6692dab 100644
--- a/core/ld.py
+++ b/core/ld.py
@@ -414,6 +414,18 @@ def canonicalise(json_data: Dict, include_security: bool = False) -> Dict:
return jsonld.compact(jsonld.expand(json_data), context)
+def get_list(container, key) -> List:
+ """
+ Given a JSON-LD value (that can be either a list, or a dict if it's just
+ one item), always returns a list"""
+ if key not in container:
+ return []
+ value = container[key]
+ if not isinstance(value, list):
+ return [value]
+ return value
+
+
def format_ld_date(value: datetime.datetime) -> str:
return value.strftime(DATETIME_FORMAT)