Remove support for Python 2.7

This commit is contained in:
Rémy HUBSCHER 2020-01-07 15:01:26 +01:00
parent 2773a2b158
commit b893e52eba
No known key found for this signature in database
GPG key ID: 82B47F36036A312A
39 changed files with 17 additions and 66 deletions

View file

@ -1,7 +1,6 @@
language: python language: python
dist: bionic dist: bionic
python: python:
- 2.7
- 3.6 - 3.6
- 3.7 - 3.7
- 3.8 - 3.8

View file

@ -1,4 +1,4 @@
from six import StringIO from io import StringIO
from django.core.files.base import ContentFile from django.core.files.base import ContentFile

View file

@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
"""Serve files with Django and reverse proxies.""" """Serve files with Django and reverse proxies."""
import pkg_resources import pkg_resources
#: Module version, as defined in PEP-0396. #: Module version, as defined in PEP-0396.
__version__ = pkg_resources.get_distribution(__package__.replace('-', '_')) \ __version__ = pkg_resources.get_distribution(__package__.replace('-', '_')).version
.version
# API shortcuts. # API shortcuts.

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Optimizations for Apache. """Optimizations for Apache.
See also `documentation of mod_xsendfile for Apache See also `documentation of mod_xsendfile for Apache

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Decorators to apply Apache X-Sendfile on a specific view.""" """Decorators to apply Apache X-Sendfile on a specific view."""
from django_downloadview.decorators import DownloadDecorator from django_downloadview.decorators import DownloadDecorator
from django_downloadview.apache.middlewares import XSendfileMiddleware from django_downloadview.apache.middlewares import XSendfileMiddleware

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Apache's specific responses.""" """Apache's specific responses."""
import os.path import os.path
@ -8,8 +7,7 @@ from django_downloadview.response import (ProxiedDownloadResponse,
class XSendfileResponse(ProxiedDownloadResponse): class XSendfileResponse(ProxiedDownloadResponse):
"Delegates serving file to Apache via X-Sendfile header." "Delegates serving file to Apache via X-Sendfile header."
def __init__(self, file_path, content_type, basename=None, def __init__(self, file_path, content_type, basename=None, attachment=True):
attachment=True):
"""Return a HttpResponse with headers for Apache X-Sendfile.""" """Return a HttpResponse with headers for Apache X-Sendfile."""
super(XSendfileResponse, self).__init__(content_type=content_type) super(XSendfileResponse, self).__init__(content_type=content_type)
if attachment: if attachment:

View file

@ -1,4 +1,3 @@
from six import iteritems
from django_downloadview.apache.response import XSendfileResponse from django_downloadview.apache.response import XSendfileResponse
@ -22,7 +21,7 @@ class XSendfileValidator(object):
""" """
self.assert_x_sendfile_response(test_case, response) self.assert_x_sendfile_response(test_case, response)
for key, value in iteritems(assertions): for key, value in assertions.items():
assert_func = getattr(self, 'assert_%s' % key) assert_func = getattr(self, 'assert_%s' % key)
assert_func(test_case, response, value) assert_func(test_case, response, value)

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Declaration of API shortcuts.""" """Declaration of API shortcuts."""
from django_downloadview.io import (BytesIteratorIO, # NoQA from django_downloadview.io import (BytesIteratorIO, # NoQA
TextIteratorIO) TextIteratorIO)

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Custom exceptions.""" """Custom exceptions."""

View file

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
"""File wrappers for use as exchange data between views and responses.""" """File wrappers for use as exchange data between views and responses."""
from __future__ import absolute_import
from io import BytesIO from io import BytesIO
from six.moves.urllib.parse import urlparse from urllib.parse import urlparse
from django.core.files.base import File from django.core.files.base import File
from django.utils.encoding import force_bytes from django.utils.encoding import force_bytes

View file

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
"""Low-level IO operations, for use with file wrappers.""" """Low-level IO operations, for use with file wrappers."""
from __future__ import absolute_import
import io import io
from django.utils.encoding import force_text, force_bytes from django.utils.encoding import force_text, force_bytes

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Optimizations for Lighttpd. """Optimizations for Lighttpd.
See also `documentation of X-Sendfile for Lighttpd See also `documentation of X-Sendfile for Lighttpd

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Decorators to apply Lighttpd X-Sendfile on a specific view.""" """Decorators to apply Lighttpd X-Sendfile on a specific view."""
from django_downloadview.decorators import DownloadDecorator from django_downloadview.decorators import DownloadDecorator
from django_downloadview.lighttpd.middlewares import XSendfileMiddleware from django_downloadview.lighttpd.middlewares import XSendfileMiddleware

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Lighttpd's specific responses.""" """Lighttpd's specific responses."""
import os.path import os.path

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Base material for download middlewares. """Base material for download middlewares.
Download middlewares capture :py:class:`django_downloadview.DownloadResponse` Download middlewares capture :py:class:`django_downloadview.DownloadResponse`

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Optimizations for Nginx. """Optimizations for Nginx.
See also `Nginx X-accel documentation <http://wiki.nginx.org/X-accel>`_ and See also `Nginx X-accel documentation <http://wiki.nginx.org/X-accel>`_ and

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Decorators to apply Nginx X-Accel on a specific view.""" """Decorators to apply Nginx X-Accel on a specific view."""
from django_downloadview.decorators import DownloadDecorator from django_downloadview.decorators import DownloadDecorator
from django_downloadview.nginx.middlewares import XAccelRedirectMiddleware from django_downloadview.nginx.middlewares import XAccelRedirectMiddleware

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Nginx's specific responses.""" """Nginx's specific responses."""
from datetime import timedelta from datetime import timedelta

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Django settings around Nginx X-Accel. """Django settings around Nginx X-Accel.
.. warning:: .. warning::

View file

@ -1,4 +1,3 @@
from six import iteritems
from django_downloadview.nginx.response import XAccelRedirectResponse from django_downloadview.nginx.response import XAccelRedirectResponse
@ -36,7 +35,7 @@ class XAccelRedirectValidator(object):
""" """
self.assert_x_accel_redirect_response(test_case, response) self.assert_x_accel_redirect_response(test_case, response)
for key, value in iteritems(assertions): for key, value in assertions.items():
assert_func = getattr(self, 'assert_%s' % key) assert_func = getattr(self, 'assert_%s' % key)
assert_func(test_case, response, value) assert_func(test_case, response, value)

View file

@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
""":py:class:`django.http.HttpResponse` subclasses.""" """:py:class:`django.http.HttpResponse` subclasses."""
import os import os
import mimetypes import mimetypes
import re import re
import unicodedata import unicodedata
import six from urllib.parse import quote
from six.moves import urllib
from django.conf import settings from django.conf import settings
from django.http import HttpResponse, StreamingHttpResponse from django.http import HttpResponse, StreamingHttpResponse
@ -31,9 +29,9 @@ def encode_basename_ascii(value):
ea ea
""" """
if isinstance(value, six.binary_type): if isinstance(value, bytes):
value = value.decode('utf-8') value = value.decode('utf-8')
ascii_basename = six.text_type(value) ascii_basename = str(value)
ascii_basename = unicodedata.normalize('NFKD', ascii_basename) ascii_basename = unicodedata.normalize('NFKD', ascii_basename)
ascii_basename = ascii_basename.encode('ascii', 'ignore') ascii_basename = ascii_basename.encode('ascii', 'ignore')
ascii_basename = ascii_basename.decode('ascii') ascii_basename = ascii_basename.decode('ascii')
@ -51,7 +49,7 @@ def encode_basename_utf8(value):
%C3%A9%C3%A0 %C3%A9%C3%A0
""" """
return urllib.parse.quote(force_str(value)) return quote(force_str(value))
def content_disposition(filename): def content_disposition(filename):

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Port of django-sendfile in django-downloadview.""" """Port of django-sendfile in django-downloadview."""
from django_downloadview.views.path import PathDownloadView from django_downloadview.views.path import PathDownloadView

