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
dist: bionic
python:
- 2.7
- 3.6
- 3.7
- 3.8

View file

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

View file

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

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Optimizations 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."""
from django_downloadview.decorators import DownloadDecorator
from django_downloadview.apache.middlewares import XSendfileMiddleware

View file

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

View file

@ -1,4 +1,3 @@
from six import iteritems
from django_downloadview.apache.response import XSendfileResponse
@ -22,7 +21,7 @@ class XSendfileValidator(object):
"""
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(test_case, response, value)

View file

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

View file

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

View file

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
"""File wrappers for use as exchange data between views and responses."""
from __future__ import absolute_import
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.utils.encoding import force_bytes

View file

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

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Optimizations 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."""
from django_downloadview.decorators import DownloadDecorator
from django_downloadview.lighttpd.middlewares import XSendfileMiddleware

View file

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

View file

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

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Optimizations for Nginx.
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."""
from django_downloadview.decorators import DownloadDecorator
from django_downloadview.nginx.middlewares import XAccelRedirectMiddleware

View file

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

View file

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

View file

@ -1,4 +1,3 @@
from six import iteritems
from django_downloadview.nginx.response import XAccelRedirectResponse
@ -36,7 +35,7 @@ class XAccelRedirectValidator(object):
"""
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(test_case, response, value)

View file

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

View file

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

View file

@ -1,6 +1,4 @@
"""Testing utilities."""
import shutil
from six import iteritems
import tempfile
from django.conf import settings
@ -103,7 +101,7 @@ class DownloadResponseValidator(object):
"""
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(test_case, response, value)

View file

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

View file

@ -1,6 +1,3 @@
# coding=utf-8
"""Views."""
# -*- coding: utf-8 -*-
"""Views to stream files."""
# API shortcuts.
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
:class:`BaseDownloadView`"""
import calendar

View file

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

View file

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

View file

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

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Stream files from storage."""
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."""
from django_downloadview.views.base import BaseDownloadView

View file

@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Python packaging."""
import os
import sys
@ -23,8 +22,6 @@ class Tox(TestCommand):
#: Absolute path to directory containing setup.py 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'
@ -39,8 +36,7 @@ CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Framework :: Django',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
@ -62,7 +58,6 @@ REQUIREMENTS = [
'Django>=1.11',
'requests',
'setuptools',
'six',
# END requirements
]
ENTRY_POINTS = {}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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