[Python-modules-commits] [python-pyld] 17/276: Updated to pass tests.
Wolfgang Borgert
debacle at moszumanska.debian.org
Wed Oct 8 23:47:49 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 982ab36a661cde9e6ab75ee7b43dec6661ad1c58
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Sat Aug 6 23:24:27 2011 -0400
Updated to pass tests.
---
lib/pyld/jsonld.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 5d2c038..df305ff 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -640,14 +640,16 @@ def _flatten(parent, parentProperty, value, subjects):
for key, v in value.items():
# drop null values
if v is not None:
- if isinstance(v, list):
- subject[key] = []
- _flatten(subject[key], None, v, subjects)
- if len(subject[key]) == 1:
- # convert subject[key] to object if it has only 1
- subject[key] = subject[key][0]
+ if key in subject:
+ if not isinstance(subject[key], list):
+ subject[key] = [subject[key]]
else:
- _flatten(subject, key, v, subjects)
+ subject[key] = []
+
+ _flatten(subject[key], None, v, subjects)
+ if len(subject[key]) == 1:
+ # convert subject[key] to object if it has only 1
+ subject[key] = subject[key][0]
# string value
else:
flattened = value
--
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