aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-05-09 16:49:42 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-05-09 16:49:42 -0500
commita468db099c20fc666fafa4ce399fd04e7e6f2cbe (patch)
treeae03984ec55a26c23a7ba2872c72f3148dcdc664
parent3850b3fb56a2a5edc869af68ae40fc3f2873dc22 (diff)
downloadmediagoblin-a468db099c20fc666fafa4ce399fd04e7e6f2cbe.tar.lz
mediagoblin-a468db099c20fc666fafa4ce399fd04e7e6f2cbe.tar.xz
mediagoblin-a468db099c20fc666fafa4ce399fd04e7e6f2cbe.zip
expand_json utility... yet another convenience function :)
This commit sponsored by Benjamin Lebsanft. Thank you!
-rw-r--r--mediagoblin/tools/metadata.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/mediagoblin/tools/metadata.py b/mediagoblin/tools/metadata.py
index 37d04fa1..dde5753e 100644
--- a/mediagoblin/tools/metadata.py
+++ b/mediagoblin/tools/metadata.py
@@ -183,3 +183,18 @@ def compact_and_validate(metadata, context=DEFAULT_CONTEXT,
return compacted
+def expand_json(metadata, context=DEFAULT_CONTEXT):
+ """
+ Expand json, but be sure to use our documentLoader.
+
+ By default this expands with DEFAULT_CONTEXT, but if you do not need this,
+ you can safely set this to None.
+
+ # @@: Is the above a good idea? Maybe it should be set to None by
+ # default.
+ """
+ options = {
+ "documentLoader": load_context}
+ if context is not None:
+ options["expandContext"] = context
+ return jsonld.expand(metadata, options=options)