[Python-modules-commits] [python-pyld] 42/276: Fixed replacement embed bugs.
Wolfgang Borgert
debacle at moszumanska.debian.org
Wed Oct 8 23:47:51 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 8487d5bd80ba9ba13c91eda3a2cf8d4fc3e6ed33
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Wed Nov 23 19:20:40 2011 -0500
Fixed replacement embed bugs.
---
lib/pyld/jsonld.py | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index f181ba9..c263c47 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -1575,7 +1575,15 @@ def _subframe(
embeds[iri] = embed
# replace the existing embed with a reference
elif embed['parent'] is not None:
- embed['parent'][embed['key']] = value['@subject']
+ objs = embed['parent'][embed['key']]
+ if isinstance(objs, list):
+ for i in range(0, len(objs)):
+ if (isinstance(objs[i], dict) and '@subject' in objs[i] and
+ objs[i]['@subject']['@iri'] == iri):
+ objs[i] = value['@subject'];
+ break
+ else:
+ embed['parent'][embed['key']] = value['@subject']
# update embed entry
embed['autoembed'] = autoembed
@@ -1720,7 +1728,13 @@ def _frame(
if rval is None:
rval = value
else:
- rval.append(value)
+ # determine if value is a reference
+ isRef = (value is not None and isinstance(value, dict) and
+ '@iri' in value and value['@iri'] in embeds)
+
+ # push any value that isn't a parentless reference
+ if not (parent is None and isRef):
+ rval.append(value)
return rval
--
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