diff options
author | Andrew Godwin | 2022-11-16 06:53:39 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-16 13:53:40 -0700 |
commit | 495e955378d62dc439c4c210785e5d401bc77f64 (patch) | |
tree | 859813b06314f387470295e752d1f1b3828830a7 /core/ld.py | |
parent | 906ed2f27c9105dbd78f416930f1aa2b49497567 (diff) | |
download | takahe-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.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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) |