summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@surroundaustralia.com>2020-08-27 15:02:16 +1000
committerGitHub <noreply@github.com>2020-08-27 15:02:16 +1000
commit892715868336407eae7e8a43895ad73d5fea7289 (patch)
treec02e84efc580e25d26077dd6f6e3842594c43dfb
parent579998625b45dbe220b2a3b930abcaf5415234ad (diff)
parentdca850e9f649689b73c685148f7f01d7448bf4d8 (diff)
downloadrdflib-892715868336407eae7e8a43895ad73d5fea7289.tar.gz
Merge pull request #1149 from ashleysommer/t0b3_github
Remove all remnants of Python2 compatibility
-rw-r--r--docs/conf.py6
-rw-r--r--examples/film.py8
-rw-r--r--examples/graph_digest_benchmark.py1
-rw-r--r--rdflib/collection.py4
-rw-r--r--rdflib/compare.py2
-rw-r--r--rdflib/compat.py5
-rw-r--r--rdflib/events.py4
-rw-r--r--rdflib/extras/describer.py4
-rw-r--r--rdflib/extras/external_graph_libs.py4
-rw-r--r--rdflib/extras/infixowl.py36
-rw-r--r--rdflib/graph.py8
-rw-r--r--rdflib/namespace.py8
-rw-r--r--rdflib/parser.py1
-rw-r--r--rdflib/paths.py2
-rw-r--r--rdflib/plugin.py3
-rwxr-xr-xrdflib/plugins/parsers/notation3.py7
-rw-r--r--rdflib/plugins/parsers/nquads.py3
-rw-r--r--rdflib/plugins/parsers/ntriples.py4
-rw-r--r--rdflib/plugins/parsers/rdfxml.py10
-rw-r--r--rdflib/plugins/parsers/trig.py2
-rw-r--r--rdflib/plugins/parsers/trix.py6
-rw-r--r--rdflib/plugins/serializers/nquads.py4
-rw-r--r--rdflib/plugins/serializers/nt.py8
-rw-r--r--rdflib/plugins/serializers/rdfxml.py4
-rw-r--r--rdflib/plugins/serializers/trig.py2
-rw-r--r--rdflib/plugins/serializers/trix.py22
-rw-r--r--rdflib/plugins/serializers/turtle.py4
-rw-r--r--rdflib/plugins/serializers/xmlwriter.py4
-rw-r--r--rdflib/plugins/sparql/algebra.py1
-rw-r--r--rdflib/plugins/sparql/evaluate.py4
-rw-r--r--rdflib/plugins/sparql/operators.py2
-rw-r--r--rdflib/plugins/sparql/parser.py26
-rw-r--r--rdflib/plugins/sparql/results/xmlresults.py68
-rw-r--r--rdflib/plugins/sparql/sparql.py2
-rw-r--r--rdflib/plugins/stores/memory.py16
-rw-r--r--rdflib/plugins/stores/sleepycat.py4
-rw-r--r--rdflib/plugins/stores/sparqlstore.py30
-rw-r--r--rdflib/query.py4
-rw-r--r--rdflib/resource.py4
-rw-r--r--rdflib/store.py4
-rw-r--r--rdflib/term.py14
-rw-r--r--rdflib/tools/csv2rdf.py4
-rw-r--r--rdflib/tools/graphisomorphism.py2
-rw-r--r--rdflib/tools/rdf2dot.py32
-rw-r--r--rdflib/tools/rdfpipe.py2
-rw-r--r--rdflib/tools/rdfs2dot.py20
-rw-r--r--rdflib/util.py7
-rwxr-xr-xrun_tests.py2
-rw-r--r--test/manifest.py2
-rw-r--r--test/store_performance.py2
-rw-r--r--test/test_auditable.py1
-rw-r--r--test/test_canonicalization.py78
-rw-r--r--test/test_comparison.py4
-rw-r--r--test/test_conjunctive_graph.py4
-rw-r--r--test/test_dataset.py18
-rw-r--r--test/test_dawg.py1
-rw-r--r--test/test_diff.py4
-rw-r--r--test/test_graph.py14
-rw-r--r--test/test_graph_context.py20
-rw-r--r--test/test_hex_binary.py22
-rw-r--r--test/test_issue084.py20
-rw-r--r--test/test_issue190.py6
-rw-r--r--test/test_issue446.py2
-rw-r--r--test/test_issue604.py2
-rw-r--r--test/test_issue923.py2
-rw-r--r--test/test_literal.py4
-rw-r--r--test/test_n3.py4
-rw-r--r--test/test_nodepickler.py2
-rw-r--r--test/test_nquads.py6
-rw-r--r--test/test_nt_misc.py2
-rw-r--r--test/test_path_div_future.py1
-rw-r--r--test/test_preflabel.py14
-rw-r--r--test/test_prettyxml.py8
-rw-r--r--test/test_rdfxml.py18
-rw-r--r--test/test_slice.py14
-rw-r--r--test/test_sparqlupdatestore.py2
-rw-r--r--test/test_term.py2
-rw-r--r--test/test_trig.py16
-rw-r--r--test/test_turtle_serialize.py8
-rw-r--r--test/test_util.py10
-rw-r--r--test/test_wide_python.py12
-rw-r--r--test/testutils.py2
82 files changed, 331 insertions, 420 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 300cf0f1..b6f457f1 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -61,8 +61,8 @@ source_encoding = "utf-8"
master_doc = "index"
# General information about the project.
-project = u"rdflib"
-copyright = u"2009 - 2020, RDFLib Team"
+project = "rdflib"
+copyright = "2009 - 2020, RDFLib Team"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -211,7 +211,7 @@ htmlhelp_basename = "rdflibdoc"
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ("index", "rdflib.tex", u"rdflib Documentation", u"RDFLib Team", "manual"),
+ ("index", "rdflib.tex", "rdflib Documentation", "RDFLib Team", "manual"),
]
# The name of an image file (relative to this directory) to place at the top of
diff --git a/examples/film.py b/examples/film.py
index f25d696b..bf2d5e0b 100644
--- a/examples/film.py
+++ b/examples/film.py
@@ -42,7 +42,7 @@ storeuri = "file://" + storefn
title = "Movies viewed by %s"
r_who = re.compile(
- "^(.*?) <([a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+)>$"
+ r"^(.*?) <([a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+)>$"
)
IMDB = Namespace("http://www.csd.abdn.ac.uk/~ggrimnes/dev/imdb/IMDB#")
@@ -130,17 +130,17 @@ def main(argv=None):
rating = None
while not rating or (rating > 5 or rating <= 0):
try:
- rating = int(input("Rating (on five): "))
+ rating = int(eval(input("Rating (on five): ")))
except ValueError:
rating = None
date = None
while not date:
try:
- i = input("Review date (YYYY-MM-DD): ")
+ i = eval(input("Review date (YYYY-MM-DD): "))
date = datetime.datetime(*time.strptime(i, "%Y-%m-%d")[:6])
except:
date = None
- comment = input("Comment: ")
+ comment = eval(input("Comment: "))
s.new_review(movie, date, rating, comment)
else:
help()
diff --git a/examples/graph_digest_benchmark.py b/examples/graph_digest_benchmark.py
index f0d0075c..f5bfd02e 100644
--- a/examples/graph_digest_benchmark.py
+++ b/examples/graph_digest_benchmark.py
@@ -5,7 +5,6 @@ This benchmark will produce graph digests for all of the
downloadable ontologies available in Bioportal.
"""
-from __future__ import print_function
from rdflib import Namespace, Graph
from rdflib.compare import to_isomorphic
diff --git a/rdflib/collection.py b/rdflib/collection.py
index b4bf9f38..3136bafd 100644
--- a/rdflib/collection.py
+++ b/rdflib/collection.py
@@ -1,7 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
from rdflib.namespace import RDF
from rdflib.term import BNode
from rdflib.term import Literal
diff --git a/rdflib/compare.py b/rdflib/compare.py
index c1665b66..ed4415f2 100644
--- a/rdflib/compare.py
+++ b/rdflib/compare.py
@@ -224,7 +224,7 @@ class Color:
value = 0
for triple in color:
value += self.hashfunc(" ".join([stringify(x) for x in triple]))
- val = u"%x" % value
+ val = "%x" % value
self._hash_cache[color] = val
return val
diff --git a/rdflib/compat.py b/rdflib/compat.py
index c058e8df..a2194ac0 100644
--- a/rdflib/compat.py
+++ b/rdflib/compat.py
@@ -2,9 +2,6 @@
Utility functions and objects to ease Python 2/3 compatibility,
and different versions of support libraries.
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
import re
import codecs
@@ -98,7 +95,7 @@ if narrow_build:
def decodeStringEscape(s):
- """
+ r"""
s is byte-string - replace \ escapes in string
"""
diff --git a/rdflib/events.py b/rdflib/events.py
index 816925ed..721b4e37 100644
--- a/rdflib/events.py
+++ b/rdflib/events.py
@@ -1,7 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
__doc__ = """
Dirt Simple Events
diff --git a/rdflib/extras/describer.py b/rdflib/extras/describer.py
index 8afce128..48d0bebf 100644
--- a/rdflib/extras/describer.py
+++ b/rdflib/extras/describer.py
@@ -1,9 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
__doc__ = """
A Describer is a stateful utility for creating RDF statements in a
diff --git a/rdflib/extras/external_graph_libs.py b/rdflib/extras/external_graph_libs.py
index fa311490..cf805c48 100644
--- a/rdflib/extras/external_graph_libs.py
+++ b/rdflib/extras/external_graph_libs.py
@@ -1,9 +1,5 @@
#!/usr/bin/env python
# encoding: utf-8
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
"""Convert (to and) from rdflib graphs to other well known graph libraries.
diff --git a/rdflib/extras/infixowl.py b/rdflib/extras/infixowl.py
index c043675a..d3464bee 100644
--- a/rdflib/extras/infixowl.py
+++ b/rdflib/extras/infixowl.py
@@ -1,9 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
__doc__ = """
RDFLib Python binding for OWL Abstract Syntax
@@ -220,7 +216,7 @@ nsBinds = {
def generateQName(graph, uri):
prefix, uri, localName = graph.compute_qname(classOrIdentifier(uri))
- return u":".join([prefix, localName])
+ return ":".join([prefix, localName])
def classOrTerm(thing):
@@ -278,47 +274,47 @@ def manchesterSyntax(thing, store, boolean=None, transientList=False):
return ":".join([prefix, localName])
if len(named) > 1:
- prefix = u"( " + u" AND ".join(map(castToQName, named)) + u" )"
+ prefix = "( " + " AND ".join(map(castToQName, named)) + " )"
else:
prefix = manchesterSyntax(named[0], store)
if childList:
return (
str(prefix)
- + u" THAT "
- + u" AND ".join(
+ + " THAT "
+ + " AND ".join(
[str(manchesterSyntax(x, store)) for x in childList]
)
)
else:
return prefix
else:
- return u"( " + u" AND ".join([str(c) for c in children]) + u" )"
+ return "( " + " AND ".join([str(c) for c in children]) + " )"
elif boolean == OWL_NS.unionOf:
- return u"( " + u" OR ".join([str(c) for c in children]) + " )"
+ return "( " + " OR ".join([str(c) for c in children]) + " )"
elif boolean == OWL_NS.oneOf:
- return u"{ " + u" ".join([str(c) for c in children]) + " }"
+ return "{ " + " ".join([str(c) for c in children]) + " }"
else:
assert boolean == OWL_NS.complementOf
elif OWL_NS.Restriction in store.objects(subject=thing, predicate=RDF.type):
prop = list(store.objects(subject=thing, predicate=OWL_NS.onProperty))[0]
prefix, uri, localName = store.compute_qname(prop)
- propString = u":".join([prefix, localName])
+ propString = ":".join([prefix, localName])
label = first(store.objects(subject=prop, predicate=RDFS.label))
if label:
propString = "'%s'" % label
for onlyClass in store.objects(subject=thing, predicate=OWL_NS.allValuesFrom):
- return u"( %s ONLY %s )" % (propString, manchesterSyntax(onlyClass, store))
+ return "( %s ONLY %s )" % (propString, manchesterSyntax(onlyClass, store))
for val in store.objects(subject=thing, predicate=OWL_NS.hasValue):
- return u"( %s VALUE %s )" % (propString, manchesterSyntax(val, store))
+ return "( %s VALUE %s )" % (propString, manchesterSyntax(val, store))
for someClass in store.objects(subject=thing, predicate=OWL_NS.someValuesFrom):
- return u"( %s SOME %s )" % (propString, manchesterSyntax(someClass, store))
+ return "( %s SOME %s )" % (propString, manchesterSyntax(someClass, store))
cardLookup = {
OWL_NS.maxCardinality: "MAX",
OWL_NS.minCardinality: "MIN",
OWL_NS.cardinality: "EQUALS",
}
for s, p, o in store.triples_choices((thing, list(cardLookup.keys()), None)):
- return u"( %s %s %s )" % (propString, cardLookup[p], o)
+ return "( %s %s %s )" % (propString, cardLookup[p], o)
compl = list(store.objects(subject=thing, predicate=OWL_NS.complementOf))
if compl:
return "( NOT %s )" % (manchesterSyntax(compl[0], store))
@@ -335,11 +331,11 @@ def manchesterSyntax(thing, store, boolean=None, transientList=False):
return manchesterSyntax(col, store, boolean=boolProp)
try:
prefix, uri, localName = store.compute_qname(thing)
- qname = u":".join([prefix, localName])
+ qname = ":".join([prefix, localName])
except Exception:
if isinstance(thing, BNode):
return thing.n3()
- return u"<" + thing + ">"
+ return "<" + thing + ">"
logger.debug(list(store.objects(subject=thing, predicate=RDF.type)))
raise
return "[]" # +thing._id.encode('utf-8')+'</em>'
@@ -396,7 +392,7 @@ class Individual(object):
if not isinstance(self.identifier, BNode):
try:
prefix, uri, localName = self.graph.compute_qname(self.identifier)
- self.qname = u":".join([prefix, localName])
+ self.qname = ":".join([prefix, localName])
except:
pass
@@ -469,7 +465,7 @@ class Individual(object):
if not isinstance(i, BNode):
try:
prefix, uri, localName = self.graph.compute_qname(i)
- self.qname = u":".join([prefix, localName])
+ self.qname = ":".join([prefix, localName])
except:
pass
diff --git a/rdflib/graph.py b/rdflib/graph.py
index 0d11b41f..41df5429 100644
--- a/rdflib/graph.py
+++ b/rdflib/graph.py
@@ -1,7 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
from xml.sax import SAXParseException
from rdflib.term import Literal # required for doctests
@@ -1099,7 +1095,9 @@ class Graph(Node):
if could_not_guess_format:
raise ParserError(
"Could not guess RDF format for %r from file extension so tried Turtle but failed."
- "You can explicitly specify format using the format argument." % source)
+ "You can explicitly specify format using the format argument."
+ % source
+ )
else:
raise se
finally:
diff --git a/rdflib/namespace.py b/rdflib/namespace.py
index 0fb2f5a4..6826bf03 100644
--- a/rdflib/namespace.py
+++ b/rdflib/namespace.py
@@ -1,7 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import logging
import os
@@ -623,7 +619,7 @@ class NamespaceManager(object):
pl_namespace = get_longest_namespace(self.__strie[namespace], uri)
if pl_namespace is not None:
namespace = pl_namespace
- name = uri[len(namespace):]
+ name = uri[len(namespace) :]
namespace = URIRef(namespace)
prefix = self.store.prefix(namespace) # warning multiple prefixes problem
@@ -809,7 +805,7 @@ class NamespaceManager(object):
NAME_START_CATEGORIES = ["Ll", "Lu", "Lo", "Lt", "Nl"]
SPLIT_START_CATEGORIES = NAME_START_CATEGORIES + ["Nd"]
NAME_CATEGORIES = NAME_START_CATEGORIES + ["Mc", "Me", "Mn", "Lm", "Nd"]
-ALLOWED_NAME_CHARS = [u"\u00B7", u"\u0387", u"-", u".", u"_", u":", u"%"]
+ALLOWED_NAME_CHARS = ["\u00B7", "\u0387", "-", ".", "_", ":", "%"]
# http://www.w3.org/TR/REC-xml-names/#NT-NCName
diff --git a/rdflib/parser.py b/rdflib/parser.py
index 73ce2ba7..fcaed5e4 100644
--- a/rdflib/parser.py
+++ b/rdflib/parser.py
@@ -9,6 +9,7 @@ can plugin to rdflib. If you are wanting to invoke a parser you likely
want to do so through the Graph class parse method.
"""
+
import codecs
import os
import sys
diff --git a/rdflib/paths.py b/rdflib/paths.py
index d2fccd22..ee5d0daa 100644
--- a/rdflib/paths.py
+++ b/rdflib/paths.py
@@ -1,4 +1,4 @@
-__doc__ = """
+__doc__ = r"""
This module implements the SPARQL 1.1 Property path operators, as
defined in:
diff --git a/rdflib/plugin.py b/rdflib/plugin.py
index 143cb53d..2af7370f 100644
--- a/rdflib/plugin.py
+++ b/rdflib/plugin.py
@@ -24,9 +24,6 @@ information.
.. __: http://peak.telecommunity.com/DevCenter/setuptools#dynamic-discovery-of-services-and-plugins
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
from rdflib.store import Store
from rdflib.parser import Parser
diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py
index d866977d..742deaf6 100755
--- a/rdflib/plugins/parsers/notation3.py
+++ b/rdflib/plugins/parsers/notation3.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-u"""
+"""
notation3.py - Standalone Notation3 Parser
Derived from CWM, the Closed World Machine
@@ -27,9 +27,6 @@ Modified to work with rdflib by Gunnar Aastrand Grimnes
Copyright 2010, Gunnar A. Grimnes
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
# Python standard libraries
import sys
@@ -1515,7 +1512,7 @@ class SinkParser:
delim2, delim3, delim4, delim5 = delim1 * 2, delim1 * 3, delim1 * 4, delim1 * 5
j = i
- ustr = u"" # Empty unicode string
+ ustr = "" # Empty unicode string
startline = self.lines # Remember where for error messages
while j < len(argstr):
if argstr[j] == delim1:
diff --git a/rdflib/plugins/parsers/nquads.py b/rdflib/plugins/parsers/nquads.py
index 2a3a9136..d44139c5 100644
--- a/rdflib/plugins/parsers/nquads.py
+++ b/rdflib/plugins/parsers/nquads.py
@@ -22,9 +22,6 @@ graphs that can be used and queried. The store that backs the graph
>>> FOAF = Namespace("http://xmlns.com/foaf/0.1/")
>>> assert(g.value(s, FOAF.name).eq("Arco Publications"))
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
from codecs import getreader
diff --git a/rdflib/plugins/parsers/ntriples.py b/rdflib/plugins/parsers/ntriples.py
index d43a240c..e728fc35 100644
--- a/rdflib/plugins/parsers/ntriples.py
+++ b/rdflib/plugins/parsers/ntriples.py
@@ -45,7 +45,7 @@ class DummySink(object):
print(s, p, o)
-quot = {"t": u"\t", "n": u"\n", "r": u"\r", '"': u'"', "\\": u"\\"}
+quot = {"t": "\t", "n": "\n", "r": "\r", '"': '"', "\\": "\\"}
r_safe = re.compile(r"([\x20\x21\x23-\x5B\x5D-\x7E]+)")
r_quot = re.compile(r'\\(t|n|r|"|\\)')
r_uniquot = re.compile(r"\\u([0-9A-F]{4})|\\U([0-9A-F]{8})")
@@ -88,7 +88,7 @@ def unquote(s):
raise ParseError("Illegal escape at: %s..." % s[:10])
else:
raise ParseError("Illegal literal character: %r" % s[0])
- return u"".join(result)
+ return "".join(result)
r_hibyte = re.compile(r"([\x80-\xFF])")
diff --git a/rdflib/plugins/parsers/rdfxml.py b/rdflib/plugins/parsers/rdfxml.py
index 76761edd..8d16500c 100644
--- a/rdflib/plugins/parsers/rdfxml.py
+++ b/rdflib/plugins/parsers/rdfxml.py
@@ -50,10 +50,10 @@ OLD_TERMS = [
URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#bagID"),
]
-NODE_ELEMENT_EXCEPTIONS = CORE_SYNTAX_TERMS + [RDF.li, ] + OLD_TERMS
+NODE_ELEMENT_EXCEPTIONS = CORE_SYNTAX_TERMS + [RDF.li,] + OLD_TERMS
NODE_ELEMENT_ATTRIBUTES = [RDF.ID, RDF.nodeID, RDF.about]
-PROPERTY_ELEMENT_EXCEPTIONS = CORE_SYNTAX_TERMS + [RDF.Description, ] + OLD_TERMS
+PROPERTY_ELEMENT_EXCEPTIONS = CORE_SYNTAX_TERMS + [RDF.Description,] + OLD_TERMS
PROPERTY_ATTRIBUTE_EXCEPTIONS = (
CORE_SYNTAX_TERMS + [RDF.Description, RDF.li] + OLD_TERMS
)
@@ -553,11 +553,11 @@ class RDFXMLHandler(handler.ContentHandler):
if name[0]:
prefix = self._current_context[name[0]]
if prefix:
- end = u"</%s:%s>" % (prefix, name[1])
+ end = "</%s:%s>" % (prefix, name[1])
else:
- end = u"</%s>" % name[1]
+ end = "</%s>" % name[1]
else:
- end = u"</%s>" % name[1]
+ end = "</%s>" % name[1]
self.parent.object += self.current.object + end
diff --git a/rdflib/plugins/parsers/trig.py b/rdflib/plugins/parsers/trig.py
index 938fb259..9caa0662 100644
--- a/rdflib/plugins/parsers/trig.py
+++ b/rdflib/plugins/parsers/trig.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import
-
from rdflib import ConjunctiveGraph
from rdflib.parser import Parser
from .notation3 import SinkParser, RDFSink
diff --git a/rdflib/plugins/parsers/trix.py b/rdflib/plugins/parsers/trix.py
index 3286aaeb..8e126f4e 100644
--- a/rdflib/plugins/parsers/trix.py
+++ b/rdflib/plugins/parsers/trix.py
@@ -99,12 +99,12 @@ class TriXHandler(handler.ContentHandler):
self.datatype = None
try:
- self.lang = attrs.getValue((str(XMLNS), u"lang"))
+ self.lang = attrs.getValue((str(XMLNS), "lang"))
except:
# language not required - ignore
pass
try:
- self.datatype = attrs.getValueByQName(u"datatype")
+ self.datatype = attrs.getValueByQName("datatype")
except KeyError:
self.error("No required attribute 'datatype'")
else:
@@ -116,7 +116,7 @@ class TriXHandler(handler.ContentHandler):
self.lang = None
self.datatype = None
try:
- self.lang = attrs.getValue((str(XMLNS), u"lang"))
+ self.lang = attrs.getValue((str(XMLNS), "lang"))
except:
# language not required - ignore
pass
diff --git a/rdflib/plugins/serializers/nquads.py b/rdflib/plugins/serializers/nquads.py
index 70c414cd..54ee42ba 100644
--- a/rdflib/plugins/serializers/nquads.py
+++ b/rdflib/plugins/serializers/nquads.py
@@ -33,14 +33,14 @@ class NQuadsSerializer(Serializer):
def _nq_row(triple, context):
if isinstance(triple[2], Literal):
- return u"%s %s %s %s .\n" % (
+ return "%s %s %s %s .\n" % (
triple[0].n3(),
triple[1].n3(),
_quoteLiteral(triple[2]),
context.n3(),
)
else:
- return u"%s %s %s %s .\n" % (
+ return "%s %s %s %s .\n" % (
triple[0].n3(),
triple[1].n3(),
triple[2].n3(),
diff --git a/rdflib/plugins/serializers/nt.py b/rdflib/plugins/serializers/nt.py
index 9ff72539..bc265ee5 100644
--- a/rdflib/plugins/serializers/nt.py
+++ b/rdflib/plugins/serializers/nt.py
@@ -45,13 +45,13 @@ class NT11Serializer(NTSerializer):
def _nt_row(triple):
if isinstance(triple[2], Literal):
- return u"%s %s %s .\n" % (
+ return "%s %s %s .\n" % (
triple[0].n3(),
triple[1].n3(),
_quoteLiteral(triple[2]),
)
else:
- return u"%s %s %s .\n" % (triple[0].n3(), triple[1].n3(), triple[2].n3())
+ return "%s %s %s .\n" % (triple[0].n3(), triple[1].n3(), triple[2].n3())
def _quoteLiteral(l_):
@@ -84,10 +84,10 @@ def _nt_unicode_error_resolver(err):
def _replace_single(c):
c = ord(c)
- fmt = u"\\u%04X" if c <= 0xFFFF else u"\\U%08X"
+ fmt = "\\u%04X" if c <= 0xFFFF else "\\U%08X"
return fmt % c
- string = err.object[err.start: err.end]
+ string = err.object[err.start : err.end]
return "".join(_replace_single(c) for c in string), err.end
diff --git a/rdflib/plugins/serializers/rdfxml.py b/rdflib/plugins/serializers/rdfxml.py
index 3f3c840d..d7c70849 100644
--- a/rdflib/plugins/serializers/rdfxml.py
+++ b/rdflib/plugins/serializers/rdfxml.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import
-
from rdflib.plugins.serializers.xmlwriter import XMLWriter
from rdflib.namespace import Namespace, RDF, RDFS # , split_uri
@@ -283,7 +281,7 @@ class PrettyXMLSerializer(Serializer):
object.value, xml.dom.minidom.Document
):
writer.attribute(RDF.parseType, "Literal")
- writer.text(u"")
+ writer.text("")
writer.stream.write(object)
else:
if object.datatype:
diff --git a/rdflib/plugins/serializers/trig.py b/rdflib/plugins/serializers/trig.py
index abf8d33e..cdaedd48 100644
--- a/rdflib/plugins/serializers/trig.py
+++ b/rdflib/plugins/serializers/trig.py
@@ -14,7 +14,7 @@ __all__ = ["TrigSerializer"]
class TrigSerializer(TurtleSerializer):
short_name = "trig"
- indentString = 4 * u" "
+ indentString = 4 * " "
def __init__(self, store):
if store.context_aware:
diff --git a/rdflib/plugins/serializers/trix.py b/rdflib/plugins/serializers/trix.py
index f6115bf8..05b6f528 100644
--- a/rdflib/plugins/serializers/trix.py
+++ b/rdflib/plugins/serializers/trix.py
@@ -28,7 +28,7 @@ class TriXSerializer(Serializer):
self.writer = XMLWriter(stream, nm, encoding, extra_ns={"": TRIXNS})
- self.writer.push(TRIXNS[u"TriX"])
+ self.writer.push(TRIXNS["TriX"])
# if base is given here, use that, if not and a base is set for the graph use that
if base is None and self.store.base is not None:
base = self.store.base
@@ -48,38 +48,38 @@ class TriXSerializer(Serializer):
stream.write("\n".encode("latin-1"))
def _writeGraph(self, graph):
- self.writer.push(TRIXNS[u"graph"])
+ self.writer.push(TRIXNS["graph"])
if graph.base:
self.writer.attribute(
"http://www.w3.org/XML/1998/namespacebase", graph.base
)
if isinstance(graph.identifier, URIRef):
- self.writer.element(TRIXNS[u"uri"], content=str(graph.identifier))
+ self.writer.element(TRIXNS["uri"], content=str(graph.identifier))
for triple in graph.triples((None, None, None)):
self._writeTriple(triple)
self.writer.pop()
def _writeTriple(self, triple):
- self.writer.push(TRIXNS[u"triple"])
+ self.writer.push(TRIXNS["triple"])
for component in triple:
if isinstance(component, URIRef):
- self.writer.element(TRIXNS[u"uri"], content=str(component))
+ self.writer.element(TRIXNS["uri"], content=str(component))
elif isinstance(component, BNode):
- self.writer.element(TRIXNS[u"id"], content=str(component))
+ self.writer.element(TRIXNS["id"], content=str(component))
elif isinstance(component, Literal):
if component.datatype:
self.writer.element(
- TRIXNS[u"typedLiteral"],
+ TRIXNS["typedLiteral"],
content=str(component),
- attributes={TRIXNS[u"datatype"]: str(component.datatype)},
+ attributes={TRIXNS["datatype"]: str(component.datatype)},
)
elif component.language:
self.writer.element(
- TRIXNS[u"plainLiteral"],
+ TRIXNS["plainLiteral"],
content=str(component),
- attributes={XMLNS[u"lang"]: str(component.language)},
+ attributes={XMLNS["lang"]: str(component.language)},
)
else:
- self.writer.element(TRIXNS[u"plainLiteral"], content=str(component))
+ self.writer.element(TRIXNS["plainLiteral"], content=str(component))
self.writer.pop()
diff --git a/rdflib/plugins/serializers/turtle.py b/rdflib/plugins/serializers/turtle.py
index a2270674..8ec9b479 100644
--- a/rdflib/plugins/serializers/turtle.py
+++ b/rdflib/plugins/serializers/turtle.py
@@ -41,7 +41,7 @@ class RecursiveSerializer(Serializer):
topClasses = [RDFS.Class]
predicateOrder = [RDF.type, RDFS.label]
maxDepth = 10
- indentString = u" "
+ indentString = " "
roundtrip_prefixes = tuple()
def __init__(self, store):
@@ -294,7 +294,7 @@ class TurtleSerializer(RecursiveSerializer):
prefix = self.addNamespace(prefix, namespace)
- return u"%s:%s" % (prefix, local)
+ return "%s:%s" % (prefix, local)
def startDocument(self):
self._started = True
diff --git a/rdflib/plugins/serializers/xmlwriter.py b/rdflib/plugins/serializers/xmlwriter.py
index 99d1e767..b0f1a06e 100644
--- a/rdflib/plugins/serializers/xmlwriter.py
+++ b/rdflib/plugins/serializers/xmlwriter.py
@@ -100,8 +100,8 @@ class XMLWriter(object):
for pre, ns in self.extra_ns.items():
if uri.startswith(ns):
if pre != "":
- return ":".join(pre, uri[len(ns):])
+ return ":".join(pre, uri[len(ns) :])
else:
- return uri[len(ns):]
+ return uri[len(ns) :]
return self.nm.qname_strict(uri)
diff --git a/rdflib/plugins/sparql/algebra.py b/rdflib/plugins/sparql/algebra.py
index cfd4f410..466f8d4b 100644
--- a/rdflib/plugins/sparql/algebra.py
+++ b/rdflib/plugins/sparql/algebra.py
@@ -5,7 +5,6 @@ http://www.w3.org/TR/sparql11-query/#sparqlQuery
"""
-from __future__ import print_function
import functools
import operator
diff --git a/rdflib/plugins/sparql/evaluate.py b/rdflib/plugins/sparql/evaluate.py
index 34fe41e9..9a12200b 100644
--- a/rdflib/plugins/sparql/evaluate.py
+++ b/rdflib/plugins/sparql/evaluate.py
@@ -357,8 +357,8 @@ def _buildQueryStringForServiceCall(ctx, match):
service_query = "BASE <" + base + "> " + service_query
sol = ctx.solution()
if len(sol) > 0:
- variables = " ".join(map(lambda v: v.n3(), sol))
- variables_bound = " ".join(map(lambda v: ctx.get(v).n3(), sol))
+ variables = " ".join([v.n3() for v in sol])
+ variables_bound = " ".join([ctx.get(v).n3() for v in sol])
service_query = (
service_query + "VALUES (" + variables + ") {(" + variables_bound + ")}"
)
diff --git a/rdflib/plugins/sparql/operators.py b/rdflib/plugins/sparql/operators.py
index ef995ce0..c0e51f56 100644
--- a/rdflib/plugins/sparql/operators.py
+++ b/rdflib/plugins/sparql/operators.py
@@ -371,7 +371,7 @@ def Builtin_STRAFTER(expr, ctx):
if i == -1:
return Literal("")
else:
- return Literal(a[i + len(b):], lang=a.language, datatype=a.datatype)
+ return Literal(a[i + len(b) :], lang=a.language, datatype=a.datatype)
def Builtin_CONTAINS(expr, ctx):
diff --git a/rdflib/plugins/sparql/parser.py b/rdflib/plugins/sparql/parser.py
index 2124aad2..1de46918 100644
--- a/rdflib/plugins/sparql/parser.py
+++ b/rdflib/plugins/sparql/parser.py
@@ -4,8 +4,6 @@ SPARQL 1.1 Parser
based on pyparsing
"""
-from __future__ import absolute_import
-
import sys
import re
@@ -179,21 +177,21 @@ if sys.maxunicode == 0xFFFF:
#
# in py3.3 this is fixed
- PN_CHARS_BASE_re = u"A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD"
+ PN_CHARS_BASE_re = "A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD"
else:
# wide python build
- PN_CHARS_BASE_re = u"A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF"
+ PN_CHARS_BASE_re = "A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF"
# [165] PN_CHARS_U ::= PN_CHARS_BASE | '_'
PN_CHARS_U_re = "_" + PN_CHARS_BASE_re
# [167] PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
-PN_CHARS_re = u"\\-0-9\u00B7\u0300-\u036F\u203F-\u2040" + PN_CHARS_U_re
+PN_CHARS_re = "\\-0-9\u00B7\u0300-\u036F\u203F-\u2040" + PN_CHARS_U_re
# PN_CHARS = Regex(u'[%s]'%PN_CHARS_re, flags=re.U)
# [168] PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS|'.')* PN_CHARS)?
PN_PREFIX = Regex(
- u"[%s](?:[%s\\.]*[%s])?" % (PN_CHARS_BASE_re, PN_CHARS_re, PN_CHARS_re), flags=re.U
+ "[%s](?:[%s\\.]*[%s])?" % (PN_CHARS_BASE_re, PN_CHARS_re, PN_CHARS_re), flags=re.U
)
# [140] PNAME_NS ::= PN_PREFIX? ':'
@@ -221,7 +219,7 @@ PLX_re = "(%s|%s)" % (PN_LOCAL_ESC_re, PERCENT_re)
# [169] PN_LOCAL ::= (PN_CHARS_U | ':' | [0-9] | PLX ) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX) )?
PN_LOCAL = Regex(
- u"""([%(PN_CHARS_U)s:0-9]|%(PLX)s)
+ """([%(PN_CHARS_U)s:0-9]|%(PLX)s)
(([%(PN_CHARS)s\\.:]|%(PLX)s)*
([%(PN_CHARS)s:]|%(PLX)s) )?"""
% dict(PN_CHARS_U=PN_CHARS_U_re, PN_CHARS=PN_CHARS_re, PLX=PLX_re),
@@ -241,7 +239,7 @@ PNAME_LN = PNAME_NS + Param("localname", PN_LOCAL.leaveWhitespace())
# [142] BLANK_NODE_LABEL ::= '_:' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
BLANK_NODE_LABEL = Regex(
- u"_:[0-9%s](?:[\\.%s]*[%s])?" % (PN_CHARS_U_re, PN_CHARS_re, PN_CHARS_re),
+ "_:[0-9%s](?:[\\.%s]*[%s])?" % (PN_CHARS_U_re, PN_CHARS_re, PN_CHARS_re),
flags=re.U,
)
BLANK_NODE_LABEL.setParseAction(lambda x: rdflib.BNode(x[0][2:]))
@@ -249,7 +247,7 @@ BLANK_NODE_LABEL.setParseAction(lambda x: rdflib.BNode(x[0][2:]))
# [166] VARNAME ::= ( PN_CHARS_U | [0-9] ) ( PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
VARNAME = Regex(
- u"[%s0-9][%s0-9\u00B7\u0300-\u036F\u203F-\u2040]*" % (PN_CHARS_U_re, PN_CHARS_U_re),
+ "[%s0-9][%s0-9\u00B7\u0300-\u036F\u203F-\u2040]*" % (PN_CHARS_U_re, PN_CHARS_U_re),
flags=re.U,
)
@@ -312,7 +310,7 @@ DOUBLE_NEGATIVE.setParseAction(lambda x: neg(x[0]))
# [158] STRING_LITERAL_LONG1 ::= "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR ) )* "'''"
# STRING_LITERAL_LONG1 = Literal("'''") + ( Optional( Literal("'") | "''"
# ) + ZeroOrMore( ~ Literal("'\\") | ECHAR ) ) + "'''"
-STRING_LITERAL_LONG1 = Regex(u"'''((?:'|'')?(?:[^'\\\\]|\\\\['ntbrf\\\\]))*'''")
+STRING_LITERAL_LONG1 = Regex("'''((?:'|'')?(?:[^'\\\\]|\\\\['ntbrf\\\\]))*'''")
STRING_LITERAL_LONG1.setParseAction(
lambda x: rdflib.Literal(decodeUnicodeEscape(x[0][3:-3]))
)
@@ -320,7 +318,7 @@ STRING_LITERAL_LONG1.setParseAction(
# [159] STRING_LITERAL_LONG2 ::= '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR ) )* '"""'
# STRING_LITERAL_LONG2 = Literal('"""') + ( Optional( Literal('"') | '""'
# ) + ZeroOrMore( ~ Literal('"\\') | ECHAR ) ) + '"""'
-STRING_LITERAL_LONG2 = Regex(u'"""(?:(?:"|"")?(?:[^"\\\\]|\\\\["ntbrf\\\\]))*"""')
+STRING_LITERAL_LONG2 = Regex('"""(?:(?:"|"")?(?:[^"\\\\]|\\\\["ntbrf\\\\]))*"""')
STRING_LITERAL_LONG2.setParseAction(
lambda x: rdflib.Literal(decodeUnicodeEscape(x[0][3:-3]))
)
@@ -329,7 +327,7 @@ STRING_LITERAL_LONG2.setParseAction(
# STRING_LITERAL1 = Literal("'") + ZeroOrMore(
# Regex(u'[^\u0027\u005C\u000A\u000D]',flags=re.U) | ECHAR ) + "'"
-STRING_LITERAL1 = Regex(u"'(?:[^'\\n\\r\\\\]|\\\\['ntbrf\\\\])*'(?!')", flags=re.U)
+STRING_LITERAL1 = Regex("'(?:[^'\\n\\r\\\\]|\\\\['ntbrf\\\\])*'(?!')", flags=re.U)
STRING_LITERAL1.setParseAction(
lambda x: rdflib.Literal(decodeUnicodeEscape(x[0][1:-1]))
)
@@ -338,7 +336,7 @@ STRING_LITERAL1.setParseAction(
# STRING_LITERAL2 = Literal('"') + ZeroOrMore (
# Regex(u'[^\u0022\u005C\u000A\u000D]',flags=re.U) | ECHAR ) + '"'
-STRING_LITERAL2 = Regex(u'"(?:[^"\\n\\r\\\\]|\\\\["ntbrf\\\\])*"(?!")', flags=re.U)
+STRING_LITERAL2 = Regex('"(?:[^"\\n\\r\\\\]|\\\\["ntbrf\\\\])*"(?!")', flags=re.U)
STRING_LITERAL2.setParseAction(
lambda x: rdflib.Literal(decodeUnicodeEscape(x[0][1:-1]))
)
@@ -1517,7 +1515,7 @@ expandUnicodeEscapes_re = re.compile(r"\\u([0-9a-f]{4}(?:[0-9a-f]{4})?)", flags=
def expandUnicodeEscapes(q):
- """
+ r"""
The syntax of the SPARQL Query Language is expressed over code points in Unicode [UNICODE]. The encoding is always UTF-8 [RFC3629].
Unicode code points may also be expressed using an \ uXXXX (U+0 to U+FFFF) or \ UXXXXXXXX syntax (for U+10000 onwards) where X is a hexadecimal digit [0-9A-F]
"""
diff --git a/rdflib/plugins/sparql/results/xmlresults.py b/rdflib/plugins/sparql/results/xmlresults.py
index 1511783f..8c77b50a 100644
--- a/rdflib/plugins/sparql/results/xmlresults.py
+++ b/rdflib/plugins/sparql/results/xmlresults.py
@@ -10,7 +10,7 @@ from rdflib import Literal, URIRef, BNode, Variable
from rdflib.query import Result, ResultParser, ResultSerializer, ResultException
-SPARQL_XML_NAMESPACE = u"http://www.w3.org/2005/sparql-results#"
+SPARQL_XML_NAMESPACE = "http://www.w3.org/2005/sparql-results#"
RESULTS_NS_ET = "{%s}" % SPARQL_XML_NAMESPACE
log = logging.getLogger(__name__)
@@ -129,10 +129,10 @@ class SPARQLXMLWriter:
def __init__(self, output, encoding="utf-8"):
writer = XMLGenerator(output, encoding)
writer.startDocument()
- writer.startPrefixMapping(u"", SPARQL_XML_NAMESPACE)
- writer.startPrefixMapping(u"xml", XML_NAMESPACE)
+ writer.startPrefixMapping("", SPARQL_XML_NAMESPACE)
+ writer.startPrefixMapping("xml", XML_NAMESPACE)
writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"sparql"), u"sparql", AttributesNSImpl({}, {})
+ (SPARQL_XML_NAMESPACE, "sparql"), "sparql", AttributesNSImpl({}, {})
)
self.writer = writer
self._output = output
@@ -141,99 +141,99 @@ class SPARQLXMLWriter:
def write_header(self, allvarsL):
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"head"), u"head", AttributesNSImpl({}, {})
+ (SPARQL_XML_NAMESPACE, "head"), "head", AttributesNSImpl({}, {})
)
for i in range(0, len(allvarsL)):
attr_vals = {
- (None, u"name"): str(allvarsL[i]),
+ (None, "name"): str(allvarsL[i]),
}
attr_qnames = {
- (None, u"name"): u"name",
+ (None, "name"): "name",
}
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"variable"),
- u"variable",
+ (SPARQL_XML_NAMESPACE, "variable"),
+ "variable",
AttributesNSImpl(attr_vals, attr_qnames),
)
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"variable"), u"variable")
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"head"), u"head")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "variable"), "variable")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "head"), "head")
def write_ask(self, val):
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"boolean"), u"boolean", AttributesNSImpl({}, {})
+ (SPARQL_XML_NAMESPACE, "boolean"), "boolean", AttributesNSImpl({}, {})
)
self.writer.characters(str(val).lower())
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"boolean"), u"boolean")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "boolean"), "boolean")
def write_results_header(self):
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"results"), u"results", AttributesNSImpl({}, {})
+ (SPARQL_XML_NAMESPACE, "results"), "results", AttributesNSImpl({}, {})
)
self._results = True
def write_start_result(self):
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"result"), u"result", AttributesNSImpl({}, {})
+ (SPARQL_XML_NAMESPACE, "result"), "result", AttributesNSImpl({}, {})
)
self._resultStarted = True
def write_end_result(self):
assert self._resultStarted
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"result"), u"result")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "result"), "result")
self._resultStarted = False
def write_binding(self, name, val):
assert self._resultStarted
attr_vals = {
- (None, u"name"): str(name),
+ (None, "name"): str(name),
}
attr_qnames = {
- (None, u"name"): u"name",
+ (None, "name"): "name",
}
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"binding"),
- u"binding",
+ (SPARQL_XML_NAMESPACE, "binding"),
+ "binding",
AttributesNSImpl(attr_vals, attr_qnames),
)
if isinstance(val, URIRef):
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"uri"), u"uri", AttributesNSImpl({}, {})
+ (SPARQL_XML_NAMESPACE, "uri"), "uri", AttributesNSImpl({}, {})
)
self.writer.characters(val)
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"uri"), u"uri")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "uri"), "uri")
elif isinstance(val, BNode):
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"bnode"), u"bnode", AttributesNSImpl({}, {})
+ (SPARQL_XML_NAMESPACE, "bnode"), "bnode", AttributesNSImpl({}, {})
)
self.writer.characters(val)
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"bnode"), u"bnode")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "bnode"), "bnode")
elif isinstance(val, Literal):
attr_vals = {}
attr_qnames = {}
if val.language:
- attr_vals[(XML_NAMESPACE, u"lang")] = val.language
- attr_qnames[(XML_NAMESPACE, u"lang")] = u"xml:lang"
+ attr_vals[(XML_NAMESPACE, "lang")] = val.language
+ attr_qnames[(XML_NAMESPACE, "lang")] = "xml:lang"
elif val.datatype:
- attr_vals[(None, u"datatype")] = val.datatype
- attr_qnames[(None, u"datatype")] = u"datatype"
+ attr_vals[(None, "datatype")] = val.datatype
+ attr_qnames[(None, "datatype")] = "datatype"
self.writer.startElementNS(
- (SPARQL_XML_NAMESPACE, u"literal"),
- u"literal",
+ (SPARQL_XML_NAMESPACE, "literal"),
+ "literal",
AttributesNSImpl(attr_vals, attr_qnames),
)
self.writer.characters(val)
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"literal"), u"literal")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "literal"), "literal")
else:
raise Exception("Unsupported RDF term: %s" % val)
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"binding"), u"binding")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "binding"), "binding")
def close(self):
if self._results:
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"results"), u"results")
- self.writer.endElementNS((SPARQL_XML_NAMESPACE, u"sparql"), u"sparql")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "results"), "results")
+ self.writer.endElementNS((SPARQL_XML_NAMESPACE, "sparql"), "sparql")
self.writer.endDocument()
diff --git a/rdflib/plugins/sparql/sparql.py b/rdflib/plugins/sparql/sparql.py
index 417edc03..888ca667 100644
--- a/rdflib/plugins/sparql/sparql.py
+++ b/rdflib/plugins/sparql/sparql.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import
-
import collections
import itertools
import datetime
diff --git a/rdflib/plugins/stores/memory.py b/rdflib/plugins/stores/memory.py
index 93b6ec25..8f783fc8 100644
--- a/rdflib/plugins/stores/memory.py
+++ b/rdflib/plugins/stores/memory.py
@@ -166,10 +166,14 @@ class SimpleMemory(Store):
return (c for c in []) # TODO: best way to return empty generator
def query(self, query, initNs, initBindings, queryGraph, **kwargs):
- super(SimpleMemory, self).query(query, initNs, initBindings, queryGraph, **kwargs)
+ super(SimpleMemory, self).query(
+ query, initNs, initBindings, queryGraph, **kwargs
+ )
def update(self, update, initNs, initBindings, queryGraph, **kwargs):
- super(SimpleMemory, self).update(update, initNs, initBindings, queryGraph, **kwargs)
+ super(SimpleMemory, self).update(
+ update, initNs, initBindings, queryGraph, **kwargs
+ )
class Memory(Store):
@@ -200,9 +204,7 @@ class Memory(Store):
self.__namespace = {}
self.__prefix = {}
self.__context_obj_map = {}
- self.__tripleContexts = (
- {}
- )
+ self.__tripleContexts = {}
self.__contextTriples = {None: set()}
# all contexts used in store (unencoded)
self.__all_contexts = set()
@@ -504,7 +506,9 @@ class Memory(Store):
return None
try:
# ctx could be a graph. In that case, use its identifier
- ctx_str = "{}:{}".format(str(ctx.identifier.__class__.__name__), str(ctx.identifier))
+ ctx_str = "{}:{}".format(
+ str(ctx.identifier.__class__.__name__), str(ctx.identifier)
+ )
self.__context_obj_map[ctx_str] = ctx
return ctx_str
except AttributeError:
diff --git a/rdflib/plugins/stores/sleepycat.py b/rdflib/plugins/stores/sleepycat.py
index 735d3c3a..7729969e 100644
--- a/rdflib/plugins/stores/sleepycat.py
+++ b/rdflib/plugins/stores/sleepycat.py
@@ -110,8 +110,8 @@ class Sleepycat(Store):
dbsetflags = 0
# create and open the DBs
- self.__indicies = [None, ] * 3
- self.__indicies_info = [None, ] * 3
+ self.__indicies = [None,] * 3
+ self.__indicies_info = [None,] * 3
for i in range(0, 3):
index_name = to_key_func(i)(
("s".encode("latin-1"), "p".encode("latin-1"), "o".encode("latin-1")),
diff --git a/rdflib/plugins/stores/sparqlstore.py b/rdflib/plugins/stores/sparqlstore.py
index 39f9790f..51c40844 100644
--- a/rdflib/plugins/stores/sparqlstore.py
+++ b/rdflib/plugins/stores/sparqlstore.py
@@ -22,7 +22,7 @@ LIMIT = "LIMIT"
OFFSET = "OFFSET"
ORDERBY = "ORDER BY"
-BNODE_IDENT_PATTERN = re.compile("(?P<label>_\:[^\s]+)")
+BNODE_IDENT_PATTERN = re.compile(r"(?P<label>_\:[^\s]+)")
def _node_to_sparql(node):
@@ -425,27 +425,27 @@ class SPARQLUpdateStore(SPARQLStore):
# in order to avoid unbalanced curly braces.
# From the SPARQL grammar
- STRING_LITERAL1 = u"'([^'\\\\]|\\\\.)*'"
- STRING_LITERAL2 = u'"([^"\\\\]|\\\\.)*"'
- STRING_LITERAL_LONG1 = u"'''(('|'')?([^'\\\\]|\\\\.))*'''"
- STRING_LITERAL_LONG2 = u'"""(("|"")?([^"\\\\]|\\\\.))*"""'
- String = u"(%s)|(%s)|(%s)|(%s)" % (
+ STRING_LITERAL1 = "'([^'\\\\]|\\\\.)*'"
+ STRING_LITERAL2 = '"([^"\\\\]|\\\\.)*"'
+ STRING_LITERAL_LONG1 = "'''(('|'')?([^'\\\\]|\\\\.))*'''"
+ STRING_LITERAL_LONG2 = '"""(("|"")?([^"\\\\]|\\\\.))*"""'
+ String = "(%s)|(%s)|(%s)|(%s)" % (
STRING_LITERAL1,
STRING_LITERAL2,
STRING_LITERAL_LONG1,
STRING_LITERAL_LONG2,
)
- IRIREF = u'<([^<>"{}|^`\\]\\\\\[\\x00-\\x20])*>'
- COMMENT = u"#[^\\x0D\\x0A]*([\\x0D\\x0A]|\\Z)"
+ IRIREF = '<([^<>"{}|^`\\]\\\\[\\x00-\\x20])*>'
+ COMMENT = "#[^\\x0D\\x0A]*([\\x0D\\x0A]|\\Z)"
# Simplified grammar to find { at beginning and } at end of blocks
- BLOCK_START = u"{"
- BLOCK_END = u"}"
- ESCAPED = u"\\\\."
+ BLOCK_START = "{"
+ BLOCK_END = "}"
+ ESCAPED = "\\\\."
# Match anything that doesn't start or end a block:
- BlockContent = u"(%s)|(%s)|(%s)|(%s)" % (String, IRIREF, COMMENT, ESCAPED)
- BlockFinding = u"(?P<block_start>%s)|(?P<block_end>%s)|(?P<block_content>%s)" % (
+ BlockContent = "(%s)|(%s)|(%s)|(%s)" % (String, IRIREF, COMMENT, ESCAPED)
+ BlockFinding = "(?P<block_start>%s)|(?P<block_end>%s)|(?P<block_content>%s)" % (
BLOCK_START,
BLOCK_END,
BlockContent,
@@ -724,12 +724,12 @@ class SPARQLUpdateStore(SPARQLStore):
if match.group("block_start") is not None:
level += 1
if level == 1:
- modified_query.append(query[pos: match.end()])
+ modified_query.append(query[pos : match.end()])
modified_query.append(graph_block_open)
pos = match.end()
elif match.group("block_end") is not None:
if level == 1:
- since_previous_pos = query[pos: match.start()]
+ since_previous_pos = query[pos : match.start()]
if modified_query[-1] is graph_block_open and (
since_previous_pos == "" or since_previous_pos.isspace()
):
diff --git a/rdflib/query.py b/rdflib/query.py
index 3e21632f..ae23e3b3 100644
--- a/rdflib/query.py
+++ b/rdflib/query.py
@@ -1,7 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import os
import itertools
import shutil
diff --git a/rdflib/resource.py b/rdflib/resource.py
index 691a07f1..f9063754 100644
--- a/rdflib/resource.py
+++ b/rdflib/resource.py
@@ -1,8 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
__doc__ = """
The :class:`~rdflib.resource.Resource` class wraps a
diff --git a/rdflib/store.py b/rdflib/store.py
index ead1c2e7..0a539df8 100644
--- a/rdflib/store.py
+++ b/rdflib/store.py
@@ -1,7 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
from io import BytesIO
import pickle
from rdflib.events import Dispatcher, Event
diff --git a/rdflib/term.py b/rdflib/term.py
index 40330508..32ec6af4 100644
--- a/rdflib/term.py
+++ b/rdflib/term.py
@@ -20,11 +20,7 @@ underlying Graph:
* Numerical Ranges
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-# from __future__ import unicode_literals
from fractions import Fraction
__all__ = [
@@ -78,7 +74,7 @@ _invalid_uri_chars = '<>" {}|\\^`'
def _is_valid_uri(uri):
- return all(map(lambda c: ord(c) > 256 or c not in _invalid_uri_chars, uri))
+ return all([ord(c) > 256 or not c in _invalid_uri_chars for c in uri])
_lang_tag_regex = compile("^[a-zA-Z]+(?:-[a-zA-Z0-9]+)*$")
@@ -303,7 +299,7 @@ class URIRef(Identifier):
"""
if isinstance(self, RDFLibGenid):
parsed_uri = urlparse("%s" % self)
- return BNode(value=parsed_uri.path[len(rdflib_skolem_genid):])
+ return BNode(value=parsed_uri.path[len(rdflib_skolem_genid) :])
elif isinstance(self, Genid):
bnode_id = "%s" % self
if bnode_id in skolems:
@@ -1260,7 +1256,7 @@ class Literal(Identifier):
# in py >=2.6 the string.format function makes this easier
# we try to produce "pretty" output
if self.datatype == _XSD_DOUBLE:
- return sub("\\.?0*e", "e", u"%e" % float(self))
+ return sub("\\.?0*e", "e", "%e" % float(self))
elif self.datatype == _XSD_DECIMAL:
s = "%s" % self
if "." not in s:
@@ -1268,9 +1264,9 @@ class Literal(Identifier):
return s
elif self.datatype == _XSD_BOOLEAN:
- return (u"%s" % self).lower()
+ return ("%s" % self).lower()
else:
- return u"%s" % self
+ return "%s" % self
encoded = self._quote_encode()
diff --git a/rdflib/tools/csv2rdf.py b/rdflib/tools/csv2rdf.py
index 64b7c6eb..eed77298 100644
--- a/rdflib/tools/csv2rdf.py
+++ b/rdflib/tools/csv2rdf.py
@@ -5,8 +5,6 @@ try: ``csv2rdf --help``
"""
-from __future__ import print_function
-
import sys
import re
import csv
@@ -102,7 +100,7 @@ def toProperty(label):
firstNm => firstNm
"""
- label = re.sub("[^\w]", " ", label)
+ label = re.sub("[^\\w]", " ", label)
label = re.sub("([a-z])([A-Z])", "\\1 \\2", label)
label = label.split(" ")
return "".join([label[0].lower()] + [x.capitalize() for x in label[1:]])
diff --git a/rdflib/tools/graphisomorphism.py b/rdflib/tools/graphisomorphism.py
index a073d7d9..fbb31c0e 100644
--- a/rdflib/tools/graphisomorphism.py
+++ b/rdflib/tools/graphisomorphism.py
@@ -3,8 +3,6 @@ A commandline tool for testing if RDF graphs are isomorpic, i.e. equal
if BNode labels are ignored.
"""
-from __future__ import absolute_import
-
from rdflib import Graph
from rdflib import BNode
from itertools import combinations
diff --git a/rdflib/tools/rdf2dot.py b/rdflib/tools/rdf2dot.py
index 9b622b66..84e3d359 100644
--- a/rdflib/tools/rdf2dot.py
+++ b/rdflib/tools/rdf2dot.py
@@ -9,8 +9,6 @@ You can draw the graph of an RDF file directly:
"""
-from __future__ import absolute_import
-
import rdflib
import rdflib.extras.cmdlineutils
@@ -110,10 +108,10 @@ def rdf2dot(g, stream, opts={}):
def formatliteral(l, g):
v = cgi.escape(l)
if l.datatype:
- return u"&quot;%s&quot;^^%s" % (v, qname(l.datatype, g))
+ return "&quot;%s&quot;^^%s" % (v, qname(l.datatype, g))
elif l.language:
- return u"&quot;%s&quot;@%s" % (v, l.language)
- return u"&quot;%s&quot;" % v
+ return "&quot;%s&quot;@%s" % (v, l.language)
+ return "&quot;%s&quot;" % v
def qname(x, g):
try:
@@ -125,7 +123,7 @@ def rdf2dot(g, stream, opts={}):
def color(p):
return "BLACK"
- stream.write(u'digraph { \n node [ fontname="DejaVu Sans" ] ; \n')
+ stream.write('digraph { \n node [ fontname="DejaVu Sans" ] ; \n')
for s, p, o in g:
sn = node(s)
@@ -134,28 +132,28 @@ def rdf2dot(g, stream, opts={}):
if isinstance(o, (rdflib.URIRef, rdflib.BNode)):
on = node(o)
opstr = (
- u"\t%s -> %s [ color=%s, label=< <font point-size='10' "
- + u"color='#336633'>%s</font> > ] ;\n"
+ "\t%s -> %s [ color=%s, label=< <font point-size='10' "
+ + "color='#336633'>%s</font> > ] ;\n"
)
stream.write(opstr % (sn, on, color(p), qname(p, g)))
else:
fields[sn].add((qname(p, g), formatliteral(o, g)))
for u, n in nodes.items():
- stream.write(u"# %s %s\n" % (u, n))
+ stream.write("# %s %s\n" % (u, n))
f = [
- u"<tr><td align='left'>%s</td><td align='left'>%s</td></tr>" % x
+ "<tr><td align='left'>%s</td><td align='left'>%s</td></tr>" % x
for x in sorted(fields[n])
]
opstr = (
- u"%s [ shape=none, color=%s label=< <table color='#666666'"
- + u" cellborder='0' cellspacing='0' border='1'><tr>"
- + u"<td colspan='2' bgcolor='grey'><B>%s</B></td></tr><tr>"
- + u"<td href='%s' bgcolor='#eeeeee' colspan='2'>"
- + u"<font point-size='10' color='#6666ff'>%s</font></td>"
- + u"</tr>%s</table> > ] \n"
+ "%s [ shape=none, color=%s label=< <table color='#666666'"
+ + " cellborder='0' cellspacing='0' border='1'><tr>"
+ + "<td colspan='2' bgcolor='grey'><B>%s</B></td></tr><tr>"
+ + "<td href='%s' bgcolor='#eeeeee' colspan='2'>"
+ + "<font point-size='10' color='#6666ff'>%s</font></td>"
+ + "</tr>%s</table> > ] \n"
)
- stream.write(opstr % (n, NODECOLOR, label(u, g), u, u, u"".join(f)))
+ stream.write(opstr % (n, NODECOLOR, label(u, g), u, u, "".join(f)))
stream.write("}\n")
diff --git a/rdflib/tools/rdfpipe.py b/rdflib/tools/rdfpipe.py
index 6ec9e6c2..d0673f72 100644
--- a/rdflib/tools/rdfpipe.py
+++ b/rdflib/tools/rdfpipe.py
@@ -5,8 +5,6 @@ A commandline tool for parsing RDF in different formats and serializing the
resulting graph to a chosen format.
"""
-from __future__ import absolute_import
-
import sys
from optparse import OptionParser
import logging
diff --git a/rdflib/tools/rdfs2dot.py b/rdflib/tools/rdfs2dot.py
index e8cf5813..cb8d0bfd 100644
--- a/rdflib/tools/rdfs2dot.py
+++ b/rdflib/tools/rdfs2dot.py
@@ -9,8 +9,6 @@ You can draw the graph of an RDFS file directly:
rdf2dot my_rdfs_file.rdf | dot -Tpng | display
"""
-from __future__ import absolute_import
-
import rdflib.extras.cmdlineutils
import sys
@@ -98,7 +96,7 @@ def rdfs2dot(g, stream, opts={}):
pass # bnodes and some weird URIs cannot be split
return l_
- stream.write(u'digraph { \n node [ fontname="DejaVu Sans" ] ; \n')
+ stream.write('digraph { \n node [ fontname="DejaVu Sans" ] ; \n')
for x in g.subjects(RDF.type, RDFS.Class):
n = node(x)
@@ -106,7 +104,7 @@ def rdfs2dot(g, stream, opts={}):
for x, y in g.subject_objects(RDFS.subClassOf):
x = node(x)
y = node(y)
- stream.write(u"\t%s -> %s [ color=%s ] ;\n" % (y, x, ISACOLOR))
+ stream.write("\t%s -> %s [ color=%s ] ;\n" % (y, x, ISACOLOR))
for x in g.subjects(RDF.type, RDF.Property):
for a, b in itertools.product(
@@ -125,18 +123,18 @@ def rdfs2dot(g, stream, opts={}):
)
for u, n in nodes.items():
- stream.write(u"# %s %s\n" % (u, n))
+ stream.write("# %s %s\n" % (u, n))
f = [
- u"<tr><td align='left'>%s</td><td>%s</td></tr>" % x
+ "<tr><td align='left'>%s</td><td>%s</td></tr>" % x
for x in sorted(fields[n])
]
opstr = (
- u"%s [ shape=none, color=%s label=< <table color='#666666'"
- + u' cellborder="0" cellspacing=\'0\' border="1"><tr>'
- + u"<td colspan=\"2\" bgcolor='grey'><B>%s</B></td>"
- + u"</tr>%s</table> > ] \n"
+ "%s [ shape=none, color=%s label=< <table color='#666666'"
+ + " cellborder='0' cellspacing='0' border='1'><tr>"
+ + "<td colspan='2' bgcolor='grey'><B>%s</B></td>"
+ + "</tr>%s</table> > ] \n"
)
- stream.write(opstr % (n, NODECOLOR, label(u, g), u"".join(f)))
+ stream.write(opstr % (n, NODECOLOR, label(u, g), "".join(f)))
stream.write("}\n")
diff --git a/rdflib/util.py b/rdflib/util.py
index c5f1ff09..592e896e 100644
--- a/rdflib/util.py
+++ b/rdflib/util.py
@@ -28,9 +28,6 @@ Statement and component type checkers
* check_pattern
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
from calendar import timegm
from time import altzone
@@ -179,7 +176,7 @@ def from_n3(s, default=None, backend=None, nsm=None):
else:
quotes = '"'
value, rest = s.rsplit(quotes, 1)
- value = value[len(quotes):] # strip leading quotes
+ value = value[len(quotes) :] # strip leading quotes
datatype = None
language = None
@@ -190,7 +187,7 @@ def from_n3(s, default=None, backend=None, nsm=None):
# datatype has to come after lang-tag so ignore everything before
# see: http://www.w3.org/TR/2011/WD-turtle-20110809/
# #prod-turtle2-RDFLiteral
- datatype = from_n3(rest[dtoffset + 2:], default, backend, nsm)
+ datatype = from_n3(rest[dtoffset + 2 :], default, backend, nsm)
else:
if rest.startswith("@"):
language = rest[1:] # strip leading at sign
diff --git a/run_tests.py b/run_tests.py
index ab68f792..2f6d5086 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -38,8 +38,6 @@ coverage options).
See <http://nedbatchelder.com/code/modules/coverage.html> for details.
"""
-from __future__ import print_function
-
NOSE_ARGS = [
"--with-doctest",
diff --git a/test/manifest.py b/test/manifest.py
index 107b9422..23c66abe 100644
--- a/test/manifest.py
+++ b/test/manifest.py
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
from collections import namedtuple
from nose.tools import nottest
diff --git a/test/store_performance.py b/test/store_performance.py
index 399ac7cb..dc3fe7ce 100644
--- a/test/store_performance.py
+++ b/test/store_performance.py
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
import unittest
import os
import gc
diff --git a/test/test_auditable.py b/test/test_auditable.py
index e5aff715..f8ab73c1 100644
--- a/test/test_auditable.py
+++ b/test/test_auditable.py
@@ -1,5 +1,4 @@
# -*- coding=utf8 -*-
-from __future__ import unicode_literals
import unittest
from rdflib import Graph, Namespace
diff --git a/test/test_canonicalization.py b/test/test_canonicalization.py
index 75abff74..c3a8bf04 100644
--- a/test/test_canonicalization.py
+++ b/test/test_canonicalization.py
@@ -201,13 +201,13 @@ def test_issue494_collapsing_bnodes():
"""Test for https://github.com/RDFLib/rdflib/issues/494 collapsing BNodes"""
g = Graph()
g += [
- (BNode("Na1a8fbcf755f41c1b5728f326be50994"), RDF["object"], URIRef(u"source")),
+ (BNode("Na1a8fbcf755f41c1b5728f326be50994"), RDF["object"], URIRef("source")),
(BNode("Na1a8fbcf755f41c1b5728f326be50994"), RDF["predicate"], BNode("vcb3")),
(BNode("Na1a8fbcf755f41c1b5728f326be50994"), RDF["subject"], BNode("vcb2")),
(BNode("Na1a8fbcf755f41c1b5728f326be50994"), RDF["type"], RDF["Statement"]),
- (BNode("Na713b02f320d409c806ff0190db324f4"), RDF["object"], URIRef(u"target")),
+ (BNode("Na713b02f320d409c806ff0190db324f4"), RDF["object"], URIRef("target")),
(BNode("Na713b02f320d409c806ff0190db324f4"), RDF["predicate"], BNode("vcb0")),
- (BNode("Na713b02f320d409c806ff0190db324f4"), RDF["subject"], URIRef(u"source")),
+ (BNode("Na713b02f320d409c806ff0190db324f4"), RDF["subject"], URIRef("source")),
(BNode("Na713b02f320d409c806ff0190db324f4"), RDF["type"], RDF["Statement"]),
(BNode("Ndb804ba690a64b3dbb9063c68d5e3550"), RDF["object"], BNode("vr0KcS4")),
(
@@ -215,15 +215,15 @@ def test_issue494_collapsing_bnodes():
RDF["predicate"],
BNode("vrby3JV"),
),
- (BNode("Ndb804ba690a64b3dbb9063c68d5e3550"), RDF["subject"], URIRef(u"source")),
+ (BNode("Ndb804ba690a64b3dbb9063c68d5e3550"), RDF["subject"], URIRef("source")),
(BNode("Ndb804ba690a64b3dbb9063c68d5e3550"), RDF["type"], RDF["Statement"]),
- (BNode("Ndfc47fb1cd2d4382bcb8d5eb7835a636"), RDF["object"], URIRef(u"source")),
+ (BNode("Ndfc47fb1cd2d4382bcb8d5eb7835a636"), RDF["object"], URIRef("source")),
(BNode("Ndfc47fb1cd2d4382bcb8d5eb7835a636"), RDF["predicate"], BNode("vcb5")),
- (BNode("Ndfc47fb1cd2d4382bcb8d5eb7835a636"), RDF["subject"], URIRef(u"target")),
+ (BNode("Ndfc47fb1cd2d4382bcb8d5eb7835a636"), RDF["subject"], URIRef("target")),
(BNode("Ndfc47fb1cd2d4382bcb8d5eb7835a636"), RDF["type"], RDF["Statement"]),
- (BNode("Nec6864ef180843838aa9805bac835c98"), RDF["object"], URIRef(u"source")),
+ (BNode("Nec6864ef180843838aa9805bac835c98"), RDF["object"], URIRef("source")),
(BNode("Nec6864ef180843838aa9805bac835c98"), RDF["predicate"], BNode("vcb4")),
- (BNode("Nec6864ef180843838aa9805bac835c98"), RDF["subject"], URIRef(u"source")),
+ (BNode("Nec6864ef180843838aa9805bac835c98"), RDF["subject"], URIRef("source")),
(BNode("Nec6864ef180843838aa9805bac835c98"), RDF["type"], RDF["Statement"]),
]
@@ -314,103 +314,103 @@ def test_issue725_collapsing_bnodes_2():
g += [
(
BNode("N0a76d42406b84fe4b8029d0a7fa04244"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
BNode("v2"),
),
(
BNode("N0a76d42406b84fe4b8029d0a7fa04244"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
BNode("v0"),
),
(
BNode("N0a76d42406b84fe4b8029d0a7fa04244"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
- URIRef(u"urn:gp_learner:fixed_var:target"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
+ URIRef("urn:gp_learner:fixed_var:target"),
),
(
BNode("N0a76d42406b84fe4b8029d0a7fa04244"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
),
(
BNode("N2f62af5936b94a8eb4b1e4bfa8e11d95"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
BNode("v1"),
),
(
BNode("N2f62af5936b94a8eb4b1e4bfa8e11d95"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
BNode("v0"),
),
(
BNode("N2f62af5936b94a8eb4b1e4bfa8e11d95"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
- URIRef(u"urn:gp_learner:fixed_var:target"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
+ URIRef("urn:gp_learner:fixed_var:target"),
),
(
BNode("N2f62af5936b94a8eb4b1e4bfa8e11d95"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
),
(
BNode("N5ae541f93e1d4e5880450b1bdceb6404"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
BNode("v5"),
),
(
BNode("N5ae541f93e1d4e5880450b1bdceb6404"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
BNode("v4"),
),
(
BNode("N5ae541f93e1d4e5880450b1bdceb6404"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
- URIRef(u"urn:gp_learner:fixed_var:target"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
+ URIRef("urn:gp_learner:fixed_var:target"),
),
(
BNode("N5ae541f93e1d4e5880450b1bdceb6404"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
),
(
BNode("N86ac7ca781f546ae939b8963895f672e"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
- URIRef(u"urn:gp_learner:fixed_var:source"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
+ URIRef("urn:gp_learner:fixed_var:source"),
),
(
BNode("N86ac7ca781f546ae939b8963895f672e"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
BNode("v0"),
),
(
BNode("N86ac7ca781f546ae939b8963895f672e"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
- URIRef(u"urn:gp_learner:fixed_var:target"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
+ URIRef("urn:gp_learner:fixed_var:target"),
),
(
BNode("N86ac7ca781f546ae939b8963895f672e"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
),
(
BNode("Nac82b883ca3849b5ab6820b7ac15e490"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#object"),
BNode("v1"),
),
(
BNode("Nac82b883ca3849b5ab6820b7ac15e490"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"),
BNode("v3"),
),
(
BNode("Nac82b883ca3849b5ab6820b7ac15e490"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
- URIRef(u"urn:gp_learner:fixed_var:target"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
+ URIRef("urn:gp_learner:fixed_var:target"),
),
(
BNode("Nac82b883ca3849b5ab6820b7ac15e490"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
- URIRef(u"http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
+ URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"),
),
]
diff --git a/test/test_comparison.py b/test/test_comparison.py
index 8455598c..f6efa598 100644
--- a/test/test_comparison.py
+++ b/test/test_comparison.py
@@ -37,8 +37,8 @@ class IdentifierEquality(unittest.TestCase):
self.uriref = URIRef("http://example.org/")
self.bnode = BNode()
self.literal = Literal("http://example.org/")
- self.python_literal = u"http://example.org/"
- self.python_literal_2 = u"foo"
+ self.python_literal = "http://example.org/"
+ self.python_literal_2 = "foo"
def testA(self):
self.assertEqual(self.uriref == self.literal, False)
diff --git a/test/test_conjunctive_graph.py b/test/test_conjunctive_graph.py
index 41bf432f..ed775c4a 100644
--- a/test/test_conjunctive_graph.py
+++ b/test/test_conjunctive_graph.py
@@ -8,11 +8,11 @@ from rdflib.parser import StringInputSource
from os import path
-DATA = u"""
+DATA = """
<http://example.org/record/1> a <http://xmlns.com/foaf/0.1/Document> .
"""
-PUBLIC_ID = u"http://example.org/record/1"
+PUBLIC_ID = "http://example.org/record/1"
def test_bnode_publicid():
diff --git a/test/test_dataset.py b/test/test_dataset.py
index ea56ef49..734b58cd 100644
--- a/test/test_dataset.py
+++ b/test/test_dataset.py
@@ -46,17 +46,17 @@ class DatasetTestCase(unittest.TestCase):
if self.store != "SPARQLUpdateStore":
self.graph.open(self.tmppath, create=True)
- self.michel = URIRef(u"urn:michel")
- self.tarek = URIRef(u"urn:tarek")
- self.bob = URIRef(u"urn:bob")
- self.likes = URIRef(u"urn:likes")
- self.hates = URIRef(u"urn:hates")
- self.pizza = URIRef(u"urn:pizza")
- self.cheese = URIRef(u"urn:cheese")
+ self.michel = URIRef("urn:michel")
+ self.tarek = URIRef("urn:tarek")
+ self.bob = URIRef("urn:bob")
+ self.likes = URIRef("urn:likes")
+ self.hates = URIRef("urn:hates")
+ self.pizza = URIRef("urn:pizza")
+ self.cheese = URIRef("urn:cheese")
# Use regular URIs because SPARQL endpoints like Fuseki alter short names
- self.c1 = URIRef(u"urn:context-1")
- self.c2 = URIRef(u"urn:context-2")
+ self.c1 = URIRef("urn:context-1")
+ self.c2 = URIRef("urn:context-2")
# delete the graph for each test!
self.graph.remove((None, None, None))
diff --git a/test/test_dawg.py b/test/test_dawg.py
index 80289738..2b1884fc 100644
--- a/test/test_dawg.py
+++ b/test/test_dawg.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
import sys
# Needed to pass
diff --git a/test/test_diff.py b/test/test_diff.py
index 7e4db728..0fb8d265 100644
--- a/test/test_diff.py
+++ b/test/test_diff.py
@@ -13,7 +13,7 @@ class TestDiff(unittest.TestCase):
def testA(self):
"""with bnode"""
g = rdflib.Graph()
- g.add((rdflib.BNode(), rdflib.URIRef("urn:p"), rdflib.Literal(u"\xe9")))
+ g.add((rdflib.BNode(), rdflib.URIRef("urn:p"), rdflib.Literal("\xe9")))
diff = graph_diff(g, g)
@@ -21,7 +21,7 @@ class TestDiff(unittest.TestCase):
"""Curiously, this one passes, even before the fix in issue 151"""
g = rdflib.Graph()
- g.add((rdflib.URIRef("urn:a"), rdflib.URIRef("urn:p"), rdflib.Literal(u"\xe9")))
+ g.add((rdflib.URIRef("urn:a"), rdflib.URIRef("urn:p"), rdflib.Literal("\xe9")))
diff = graph_diff(g, g)
diff --git a/test/test_graph.py b/test/test_graph.py
index 6150beea..fba32e5d 100644
--- a/test/test_graph.py
+++ b/test/test_graph.py
@@ -27,13 +27,13 @@ class GraphTestCase(unittest.TestCase):
self.tmppath = mkdtemp()
self.graph.open(self.tmppath, create=True)
- self.michel = URIRef(u"michel")
- self.tarek = URIRef(u"tarek")
- self.bob = URIRef(u"bob")
- self.likes = URIRef(u"likes")
- self.hates = URIRef(u"hates")
- self.pizza = URIRef(u"pizza")
- self.cheese = URIRef(u"cheese")
+ self.michel = URIRef("michel")
+ self.tarek = URIRef("tarek")
+ self.bob = URIRef("bob")
+ self.likes = URIRef("likes")
+ self.hates = URIRef("hates")
+ self.pizza = URIRef("pizza")
+ self.cheese = URIRef("cheese")
def tearDown(self):
self.graph.close()
diff --git a/test/test_graph_context.py b/test/test_graph_context.py
index f6c6713e..52220d2c 100644
--- a/test/test_graph_context.py
+++ b/test/test_graph_context.py
@@ -24,16 +24,16 @@ class ContextTestCase(unittest.TestCase):
else:
self.tmppath = mkdtemp()
self.graph.open(self.tmppath, create=True)
- self.michel = URIRef(u"michel")
- self.tarek = URIRef(u"tarek")
- self.bob = URIRef(u"bob")
- self.likes = URIRef(u"likes")
- self.hates = URIRef(u"hates")
- self.pizza = URIRef(u"pizza")
- self.cheese = URIRef(u"cheese")
-
- self.c1 = URIRef(u"context-1")
- self.c2 = URIRef(u"context-2")
+ self.michel = URIRef("michel")
+ self.tarek = URIRef("tarek")
+ self.bob = URIRef("bob")
+ self.likes = URIRef("likes")
+ self.hates = URIRef("hates")
+ self.pizza = URIRef("pizza")
+ self.cheese = URIRef("cheese")
+
+ self.c1 = URIRef("context-1")
+ self.c2 = URIRef("context-2")
# delete the graph for each test!
self.graph.remove((None, None, None))
diff --git a/test/test_hex_binary.py b/test/test_hex_binary.py
index 5f46bda5..fc152126 100644
--- a/test/test_hex_binary.py
+++ b/test/test_hex_binary.py
@@ -19,29 +19,29 @@ class HexBinaryTestCase(unittest.TestCase):
l = Literal(hex_i, datatype=XSD.hexBinary)
bin_i = l.toPython()
- self.assertEquals(int(binascii.hexlify(bin_i), 16), i)
+ self.assertEqual(int(binascii.hexlify(bin_i), 16), i)
- self.assertEquals(str(l), hex_i)
- self.assertEquals(int(hex_i, 16), i)
- self.assertEquals(int(l, 16), i)
- self.assertEquals(int(str(l), 16), i)
+ self.assertEqual(str(l), hex_i)
+ self.assertEqual(int(hex_i, 16), i)
+ self.assertEqual(int(l, 16), i)
+ self.assertEqual(int(str(l), 16), i)
def test_unicode(self):
- str1 = u"Test utf-8 string éàë"
+ str1 = "Test utf-8 string éàë"
# u hexstring
hex_str1 = binascii.hexlify(str1.encode("utf-8")).decode()
l1 = Literal(hex_str1, datatype=XSD.hexBinary)
b_str1 = l1.toPython()
- self.assertEquals(b_str1.decode("utf-8"), str1)
- self.assertEquals(str(l1), hex_str1)
+ self.assertEqual(b_str1.decode("utf-8"), str1)
+ self.assertEqual(str(l1), hex_str1)
# b hexstring
hex_str1b = binascii.hexlify(str1.encode("utf-8"))
l1b = Literal(hex_str1b, datatype=XSD.hexBinary)
b_str1b = l1b.toPython()
- self.assertEquals(b_str1, b_str1b)
- self.assertEquals(b_str1b.decode("utf-8"), str1)
- self.assertEquals(str(l1b), hex_str1)
+ self.assertEqual(b_str1, b_str1b)
+ self.assertEqual(b_str1b.decode("utf-8"), str1)
+ self.assertEqual(str(l1b), hex_str1)
if __name__ == "__main__":
diff --git a/test/test_issue084.py b/test/test_issue084.py
index 23536550..831cbd1c 100644
--- a/test/test_issue084.py
+++ b/test/test_issue084.py
@@ -4,7 +4,7 @@ from io import BytesIO, StringIO
from rdflib import URIRef, Literal
from rdflib.graph import Graph
-rdf = u"""@prefix skos:
+rdf = """@prefix skos:
<http://www.w3.org/2004/02/skos/core#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <http://www.test.org/#> .
@@ -33,7 +33,7 @@ def test_a():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
def test_b():
@@ -44,7 +44,7 @@ def test_b():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
def test_c():
@@ -56,7 +56,7 @@ def test_c():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
def test_d():
@@ -67,7 +67,7 @@ def test_d():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
def test_e():
@@ -78,11 +78,11 @@ def test_e():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
# this is unicode
-rdfxml = u"""<?xml version="1.0" encoding="UTF-8"?>
+rdfxml = """<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
@@ -109,7 +109,7 @@ def test_xml_a():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
def test_xml_b():
@@ -120,7 +120,7 @@ def test_xml_b():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
# The following two cases are currently not supported by Graph.parse
@@ -147,4 +147,4 @@ def test_xml_e():
subject=URIRef("http://www.test.org/#CI"),
predicate=URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
)
- assert v == Literal(u"C\u00f4te d'Ivoire", lang="fr")
+ assert v == Literal("C\u00f4te d'Ivoire", lang="fr")
diff --git a/test/test_issue190.py b/test/test_issue190.py
index f8ab37e7..87a8db3e 100644
--- a/test/test_issue190.py
+++ b/test/test_issue190.py
@@ -20,7 +20,7 @@ prefix = textwrap.dedent(
)
meta = textwrap.dedent(
- u"""\
+ """\
a nfo:PaginatedTextDocument ;
nie:title "SV Meldung" ;
nco:creator [ a nco:Contact ;
@@ -36,7 +36,7 @@ a nfo:PaginatedTextDocument ;
"""
)
-test_string1 = u"""\
+test_string1 = """\
Betriebsnummer der Einzugsstelle:\nKnappschaft\n980 0000 6\nWICHTIGES DOKUMENT - SORGFÄLTIG AUFBEWAHREN!\n """
@@ -48,7 +48,7 @@ def test1():
)
-test_string2 = u"""\
+test_string2 = """\
Betriebsnummer der Einzugsstelle:
Knappschaft
980 0000 6
diff --git a/test/test_issue446.py b/test/test_issue446.py
index 98c46578..6fd21347 100644
--- a/test/test_issue446.py
+++ b/test/test_issue446.py
@@ -9,7 +9,7 @@ def test_sparql_unicode():
trip = (
URIRef("http://example.org/foo"),
URIRef("http://example.org/bar"),
- URIRef(u"http://example.org/jörn"),
+ URIRef("http://example.org/jörn"),
)
g.add(trip)
q = 'select ?s ?p ?o where { ?s ?p ?o . FILTER(lang(?o) = "") }'
diff --git a/test/test_issue604.py b/test/test_issue604.py
index 7a827241..cc48afea 100644
--- a/test/test_issue604.py
+++ b/test/test_issue604.py
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
from rdflib import *
from rdflib.collection import Collection
diff --git a/test/test_issue923.py b/test/test_issue923.py
index 48f2e4de..0d9d709f 100644
--- a/test/test_issue923.py
+++ b/test/test_issue923.py
@@ -5,7 +5,7 @@ from io import StringIO
from rdflib.query import Result
-RESULT_SOURCE = u"""\
+RESULT_SOURCE = """\
{
"head" : {
"vars" : [ "subject", "predicate", "object", "context" ]
diff --git a/test/test_literal.py b/test/test_literal.py
index bc6919b7..656bfb10 100644
--- a/test/test_literal.py
+++ b/test/test_literal.py
@@ -92,8 +92,8 @@ class TestRepr(unittest.TestCase):
class MyLiteral(Literal):
pass
- x = MyLiteral(u"foo")
- self.assertEqual(repr(x), uformat("MyLiteral(u'foo')"))
+ x = MyLiteral("foo")
+ self.assertEqual(repr(x), uformat("MyLiteral('foo')"))
class TestDoubleOutput(unittest.TestCase):
diff --git a/test/test_n3.py b/test/test_n3.py
index 9a378843..7cd394cd 100644
--- a/test/test_n3.py
+++ b/test/test_n3.py
@@ -132,13 +132,13 @@ class TestN3Case(unittest.TestCase):
self.assertEqual(list(g), list(g2))
def testIssue23(self):
- input = """<http://example.com/article1> <http://example.com/title> "this word is in \u201Cquotes\u201D"."""
+ input = """<http://example.com/article1> <http://example.com/title> "this word is in \\u201Cquotes\\u201D"."""
g = Graph()
g.parse(data=input, format="n3")
# Note difference in case of hex code, cwm allows lower-case
- input = """<http://example.com/article1> <http://example.com/title> "this word is in \u201cquotes\u201d"."""
+ input = """<http://example.com/article1> <http://example.com/title> "this word is in \\u201cquotes\\u201d"."""
g.parse(data=input, format="n3")
diff --git a/test/test_nodepickler.py b/test/test_nodepickler.py
index 970ec232..5312931a 100644
--- a/test/test_nodepickler.py
+++ b/test/test_nodepickler.py
@@ -28,7 +28,7 @@ class UtilTestCase(unittest.TestCase):
np = NodePickler()
a = Literal(
- u"""A test with a \\n (backslash n), "\u00a9" , and newline \n and a second line.
+ """A test with a \\n (backslash n), "\u00a9" , and newline \n and a second line.
"""
)
b = np.loads(np.dumps(a))
diff --git a/test/test_nquads.py b/test/test_nquads.py
index da9e8e2d..f99984dd 100644
--- a/test/test_nquads.py
+++ b/test/test_nquads.py
@@ -45,9 +45,9 @@ class NQuadsParserTest(unittest.TestCase):
uri1 = URIRef("http://example.org/mygraph1")
uri2 = URIRef("http://example.org/mygraph2")
- bob = URIRef(u"urn:bob")
- likes = URIRef(u"urn:likes")
- pizza = URIRef(u"urn:pizza")
+ bob = URIRef("urn:bob")
+ likes = URIRef("urn:likes")
+ pizza = URIRef("urn:pizza")
g.get_context(uri1).add((bob, likes, pizza))
g.get_context(uri2).add((bob, likes, pizza))
diff --git a/test/test_nt_misc.py b/test/test_nt_misc.py
index 2d25e742..399f7bff 100644
--- a/test/test_nt_misc.py
+++ b/test/test_nt_misc.py
@@ -23,7 +23,7 @@ class NTTestCase(unittest.TestCase):
def testIssue78(self):
g = Graph()
- g.add((URIRef("foo"), URIRef("foo"), Literal(u"R\u00E4ksm\u00F6rg\u00E5s")))
+ g.add((URIRef("foo"), URIRef("foo"), Literal("R\u00E4ksm\u00F6rg\u00E5s")))
s = g.serialize(format="nt")
self.assertEqual(type(s), bytes)
self.assertTrue(r"R\u00E4ksm\u00F6rg\u00E5s".encode("latin-1") in s)
diff --git a/test/test_path_div_future.py b/test/test_path_div_future.py
index 82dadc29..20886e0d 100644
--- a/test/test_path_div_future.py
+++ b/test/test_path_div_future.py
@@ -1,4 +1,3 @@
-from __future__ import division
from rdflib import URIRef
from rdflib.paths import Path
diff --git a/test/test_preflabel.py b/test/test_preflabel.py
index b35c626c..77ecbcd3 100644
--- a/test/test_preflabel.py
+++ b/test/test_preflabel.py
@@ -19,11 +19,11 @@ class TestPrefLabel(unittest.TestCase):
tgt = [
(
rdflib.term.URIRef("http://www.w3.org/2000/01/rdf-schema#label"),
- rdflib.term.Literal(u"bar"),
+ rdflib.term.Literal("bar"),
),
(
rdflib.term.URIRef("http://www.w3.org/2000/01/rdf-schema#label"),
- rdflib.term.Literal(u"foo"),
+ rdflib.term.Literal("foo"),
),
]
self.assertEqual(res, tgt)
@@ -34,7 +34,7 @@ class TestPrefLabel(unittest.TestCase):
tgt = [
(
rdflib.term.URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
- rdflib.term.Literal(u"bla"),
+ rdflib.term.Literal("bla"),
)
]
self.assertEqual(res, tgt)
@@ -46,11 +46,11 @@ class TestPrefLabel(unittest.TestCase):
tgt = [
(
rdflib.term.URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
- rdflib.term.Literal(u"bla"),
+ rdflib.term.Literal("bla"),
),
(
rdflib.term.URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
- rdflib.term.Literal(u"blubb", lang="en"),
+ rdflib.term.Literal("blubb", lang="en"),
),
]
@@ -63,7 +63,7 @@ class TestPrefLabel(unittest.TestCase):
tgt = [
(
rdflib.term.URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
- rdflib.term.Literal(u"bla"),
+ rdflib.term.Literal("bla"),
)
]
self.assertEqual(res, tgt)
@@ -74,7 +74,7 @@ class TestPrefLabel(unittest.TestCase):
tgt = [
(
rdflib.term.URIRef("http://www.w3.org/2004/02/skos/core#prefLabel"),
- rdflib.term.Literal(u"blubb", lang="en"),
+ rdflib.term.Literal("blubb", lang="en"),
)
]
self.assertEqual(res, tgt)
diff --git a/test/test_prettyxml.py b/test/test_prettyxml.py
index 4a033fa4..4151c354 100644
--- a/test/test_prettyxml.py
+++ b/test/test_prettyxml.py
@@ -179,7 +179,7 @@ class TestPrettyXmlSerializer(SerializerTestBase):
BNode(),
RDF.value,
Literal(
- u"""<p xmlns="http://www.w3.org/1999/xhtml">See also <a href="#aring">Å</a></p>""",
+ """<p xmlns="http://www.w3.org/1999/xhtml">See also <a href="#aring">Å</a></p>""",
datatype=RDF.XMLLiteral,
),
)
@@ -188,7 +188,7 @@ class TestPrettyXmlSerializer(SerializerTestBase):
xmlrepr = g.serialize(format="pretty-xml")
# then:
assert (
- u"""<rdf:value rdf:parseType="Literal"><p xmlns="http://www.w3.org/1999/xhtml">See also <a href="#aring">Å</a></p></rdf:value>""".encode(
+ """<rdf:value rdf:parseType="Literal"><p xmlns="http://www.w3.org/1999/xhtml">See also <a href="#aring">Å</a></p></rdf:value>""".encode(
"utf-8"
)
in xmlrepr
@@ -197,12 +197,12 @@ class TestPrettyXmlSerializer(SerializerTestBase):
def test_pretty_broken_xmlliteral(self):
# given:
g = ConjunctiveGraph()
- g.add((BNode(), RDF.value, Literal(u"""<p """, datatype=RDF.XMLLiteral)))
+ g.add((BNode(), RDF.value, Literal("""<p """, datatype=RDF.XMLLiteral)))
# when:
xmlrepr = g.serialize(format="pretty-xml")
# then:
assert (
- u"""<rdf:value rdf:datatype="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral">&lt;p """.encode(
+ """<rdf:value rdf:datatype="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral">&lt;p """.encode(
"utf-8"
)
in xmlrepr
diff --git a/test/test_rdfxml.py b/test/test_rdfxml.py
index 845a9a7d..eef09219 100644
--- a/test/test_rdfxml.py
+++ b/test/test_rdfxml.py
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
import sys
from encodings.utf_8 import StreamWriter
@@ -97,7 +95,7 @@ def resolve(rel):
def _testPositive(uri, manifest):
if verbose:
- write(u"TESTING: %s" % uri)
+ write("TESTING: %s" % uri)
result = 0 # 1=failed, 0=passed
inDoc = first(manifest.objects(uri, TEST["inputDocument"]))
outDoc = first(manifest.objects(uri, TEST["outputDocument"]))
@@ -127,7 +125,7 @@ def _testPositive(uri, manifest):
result = 1
else:
if not store.isomorphic(expected):
- write(u"""Failed: '%s'""" % uri)
+ write("""Failed: '%s'""" % uri)
if verbose:
write(""" In:\n""")
for s, p, o in store:
@@ -141,7 +139,7 @@ def _testPositive(uri, manifest):
def _testNegative(uri, manifest):
if verbose:
- write(u"TESTING: %s" % uri)
+ write("TESTING: %s" % uri)
result = 0 # 1=failed, 0=passed
inDoc = first(manifest.objects(uri, TEST["inputDocument"]))
store = Graph()
@@ -160,7 +158,7 @@ def _testNegative(uri, manifest):
results.add((test, RDF.type, RESULT["PassingRun"]))
# pass
else:
- write(u"""Failed: '%s'""" % uri)
+ write("""Failed: '%s'""" % uri)
results.add((test, RDF.type, RESULT["FailingRun"]))
result = 1
return result
@@ -254,15 +252,15 @@ if __name__ == "__main__":
for arg in argv[1:]:
verbose = 1
case = URIRef(arg)
- write(u"Testing: %s" % case)
+ write("Testing: %s" % case)
if (case, RDF.type, TEST["PositiveParserTest"]) in manifest:
result = _testPositive(case, manifest)
- write(u"Positive test %s" % ["PASSED", "FAILED"][result])
+ write("Positive test %s" % ["PASSED", "FAILED"][result])
elif (case, RDF.type, TEST["NegativeParserTest"]) in manifest:
result = _testNegative(case, manifest)
- write(u"Negative test %s" % ["PASSED", "FAILED"][result])
+ write("Negative test %s" % ["PASSED", "FAILED"][result])
else:
- write(u"%s not ??" % case)
+ write("%s not ??" % case)
if len(argv) <= 1:
unittest.main()
diff --git a/test/test_slice.py b/test/test_slice.py
index 36c72ca8..887791ed 100644
--- a/test/test_slice.py
+++ b/test/test_slice.py
@@ -49,13 +49,13 @@ class GraphSlice(unittest.TestCase):
def setUp(self):
self.graph = Graph()
- self.michel = URIRef(u"michel")
- self.tarek = URIRef(u"tarek")
- self.bob = URIRef(u"bob")
- self.likes = URIRef(u"likes")
- self.hates = URIRef(u"hates")
- self.pizza = URIRef(u"pizza")
- self.cheese = URIRef(u"cheese")
+ self.michel = URIRef("michel")
+ self.tarek = URIRef("tarek")
+ self.bob = URIRef("bob")
+ self.likes = URIRef("likes")
+ self.hates = URIRef("hates")
+ self.pizza = URIRef("pizza")
+ self.cheese = URIRef("cheese")
self.addStuff()
diff --git a/test/test_sparqlupdatestore.py b/test/test_sparqlupdatestore.py
index b6dcedbd..ca137beb 100644
--- a/test/test_sparqlupdatestore.py
+++ b/test/test_sparqlupdatestore.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from nose import SkipTest
import unittest
diff --git a/test/test_term.py b/test/test_term.py
index 0363baba..e154bd4e 100644
--- a/test/test_term.py
+++ b/test/test_term.py
@@ -224,7 +224,7 @@ class TestLiteral(unittest.TestCase):
(
45,
Literal(Decimal(1.0), datatype=XSD.integer),
- Literal(u"1", datatype=XSD.string),
+ Literal("1", datatype=XSD.string),
Literal("11", datatype=XSD.string),
),
(
diff --git a/test/test_trig.py b/test/test_trig.py
index 90321c5c..d61667fc 100644
--- a/test/test_trig.py
+++ b/test/test_trig.py
@@ -31,7 +31,7 @@ class TestTrig(unittest.TestCase):
self.assertEqual(len(g.get_context("urn:b")), 1)
s = g.serialize(format="trig")
- self.assertTrue("{}".encode("latin-1") not in s) # no empty graphs!
+ self.assertTrue(b"{}" not in s) # no empty graphs!
def testSameSubject(self):
g = rdflib.ConjunctiveGraph()
@@ -48,10 +48,10 @@ class TestTrig(unittest.TestCase):
s = g.serialize(format="trig")
- self.assertEqual(len(re.findall("p1".encode("latin-1"), s)), 1)
- self.assertEqual(len(re.findall("p2".encode("latin-1"), s)), 1)
+ self.assertEqual(len(re.findall(b"p1", s)), 1)
+ self.assertEqual(len(re.findall(b"p2", s)), 1)
- self.assertTrue("{}".encode("latin-1") not in s) # no empty graphs!
+ self.assertTrue(b"{}" not in s) # no empty graphs!
def testRememberNamespace(self):
g = rdflib.ConjunctiveGraph()
@@ -155,7 +155,7 @@ class TestTrig(unittest.TestCase):
g.parse(data=data, format="trig")
data = g.serialize(format="trig")
- self.assertTrue("None".encode("latin-1") not in data)
+ self.assertTrue(b"None" not in data)
def testPrefixes(self):
@@ -175,6 +175,6 @@ class TestTrig(unittest.TestCase):
cg.parse(data=data, format="trig")
data = cg.serialize(format="trig")
- self.assert_("ns2: <http://ex.org/docs/".encode("latin-1") in data, data)
- self.assert_("<ns2:document1>".encode("latin-1") not in data, data)
- self.assert_("ns2:document1".encode("latin-1") in data, data)
+ self.assertTrue(b"ns2: <http://ex.org/docs/" in data)
+ self.assertTrue(b"<ns2:document1>" not in data)
+ self.assertTrue(b"ns2:document1" in data)
diff --git a/test/test_turtle_serialize.py b/test/test_turtle_serialize.py
index 155cdffd..48c86442 100644
--- a/test/test_turtle_serialize.py
+++ b/test/test_turtle_serialize.py
@@ -41,7 +41,7 @@ def testTurtleBoolList():
def testUnicodeEscaping():
- turtle_string = " <http://example.com/A> <http://example.com/B> <http://example.com/aaa\u00F3bbbb> . <http://example.com/A> <http://example.com/C> <http://example.com/zzz\U00100000zzz> . <http://example.com/A> <http://example.com/D> <http://example.com/aaa\u00f3bbb> ."
+ turtle_string = " <http://example.com/A> <http://example.com/B> <http://example.com/aaa\\u00F3bbbb> . <http://example.com/A> <http://example.com/C> <http://example.com/zzz\\U00100000zzz> . <http://example.com/A> <http://example.com/D> <http://example.com/aaa\\u00f3bbb> ."
g = Graph()
# shouldn't get an exception
@@ -50,9 +50,9 @@ def testUnicodeEscaping():
assert len(triples) == 3
print(triples)
# Now check that was decoded into python values properly
- assert triples[0][2] == URIRef(u"http://example.com/aaa\xf3bbbb")
- assert triples[1][2] == URIRef(u"http://example.com/zzz\U00100000zzz")
- assert triples[2][2] == URIRef(u"http://example.com/aaa\xf3bbb")
+ assert triples[0][2] == URIRef("http://example.com/aaa\xf3bbbb")
+ assert triples[1][2] == URIRef("http://example.com/zzz\U00100000zzz")
+ assert triples[2][2] == URIRef("http://example.com/aaa\xf3bbb")
def test_turtle_valid_list():
diff --git a/test/test_util.py b/test/test_util.py
index d8f0a5d1..ea3b122e 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -243,17 +243,17 @@ class TestUtilTermConvert(unittest.TestCase):
def test_util_from_n3_expectpartialidempotencewithn3(self):
for n3 in (
- "<http://ex.com/foo>",
+ '<http://ex.com/foo>',
'"foo"@de',
- u"<http://ex.com/漢字>",
- u"<http://ex.com/a#あ>",
+ '<http://ex.com/漢字>',
+ '<http://ex.com/a#あ>',
# '"\\""', # exception as '\\"' --> '"' by orig parser as well
'"""multi\n"line"\nstring"""@en',
):
self.assertEqual(
- util.from_n3(n3).n3(),
+ util.from_n3(n3).n3(),
n3,
- "from_n3(%(n3e)r).n3() != %(n3e)r" % {"n3e": n3},
+ 'from_n3(%(n3e)r).n3() != %(n3e)r' % {'n3e': n3},
)
def test_util_from_n3_expectsameasn3parser(self):
diff --git a/test/test_wide_python.py b/test/test_wide_python.py
index 5463e798..f4eeab32 100644
--- a/test/test_wide_python.py
+++ b/test/test_wide_python.py
@@ -3,11 +3,11 @@ def test_wide_python_build():
See https://github.com/RDFLib/rdflib/issues/456 for more information.
"""
- assert len(u"\U0010FFFF") == 1, (
- "You are using a narrow Python build!\n"
- "This means that your Python does not properly support chars > 16bit.\n"
+ assert len('\U0010FFFF') == 1, (
+ 'You are using a narrow Python build!\n'
+ 'This means that your Python does not properly support chars > 16bit.\n'
'On your system chars like c=u"\\U0010FFFF" will have a len(c)==2.\n'
- "As this can cause hard to debug problems with string processing\n"
- "(slicing, regexp, ...) later on, we strongly advise to use a wide\n"
- "Python build in production systems."
+ 'As this can cause hard to debug problems with string processing\n'
+ '(slicing, regexp, ...) later on, we strongly advise to use a wide\n'
+ 'Python build in production systems.'
)
diff --git a/test/testutils.py b/test/testutils.py
index 03366cfb..5fd46d4d 100644
--- a/test/testutils.py
+++ b/test/testutils.py
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
import sys
import isodate
import datetime