[Python-modules-commits] [python-pyld] 110/276: Always use @graph when context output is an array.

Wolfgang Borgert debacle at moszumanska.debian.org
Wed Oct 8 23:47:59 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-pyld.

commit 1d88082b1a19f0c5f83eba98a46921d0a1f1ce14
Author: Dave Longley <dlongley at digitalbazaar.com>
Date:   Tue Apr 9 11:31:29 2013 -0400

    Always use @graph when context output is an array.
---
 lib/pyld/jsonld.py | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index dfc9d1a..f8d247b 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -455,23 +455,22 @@ class JsonLdProcessor:
         if ctx_length == 1:
             ctx = ctx[0]
 
-        # add context
-        if has_context or options['graph']:
-            if _is_array(compacted):
-                # use '@graph' keyword
-                kwgraph = self._compact_iri(active_ctx, '@graph')
-                graph = compacted
-                compacted = {}
-                if has_context:
-                    compacted['@context'] = ctx
-                compacted[kwgraph] = graph
-            elif _is_object(compacted):
-                # reorder keys so @context is first
-                graph = compacted
-                compacted = {}
+        # add context and/or @graph
+        if _is_array(compacted):
+            # use '@graph' keyword
+            kwgraph = self._compact_iri(active_ctx, '@graph')
+            graph = compacted
+            compacted = {}
+            if has_context:
                 compacted['@context'] = ctx
-                for k, v in graph.items():
-                    compacted[k] = v
+            compacted[kwgraph] = graph
+        elif _is_object(compacted) and has_context:
+            # reorder keys so @context is first
+            graph = compacted
+            compacted = {}
+            compacted['@context'] = ctx
+            for k, v in graph.items():
+                compacted[k] = v
 
         if options['activeCtx']:
             return {'compacted': compacted, 'activeCtx': active_ctx}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pyld.git



More information about the Python-modules-commits mailing list