diff --git a/embedly/client.py b/embedly/client.py index cfda2df..d8cd099 100644 --- a/embedly/client.py +++ b/embedly/client.py @@ -8,7 +8,7 @@ import re import httplib2 import json -from urllib import quote, urlencode +from urllib.parse import quote, urlencode from .models import Url diff --git a/embedly/models.py b/embedly/models.py index f97591c..d9e488c 100644 --- a/embedly/models.py +++ b/embedly/models.py @@ -1,9 +1,8 @@ from __future__ import absolute_import, unicode_literals -from .py3_utils import python_2_unicode_compatible, IterableUserDict +from collections import UserDict -@python_2_unicode_compatible -class Url(IterableUserDict, object): +class Url(UserDict, object): """ A dictionary with two additional attributes for the method and url. UserDict provides a dictionary interface along with the regular diff --git a/embedly/py3_utils.py b/embedly/py3_utils.py deleted file mode 100644 index 089ce8e..0000000 --- a/embedly/py3_utils.py +++ /dev/null @@ -1,28 +0,0 @@ -import sys - -# 2to3 doesn't handle the UserDict relocation -# put the import logic here for cleaner usage -try: - from collections import UserDict as IterableUserDict -except ImportError: # Python 2 - from UserDict import IterableUserDict - - -def python_2_unicode_compatible(klass): - """ - A decorator that defines __unicode__ and __str__ methods under Python 2. - Under Python 3 it does nothing. - - From django.utils.encoding.py in 1.4.2+, minus the dependency on Six. - - To support Python 2 and 3 with a single code base, define a __str__ method - returning text and apply this decorator to the class. - """ - if sys.version_info[0] == 2: - if '__str__' not in klass.__dict__: - raise ValueError("@python_2_unicode_compatible cannot be applied " - "to %s because it doesn't define __str__()." % - klass.__name__) - klass.__unicode__ = klass.__str__ - klass.__str__ = lambda self: self.__unicode__().encode('utf-8') - return klass diff --git a/embedly/tests.py b/embedly/tests.py index 90ac6d9..c65e2e1 100644 --- a/embedly/tests.py +++ b/embedly/tests.py @@ -2,16 +2,8 @@ import re import sys import json - -try: # pragma: no cover - import unittest2 as unittest # Python 2.6 # pragma: no cover -except ImportError: # pragma: no cover - import unittest # pragma: no cover - -try: # pragma: no cover - from unittest import mock # pragma: no cover -except ImportError: # Python < 3.3 # pragma: no cover - import mock # pragma: no cover +import unittest +from unittest import mock # pragma: no cover from embedly.client import Embedly from embedly.models import Url diff --git a/setup.py b/setup.py index bf63710..562860c 100644 --- a/setup.py +++ b/setup.py @@ -42,8 +42,7 @@ def get_version(): tests_require=tests_require, test_suite="embedly.tests", zip_safe=True, - use_2to3=True, - classifiers=( + classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Natural Language :: English', @@ -54,5 +53,5 @@ def get_version(): 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', - ) + ] )