[Python-modules-commits] [python-pyld] 167/276: Do not output relative IRIs in RDF datasets.
Wolfgang Borgert
debacle at moszumanska.debian.org
Wed Oct 8 23:48:07 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 f60d060c6dde2b9887d45630d2cd39331f22e9e7
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Mon Sep 9 20:42:58 2013 -0400
Do not output relative IRIs in RDF datasets.
---
lib/pyld/jsonld.py | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 2a10f39..c5a7079 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -860,7 +860,9 @@ class JsonLdProcessor:
# output RDF dataset
dataset = {}
for graph_name, graph in sorted(node_map.items()):
- dataset[graph_name] = self._graph_to_rdf(graph, namer, options)
+ # skip relative IRIs
+ if graph_name == '@default' or _is_absolute_iri(graph_name):
+ dataset[graph_name] = self._graph_to_rdf(graph, namer, options)
# convert to output format
if 'format' in options:
@@ -2415,6 +2417,11 @@ class JsonLdProcessor:
continue
for item in items:
+ # skip relative IRI subjects and predicates
+ if not (_is_absolute_iri(id_) and
+ _is_absolute_iri(property)):
+ continue
+
# RDF subject
subject = {}
if id_.startswith('_:'):
@@ -2441,11 +2448,13 @@ class JsonLdProcessor:
# convert value or node object to triple
else:
object = self._object_to_rdf(item)
- rval.append({
- 'subject': subject,
- 'predicate': predicate,
- 'object': object
- })
+ # skip None objects (they are relative IRIs)
+ if object is not None:
+ rval.append({
+ 'subject': subject,
+ 'predicate': predicate,
+ 'object': object
+ })
return rval
def _list_to_rdf(self, list, namer, subject, predicate, triples):
@@ -2474,11 +2483,13 @@ class JsonLdProcessor:
subject = blank_node
predicate = first
object = self._object_to_rdf(item)
- triples.append({
- 'subject': subject,
- 'predicate': predicate,
- 'object': object
- })
+ # skip None objects (they are relative IRIs)
+ if object is not None:
+ triples.append({
+ 'subject': subject,
+ 'predicate': predicate,
+ 'object': object
+ })
predicate = rest
@@ -2532,6 +2543,10 @@ class JsonLdProcessor:
object['type'] = 'IRI'
object['value'] = id_
+ # skip relative IRIs
+ if object['type'] == 'IRI' and not _is_absolute_iri(object['value']):
+ return None
+
return object
def _rdf_to_object(self, o, use_native_types):
--
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