[Python-modules-commits] [python-pyld] 172/276: Ensure remote doc is parsed; paren fix.
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 ed00b59ab639d882e385c151c3782bb25dd6d8c1
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Mon Sep 9 23:11:49 2013 -0400
Ensure remote doc is parsed; paren fix.
---
lib/pyld/jsonld.py | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index a41506e..5687226 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -573,9 +573,23 @@ class JsonLdProcessor:
'document': input_
}
+ try:
+ if not remote_doc['document']:
+ raise JsonLdError(
+ 'No remote document found at the given URL.',
+ 'jsonld.NullRemoteDocument')
+ if _is_string(remote_doc['document']):
+ remote_doc['document'] = json.loads(remote_doc['document'])
+ except Exception as cause:
+ raise JsonLdError(
+ 'Could not retrieve a JSON-LD document from the URL. URL '
+ 'derefencing not implemented.', 'jsonld.LoadDocumentError',
+ {'remoteDoc': remote_doc}, code='loading document failed',
+ cause=cause)
+
# build meta-object and retrieve all @context urls
input_ = {
- 'document': copy.deepcopy(input_),
+ 'document': copy.deepcopy(remote_doc['document']),
'remoteContext': {'@context': remote_doc['contextUrl']}
}
if 'expandContext' in options:
@@ -1898,8 +1912,8 @@ class JsonLdProcessor:
'Invalid JSON-LD syntax; only strings may be '
'language-tagged.', 'jsonld.SyntaxError',
{'element': rval}, code='invalid language-tagged value')
- elif ('@type' in rval and not _is_absolute_iri(rval['@type']) or
- rval['@type'].startswith('_:')):
+ elif ('@type' in rval and (not _is_absolute_iri(rval['@type']) or
+ rval['@type'].startswith('_:'))):
raise JsonLdError(
'Invalid JSON-LD syntax; an element containing "@value" '
'and "@type" must have an absolute IRI for the 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