summaryrefslogtreecommitdiff
path: root/rdflib/term.py
diff options
context:
space:
mode:
authorGraham Higgins <gjh-github@bel-epa.com>2013-02-07 07:48:36 +0000
committerGraham Higgins <gjh-github@bel-epa.com>2013-02-07 07:48:36 +0000
commit28a04eb941bae97b21451673e14866d6f1210e0f (patch)
tree67323fe7ec44d15a0ee4ebb6a3bf422eb5e651f9 /rdflib/term.py
parent35c90e770113b6cf4c198d4a5b029b5cd439f519 (diff)
parent2e1d4c81c8f88c43bd481f8d4359954675d15b4f (diff)
downloadrdflib-28a04eb941bae97b21451673e14866d6f1210e0f.tar.gz
merge from master
Diffstat (limited to 'rdflib/term.py')
-rw-r--r--rdflib/term.py46
1 files changed, 15 insertions, 31 deletions
diff --git a/rdflib/term.py b/rdflib/term.py
index e8b0e25f..bd412017 100644
--- a/rdflib/term.py
+++ b/rdflib/term.py
@@ -50,6 +50,7 @@ from re import sub
try:
from hashlib import md5
+ assert md5
except ImportError:
from md5 import md5
@@ -95,7 +96,7 @@ class URIRef(Identifier):
if ends_in_hash:
if not value.endswith("#"):
value += "#"
- #if normalize and value and value != normalize("NFC", value):
+ # if normalize and value and value != normalize("NFC", value):
# raise Error("value must be in NFC normalized form.")
final_cls = RDFLibGenid if RDFLibGenid._is_rdflib_skolem(value) \
else (Genid if Genid._is_external_skolem(value) \
@@ -179,10 +180,6 @@ class URIRef(Identifier):
Supported for backwards compatibility; new code should
probably just use __hash__
"""
- warnings.warn(
- "method md5_term_hash is deprecated, and will be removed " +
- "in the future. If you use this please let rdflib-dev know!",
- category=DeprecationWarning, stacklevel=2)
d = md5(self.encode())
d.update(b("U"))
return d.hexdigest()
@@ -324,8 +321,8 @@ class BNode(Identifier):
# only store implementations should pass in a value
"""
if value is None:
- # so that BNode values do not collide with ones created with a
- # different instance of this module at some other time.
+ # so that BNode values do not collide with ones created with
+ # a different instance of this module at some other time.
node_id = _sn_gen()
value = "%s%s" % (_prefix, node_id)
else:
@@ -392,10 +389,6 @@ class BNode(Identifier):
Supported for backwards compatibility; new code should
probably just use __hash__
"""
- warnings.warn(
- "method md5_term_hash is deprecated, and will be removed " +
- "in the future. If you use this please let rdflib-dev know!",
- category=DeprecationWarning, stacklevel=2)
d = md5(self.encode())
d.update(b("B"))
return d.hexdigest()
@@ -743,12 +736,12 @@ class Literal(Identifier):
"Two literals are equal if and only if all of the following hold:
* The strings of the two lexical forms compare equal, character by
- character.
+ character.
* Either both or neither have language tags.
* The language tags, if any, compare equal.
* Either both or neither have datatype URIs.
* The two datatype URIs, if any, compare equal, character by
- character."
+ character."
-- 6.5.1 Literal Equality (RDF: Concepts and Abstract Syntax)
"""
@@ -939,9 +932,9 @@ class Literal(Identifier):
def _quote_encode(self):
# This simpler encoding doesn't work; a newline gets encoded as "\\n",
# which is ok in sourcecode, but we want "\n".
- #encoded = self.encode('unicode-escape').replace(
+ # encoded = self.encode('unicode-escape').replace(
# '\\', '\\\\').replace('"','\\"')
- #encoded = self.replace.replace('\\', '\\\\').replace('"','\\"')
+ # encoded = self.replace.replace('\\', '\\\\').replace('"','\\"')
# NOTE: Could in theory chose quotes based on quotes appearing in the
# string, i.e. '"' and "'", but N3/turtle doesn't allow "'"(?).
@@ -957,12 +950,11 @@ class Literal(Identifier):
return '"""%s"""' % encoded.replace('\r', '\\r')
else:
- return '"%s"' % \
- self.replace(
- '\n', '\\n').replace(
- '\\', '\\\\').replace(
- '"', '\\"').replace(
- '\r', '\\r')
+ return '"%s"' % self.replace(
+ '\n', '\\n').replace(
+ '\\', '\\\\').replace(
+ '"', '\\"').replace(
+ '\r', '\\r')
if not py3compat.PY3:
def __str__(self):
@@ -996,8 +988,8 @@ class Literal(Identifier):
try:
rt = self.toPython()
except Exception:
- _LOGGER.warning("could not convert %s to a Python datatype" %
- repr(self))
+ _LOGGER.warning(
+ "could not convert %s to a Python datatype" % repr(self))
rt = self
if rt is self:
@@ -1014,10 +1006,6 @@ class Literal(Identifier):
Supported for backwards compatibility; new code should
probably just use __hash__
"""
- warnings.warn(
- "method md5_term_hash is deprecated, and will be removed " +
- "in the future. If you use this please let rdflib-dev know!",
- category=DeprecationWarning, stacklevel=2)
d = md5(self.encode())
d.update(b("L"))
return d.hexdigest()
@@ -1153,10 +1141,6 @@ class Variable(Identifier):
Supported for backwards compatibility; new code should
probably just use __hash__
"""
- warnings.warn(
- "method md5_term_hash is deprecated, and will be removed " +
- "in the future. If you use this please let rdflib-dev know!",
- category=DeprecationWarning, stacklevel=2)
d = md5(self.encode())
d.update(b("V"))
return d.hexdigest()