Skip to content

trim "six" usage #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions rdflib_sqlalchemy/sql.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from rdflib.namespace import RDF
from six import text_type
from sqlalchemy.sql import expression, functions

from rdflib_sqlalchemy.constants import (
Expand Down Expand Up @@ -74,7 +73,7 @@ def union_select(select_components, distinct=False, select_type=TRIPLE_SELECT):
select_clause = expression.select(
*[table.c.id.label("id"),
table.c.member.label("subject"),
expression.literal(text_type(RDF.type)).label("predicate"),
expression.literal(str(RDF.type)).label("predicate"),
table.c.klass.label("object"),
table.c.context.label("context"),
table.c.termComb.label("termcomb"),
Expand Down
9 changes: 4 additions & 5 deletions rdflib_sqlalchemy/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from rdflib.namespace import RDF
from rdflib.plugins.stores.regexmatching import PYTHON_REGEX, REGEXTerm
from rdflib.store import CORRUPTED_STORE, VALID_STORE, NodePickler, Store
from six import text_type
from sqlalchemy import MetaData, inspect
from sqlalchemy.sql import expression, select, delete
from sqlalchemy.exc import OperationalError
Expand Down Expand Up @@ -639,8 +638,8 @@ def bind(self, prefix, namespace):
with self.engine.begin() as connection:
try:
binds_table = self.tables["namespace_binds"]
prefix = text_type(prefix)
namespace = text_type(namespace)
prefix = str(prefix)
namespace = str(namespace)
connection.execute(delete(binds_table).where(
expression.or_(binds_table.c.uri == namespace,
binds_table.c.prefix == prefix)))
Expand All @@ -653,7 +652,7 @@ def prefix(self, namespace):
"""Prefix."""
with self.engine.begin() as connection:
nb_table = self.tables["namespace_binds"]
namespace = text_type(namespace)
namespace = str(namespace)
s = select(nb_table.c.prefix).where(nb_table.c.uri == namespace)
res = connection.execute(s)
rt = [rtTuple[0] for rtTuple in res.fetchall()]
Expand All @@ -664,7 +663,7 @@ def prefix(self, namespace):

def namespace(self, prefix):
res = None
prefix_val = text_type(prefix)
prefix_val = str(prefix)
try:
with self.engine.begin() as connection:
nb_table = self.tables["namespace_binds"]
Expand Down
5 changes: 2 additions & 3 deletions rdflib_sqlalchemy/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from rdflib.graph import Graph, QuotedGraph
from rdflib.term import Node
from six import text_type
from sqlalchemy import types


Expand All @@ -13,8 +12,8 @@ class TermType(types.TypeDecorator):
def process_bind_param(self, value, dialect):
"""Process bound parameters."""
if isinstance(value, (QuotedGraph, Graph)):
return text_type(value.identifier)
return str(value.identifier)
elif isinstance(value, Node):
return text_type(value)
return str(value)
else:
return value
3 changes: 1 addition & 2 deletions test/context_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from rdflib import URIRef
from rdflib import plugin
from rdflib.store import Store
from six import string_types


class ContextTestCase(unittest.TestCase):
Expand Down Expand Up @@ -164,7 +163,7 @@ def testContexts(self):
self.addStuffInMultipleContexts()

def cid(c):
if not isinstance(c, string_types):
if not isinstance(c, str):
return c.identifier
return c
self.assertIn(self.c1, list(map(cid, self.graph.contexts())))
Expand Down
5 changes: 2 additions & 3 deletions test/graph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from rdflib import Graph, URIRef, Literal, plugin, RDF
from rdflib.parser import StringInputSource
from six import PY3
from rdflib.store import Store


Expand Down Expand Up @@ -273,7 +272,7 @@ def testStoreLiteralsXml(self):
Literal(u"こんにちは", lang="ja"),
Literal(u"les garçons à Noël reçoivent des œufs", lang="fr")]

testdoc = (PY3 and bytes(xmltestdocXml, "UTF-8")) or xmltestdocXml
testdoc = bytes(xmltestdocXml, "UTF-8")

self.graph.parse(StringInputSource(testdoc), format="xml")

Expand All @@ -289,7 +288,7 @@ def testStoreLiteralsXmlQuote(self):
says = URIRef(u"http://www.rdflib.net/terms/says")
imtheone = Literal(u"I'm the one", lang="en")

testdoc = (PY3 and bytes(xmltestdocXmlQuote, "UTF-8")) or xmltestdocXmlQuote
testdoc = bytes(xmltestdocXmlQuote, "UTF-8")

self.graph.parse(StringInputSource(testdoc), format="xml")

Expand Down
2 changes: 1 addition & 1 deletion test/test_aggregate_graphs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from io import StringIO

from rdflib import Literal
from rdflib import RDF
Expand All @@ -10,7 +11,6 @@
from rdflib.graph import Graph
from rdflib.graph import ReadOnlyGraphAggregate
from rdflib.store import Store
from six.moves import cStringIO as StringIO


plugin.register(
Expand Down
3 changes: 1 addition & 2 deletions test/test_store_performance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
import unittest
import gc
import os
Expand All @@ -7,7 +6,7 @@
from tempfile import mkdtemp

from rdflib import Graph
from six.moves.urllib.request import pathname2url
from urllib.request import pathname2url

try:
from rdflib.plugins.stores.memory import Memory
Expand Down