View file

@ -1,6 +1,4 @@
"""Testing utilities."""
import shutil import shutil
from six import iteritems
import tempfile import tempfile
from django.conf import settings from django.conf import settings
@ -103,7 +101,7 @@ class DownloadResponseValidator(object):
""" """
self.assert_download_response(test_case, response) self.assert_download_response(test_case, response)
for key, value in iteritems(assertions): for key, value in assertions.items():
assert_func = getattr(self, 'assert_%s' % key) assert_func = getattr(self, 'assert_%s' % key)
assert_func(test_case, response, value) assert_func(test_case, response, value)

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Utility functions that may be implemented in external packages.""" """Utility functions that may be implemented in external packages."""
import re import re

View file

@ -1,6 +1,3 @@
# coding=utf-8
"""Views."""
# -*- coding: utf-8 -*-
"""Views to stream files.""" """Views to stream files."""
# API shortcuts. # API shortcuts.
from django_downloadview.views.base import (DownloadMixin, # NoQA from django_downloadview.views.base import (DownloadMixin, # NoQA

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Base material for download views: :class:`DownloadMixin` and """Base material for download views: :class:`DownloadMixin` and
:class:`BaseDownloadView`""" :class:`BaseDownloadView`"""
import calendar import calendar

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Stream files given an URL, i.e. files you want to proxy.""" """Stream files given an URL, i.e. files you want to proxy."""
import requests import requests

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Stream files that live in models.""" """Stream files that live in models."""
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
""":class:`PathDownloadView`.""" """:class:`PathDownloadView`."""
import os import os

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Stream files from storage.""" """Stream files from storage."""
from django.core.files.storage import DefaultStorage from django.core.files.storage import DefaultStorage

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Stream files that you generate or that live in memory.""" """Stream files that you generate or that live in memory."""
from django_downloadview.views.base import BaseDownloadView from django_downloadview.views.base import BaseDownloadView

