Skip to content

Commit 2647d3e

Browse files
ElyungeXopherus
authored andcommitted
Add compatibility for python 3
This is done via the future package, which is added to the setup requirements.
1 parent 8c6c0c4 commit 2647d3e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

redis_url.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
try:
2-
import urlparse
3-
except ImportError:
4-
import urllib.parse as urlparse
1+
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
4+
from __future__ import unicode_literals
5+
from builtins import int
6+
from future import standard_library
7+
standard_library.install_aliases()
8+
9+
import urllib.parse
510

611
def parse(url):
712
"""Parses a Redis URL."""
813

9-
url = urlparse.urlparse(url)
14+
url = urllib.parse.urlparse(url)
1015

1116
config = {
1217
'host': url.hostname or 'localhost',
@@ -15,15 +20,15 @@ def parse(url):
1520
}
1621

1722
# parse options from url
18-
options = urlparse.parse_qs(url.query)
23+
options = urllib.parse.parse_qs(url.query)
1924

2025
# if cluster mode is enabled, do not add db to config (unsupported)
2126
cluster_enabled = options.pop('cluster', ['false'])[0]
2227

2328
if cluster_enabled == 'false':
2429
config['db'] = int(url.path[1:] or 0)
2530

26-
for key, val in options.iteritems():
31+
for key, val in options.items():
2732
config[key] = val[0] if len(val) == 1 else val
2833

2934
if key == 'skip_full_coverage_check':

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
setup(
1111
name='redis-url-py',
12-
version='0.0.3',
12+
version='0.0.4',
1313
url='https://github.com/Xopherus/redis-url-py',
1414
license=LICENSE,
1515
author='Chris Raborg',
1616
author_email='craborg1@umbc.edu',
1717
description='Use Redis URLs in your Python applications',
1818
long_description=DESCRIPTION,
1919
py_modules=['redis_url'],
20+
install_requires = ["future"],
2021
zip_safe=False,
2122
)

0 commit comments

Comments
 (0)