Remove use of six because its 2020

This commit is contained in:
Friedrich Lindenberg 2020-01-11 14:06:57 +01:00
parent ce28a0d4e8
commit 45ae60349c
3 changed files with 11 additions and 18 deletions

View File

@ -1,8 +1,6 @@
import logging import logging
import threading import threading
from urllib.parse import parse_qs, urlparse
import six
from six.moves.urllib.parse import parse_qs, urlparse
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.sql import text from sqlalchemy.sql import text
@ -182,7 +180,7 @@ class Database(object):
table5 = db.create_table('population5', table5 = db.create_table('population5',
primary_id=False) primary_id=False)
""" """
assert not isinstance(primary_type, six.string_types), \ assert not isinstance(primary_type, str), \
'Text-based primary_type support is dropped, use db.types.' 'Text-based primary_type support is dropped, use db.types.'
table_name = normalize_table_name(table_name) table_name = normalize_table_name(table_name)
with self.lock: with self.lock:
@ -253,7 +251,7 @@ class Database(object):
The returned iterator will yield each result sequentially. The returned iterator will yield each result sequentially.
""" """
if isinstance(query, six.string_types): if isinstance(query, str):
query = text(query) query = text(query)
_step = kwargs.pop('_step', QUERY_STEP) _step = kwargs.pop('_step', QUERY_STEP)
rp = self.executable.execute(query, *args, **kwargs) rp = self.executable.execute(query, *args, **kwargs)

View File

@ -1,11 +1,7 @@
import six
from hashlib import sha1 from hashlib import sha1
try: from urllib.parse import urlparse
from collections.abc import Iterable
except ImportError:
from collections import Iterable
from collections import OrderedDict from collections import OrderedDict
from six.moves.urllib.parse import urlparse from collections.abc import Iterable
QUERY_STEP = 1000 QUERY_STEP = 1000
row_type = OrderedDict row_type = OrderedDict
@ -58,13 +54,13 @@ class ResultIter(object):
def normalize_column_name(name): def normalize_column_name(name):
"""Check if a string is a reasonable thing to use as a column name.""" """Check if a string is a reasonable thing to use as a column name."""
if not isinstance(name, six.string_types): if not isinstance(name, str):
raise ValueError('%r is not a valid column name.' % name) raise ValueError('%r is not a valid column name.' % name)
# limit to 63 characters # limit to 63 characters
name = name.strip()[:63] name = name.strip()[:63]
# column names can be 63 *bytes* max in postgresql # column names can be 63 *bytes* max in postgresql
if isinstance(name, six.text_type): if isinstance(name, str):
while len(name.encode('utf-8')) >= 64: while len(name.encode('utf-8')) >= 64:
name = name[:len(name) - 1] name = name[:len(name) - 1]
@ -75,7 +71,7 @@ def normalize_column_name(name):
def normalize_table_name(name): def normalize_table_name(name):
"""Check if the table name is obviously invalid.""" """Check if the table name is obviously invalid."""
if not isinstance(name, six.string_types): if not isinstance(name, str):
raise ValueError("Invalid table name: %r" % name) raise ValueError("Invalid table name: %r" % name)
name = name.strip()[:63] name = name.strip()[:63]
if not len(name): if not len(name):
@ -103,7 +99,7 @@ def ensure_tuple(obj):
"""Try and make the given argument into a tuple.""" """Try and make the given argument into a tuple."""
if obj is None: if obj is None:
return tuple() return tuple()
if isinstance(obj, Iterable) and not isinstance(obj, six.string_types): if isinstance(obj, Iterable) and not isinstance(obj, (str, bytes)):
return tuple(obj) return tuple(obj)
return obj, return obj,

View File

@ -17,7 +17,7 @@ setup(
], ],
keywords='sql sqlalchemy etl loading utility', keywords='sql sqlalchemy etl loading utility',
author='Friedrich Lindenberg, Gregor Aisch, Stefan Wehrmeyer', author='Friedrich Lindenberg, Gregor Aisch, Stefan Wehrmeyer',
author_email='friedrich@pudo.org', author_email='friedrich.lindenberg@gmail.com',
url='http://github.com/pudo/dataset', url='http://github.com/pudo/dataset',
license='MIT', license='MIT',
packages=find_packages(exclude=['ez_setup', 'examples', 'test']), packages=find_packages(exclude=['ez_setup', 'examples', 'test']),
@ -26,8 +26,7 @@ setup(
zip_safe=False, zip_safe=False,
install_requires=[ install_requires=[
'sqlalchemy >= 1.1.2', 'sqlalchemy >= 1.1.2',
'alembic >= 0.6.2', 'alembic >= 0.6.2'
'six >= 1.11.0'
], ],
tests_require=[ tests_require=[
'nose' 'nose'