[Python-modules-commits] [python-pyld] 15/276: Removed JSON output from relation serializations.
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 4bdcbea1507bf02f2d1fabac7c660844d42b81ba
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Tue Aug 2 23:54:25 2011 -0400
Removed JSON output from relation serializations.
---
lib/pyld/jsonld.py | 44 +++++++++++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 13 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 3728ff1..693a302 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -1028,10 +1028,10 @@ class Processor:
b = self.subjects[iri]
# serialize properties
- s += '<' + _serializeProperties(b) + '>'
+ s += '[' + _serializeProperties(b) + ']'
# serialize references
- s += '<'
+ s += '['
first = True
refs = self.edges['refs'][iri]['all']
for r in refs:
@@ -1039,8 +1039,10 @@ class Processor:
first = False
else:
s += '|'
- s += '_:' if _isBlankNodeIri(r['s']) else r['s']
- s += '>'
+ s += '<' + r['p'] + '>'
+ s += ('_:' if _isBlankNodeIri(r['s']) else
+ ('<' + r['s'] + '>'))
+ s += ']'
# serialize adjacent node keys
s += ''.join(adj['k'])
@@ -1602,20 +1604,36 @@ def _rotate(a):
# @return the serialized properties.
def _serializeProperties(b):
rval = ''
+ first = True
for p in b.keys():
if p != '@subject':
- first = True
+ if first:
+ first = False
+ else:
+ rval += '|'
+ rval += '<' + p + '>'
objs = b[p] if isinstance(b[p], list) else [b[p]]
for o in objs:
- if first:
- first = False
- else:
- rval += '|'
- if (isinstance(o, dict) and '@iri' in o and
- _isBlankNodeIri(o['@iri'])):
- rval += '_:'
+ if isinstance(o, dict):
+ # iri
+ if '@iri' in o:
+ if _isBlankNodeIri(o['@iri']):
+ rval += '_:'
+ else:
+ rval += '<' + o['@iri'] + '>'
+ # literal
+ else:
+ rval += '"' + o['@literal'] + '"'
+
+ # datatype literal
+ if '@datatype' in o:
+ rval += '^^<' + o['@datatype'] + '>'
+ # language literal
+ elif '@language' in o:
+ rval += '@' + o['@language']
+ # plain literal
else:
- rval += json.dumps(o)
+ rval += '"' + o + '"'
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