Skip to content

Commit

Permalink
Remove old versions from test matrix (#15)
Browse files Browse the repository at this point in the history
- Remove Django 1.8-1.10 and 2.0
- Remove Python 3.4
- Remove code for support of the above
- Tidy up imports

Fixes #7
  • Loading branch information
moggers87 authored Jun 6, 2019
1 parent 7dd39d5 commit 455e34a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ dist: xenial

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- pypy2.7-6.0
- pypy3.5-6.0

install:
- pip install tox-travis
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ etc is done elsewhere.
Supported Django Versions
=========================

Django 1.8 to 2.2 is currently supported by this library.
Django 1.11, 2.1, and 2.2 are currently supported by this library.

Installation
============
Expand Down
6 changes: 1 addition & 5 deletions examples/protected_downloads/download/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

from django.conf import settings
from django.core.files.storage import FileSystemStorage

try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
from django.urls import reverse

sendfile_storage = FileSystemStorage(location=settings.SENDFILE_ROOT)

Expand Down
14 changes: 1 addition & 13 deletions examples/protected_downloads/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os.path

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[email protected]'),
Expand Down Expand Up @@ -54,13 +53,6 @@
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'n309^dwk=@+g72ko--8vjyz&1v0u%xf#*0=wzr=2n#f3hb0a=l'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
Expand All @@ -70,10 +62,6 @@

ROOT_URLCONF = 'urls'

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
)

TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
Expand All @@ -87,7 +75,7 @@
'django.template.loaders.app_directories.Loader',
),
],
'debug': DEBUG, # noqa: F405
'debug': DEBUG,
},
}]

Expand Down
20 changes: 8 additions & 12 deletions sendfile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from importlib import import_module
from mimetypes import guess_type
import os.path
import unicodedata

from ._version import get_versions
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.http import Http404
from django.utils.encoding import force_text
from django.utils.http import urlquote
import six

from ._version import get_versions

__version__ = get_versions()['version']
del get_versions
Expand Down Expand Up @@ -31,13 +38,6 @@ def clear():

@_lazy_load
def _get_sendfile():
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

backend = getattr(settings, 'SENDFILE_BACKEND', None)
if not backend:
raise ImproperlyConfigured('You ust specify a value for SENDFILE_BACKEND')
Expand Down Expand Up @@ -65,7 +65,6 @@ def sendfile(request, filename, attachment=False, attachment_filename=None,
_sendfile = _get_sendfile()

if not os.path.exists(filename):
from django.http import Http404
raise Http404('"%s" does not exist' % filename)

guessed_mimetype, guessed_encoding = guess_type(filename)
Expand All @@ -83,18 +82,15 @@ def sendfile(request, filename, attachment=False, attachment_filename=None,
parts = ['attachment']

if attachment_filename:
from django.utils.encoding import force_text
attachment_filename = force_text(attachment_filename)
ascii_filename = unicodedata.normalize('NFKD', attachment_filename)
ascii_filename = ascii_filename.encode('ascii', 'ignore')

import six
if six.PY3:
ascii_filename = ascii_filename.decode()
parts.append('filename="%s"' % ascii_filename)

if ascii_filename != attachment_filename:
from django.utils.http import urlquote
quoted_filename = urlquote(attachment_filename)
parts.append('filename*=UTF-8\'\'%s' % quoted_filename)

Expand Down
4 changes: 2 additions & 2 deletions sendfile/backends/development.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.views.static import serve

import os.path

from django.views.static import serve


def sendfile(request, filename, **kwargs):
'''
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand Down
14 changes: 4 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
[tox]
envlist =
{pypy,py27}-django{18,19,110,111}
py34-django{18,19,110,111,20}
py35-django{18,19,110,111,20,21,22}
py36-django{111,20,21,22}
py37-django{20,21,22}
{pypy,py27}-django111
py{py3,35,36,37}-django{111,21,22}
flake8

[testenv]
usedevelop=True
deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
changedir = examples/protected_downloads
Expand All @@ -40,7 +33,8 @@ exclude =
[travis]
python =
2.7: py27
3.4: py34
3.5: py35
3.6: py36
3.7: py37
pypy: pypy
pypy3: pypy3

0 comments on commit 455e34a

Please sign in to comment.