View file

@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Python packaging.""" """Python packaging."""
import os import os
import sys import sys
@ -23,8 +22,6 @@ class Tox(TestCommand):
#: Absolute path to directory containing setup.py file. #: Absolute path to directory containing setup.py file.
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
#: Boolean, ``True`` if environment is running Python version 2.
IS_PYTHON2 = sys.version_info[0] == 2
NAME = 'django-downloadview' NAME = 'django-downloadview'
@ -39,8 +36,7 @@ CLASSIFIERS = [
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',
'Framework :: Django', 'Framework :: Django',
'License :: OSI Approved :: BSD License', 'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.8',
@ -62,7 +58,6 @@ REQUIREMENTS = [
'Django>=1.11', 'Django>=1.11',
'requests', 'requests',
'setuptools', 'setuptools',
'six',
# END requirements # END requirements
] ]
ENTRY_POINTS = {} ENTRY_POINTS = {}

View file

@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Test suite around :mod:`django_downloadview.api` and deprecation plan.""" """Test suite around :mod:`django_downloadview.api` and deprecation plan."""
from importlib import import_module from importlib import import_module, reload
import unittest import unittest
from six.moves import reload_module as reload
import warnings import warnings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured

View file

@ -1,4 +1,3 @@
# coding=utf-8
"""Tests around :mod:`django_downloadview.io`.""" """Tests around :mod:`django_downloadview.io`."""
import unittest import unittest

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Tests around project's distribution and packaging.""" """Tests around project's distribution and packaging."""
import os import os
import unittest import unittest

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Unit tests around responses.""" """Unit tests around responses."""
import unittest import unittest

View file

@ -1,4 +1,3 @@
# coding=utf-8
"""Tests around :py:mod:`django_downloadview.sendfile`.""" """Tests around :py:mod:`django_downloadview.sendfile`."""
from django.http import Http404 from django.http import Http404
import django.test import django.test

View file

@ -1,4 +1,3 @@
# coding=utf-8
"""Tests around :mod:`django_downloadview.views`.""" """Tests around :mod:`django_downloadview.views`."""
import calendar import calendar
import os import os

View file

@ -1,6 +1,5 @@
[tox] [tox]
envlist = py27-django111, envlist = py{35,36,36,37,38}-django{111,22,30},
py{35,36,36,37,38}-django{22,30},
flake8, sphinx, readme flake8, sphinx, readme
[travis] [travis]
@ -54,3 +53,6 @@ deps =
zest.releaser zest.releaser
commands = commands =
fullrelease fullrelease
[flake8]
max-line-length = 99