Remove use of six because its 2020
This commit is contained in:
parent
ce28a0d4e8
commit
45ae60349c
@ -1,8 +1,6 @@
|
||||
import logging
|
||||
import threading
|
||||
|
||||
import six
|
||||
from six.moves.urllib.parse import parse_qs, urlparse
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.sql import text
|
||||
@ -182,7 +180,7 @@ class Database(object):
|
||||
table5 = db.create_table('population5',
|
||||
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.'
|
||||
table_name = normalize_table_name(table_name)
|
||||
with self.lock:
|
||||
@ -253,7 +251,7 @@ class Database(object):
|
||||
|
||||
The returned iterator will yield each result sequentially.
|
||||
"""
|
||||
if isinstance(query, six.string_types):
|
||||
if isinstance(query, str):
|
||||
query = text(query)
|
||||
_step = kwargs.pop('_step', QUERY_STEP)
|
||||
rp = self.executable.execute(query, *args, **kwargs)
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import six
|
||||
from hashlib import sha1
|
||||
try:
|
||||
from collections.abc import Iterable
|
||||
except ImportError:
|
||||
from collections import Iterable
|
||||
from urllib.parse import urlparse
|
||||
from collections import OrderedDict
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from collections.abc import Iterable
|
||||
|
||||
QUERY_STEP = 1000
|
||||
row_type = OrderedDict
|
||||
@ -58,13 +54,13 @@ class ResultIter(object):
|
||||
|
||||
def normalize_column_name(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)
|
||||
|
||||
# limit to 63 characters
|
||||
name = name.strip()[:63]
|
||||
# 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:
|
||||
name = name[:len(name) - 1]
|
||||
|
||||
@ -75,7 +71,7 @@ def normalize_column_name(name):
|
||||
|
||||
def normalize_table_name(name):
|
||||
"""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)
|
||||
name = name.strip()[:63]
|
||||
if not len(name):
|
||||
@ -103,7 +99,7 @@ def ensure_tuple(obj):
|
||||
"""Try and make the given argument into a tuple."""
|
||||
if obj is None:
|
||||
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 obj,
|
||||
|
||||
|
||||
5
setup.py
5
setup.py
@ -17,7 +17,7 @@ setup(
|
||||
],
|
||||
keywords='sql sqlalchemy etl loading utility',
|
||||
author='Friedrich Lindenberg, Gregor Aisch, Stefan Wehrmeyer',
|
||||
author_email='friedrich@pudo.org',
|
||||
author_email='friedrich.lindenberg@gmail.com',
|
||||
url='http://github.com/pudo/dataset',
|
||||
license='MIT',
|
||||
packages=find_packages(exclude=['ez_setup', 'examples', 'test']),
|
||||
@ -26,8 +26,7 @@ setup(
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
'sqlalchemy >= 1.1.2',
|
||||
'alembic >= 0.6.2',
|
||||
'six >= 1.11.0'
|
||||
'alembic >= 0.6.2'
|
||||
],
|
||||
tests_require=[
|
||||
'nose'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user