[Python-modules-commits] [python-pyld] 72/276: Use %1.15e for double strings, fix base IRI handling.
Wolfgang Borgert
debacle at moszumanska.debian.org
Wed Oct 8 23:47:55 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 b0d6eb0dac298ef20be1e4f481282b5c0907840c
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Mon Apr 30 15:14:13 2012 -0400
Use %1.15e for double strings, fix base IRI handling.
---
lib/pyld/jsonld.py | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 12844e6..948c0ff 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -1234,8 +1234,8 @@ class JsonLdProcessor:
# convert double to @value
elif _is_double(o):
# do special JSON-LD double format,
- # printf(' % 1.16e') equivalent
- o = {'@value': ('%1.16e' % o), '@type': XSD_DOUBLE}
+ # printf(' % 1.15e') equivalent
+ o = {'@value': ('%1.15e' % o), '@type': XSD_DOUBLE}
# convert integer to @value
elif _is_integer(o):
o = {'@value': str(o), '@type': XSD_INTEGER}
@@ -2286,7 +2286,7 @@ class JsonLdProcessor:
return value
# prepend base
- value = "basevalue"
+ value = self._prependBase(base, value)
# value must now be an absolute IRI
if not _is_absolute_iri(value):
@@ -2338,9 +2338,24 @@ class JsonLdProcessor:
return term
# prepend base to term
- return base + term
+ return self._prependBase(base, term)
- def _getInitialContext(self,):
+ def _prependBase(self, base, iri):
+ """
+ Prepends a base IRI to the given relative IRI.
+
+ :param base: the base IRI.
+ :param iri: the relative IRI.
+
+ :return: the absolute IRI.
+ """
+ if iri == '' or iri.startswith('#'):
+ return base + iri
+ else:
+ # prepend last directory for base
+ return base[:base.rfind('/') + 1] + iri;
+
+ def _getInitialContext(self):
"""
Gets the initial context.
--
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