edoburu / django-private-storage

@@ -126,7 +126,7 @@
Loading
126 126
        if 'WebKit' in user_agent:
127 127
            # Support available for UTF-8 encoded strings.
128 128
            # This also matches Edgee.
129 -
            return u'filename={}'.format(filename).encode("utf-8")
129 +
            return 'filename={}'.format(filename).encode("utf-8")
130 130
        elif 'MSIE' in user_agent:
131 131
            # IE does not support RFC2231 for internationalized headers, but somehow
132 132
            # percent-decodes it so this can be used instead. Note that using the word
@@ -155,7 +155,7 @@
Loading
155 155
156 156
    def get(self, request, *args, **kwargs):
157 157
        self.object = self.get_object()
158 -
        return super(PrivateStorageDetailView, self).get(request, *args, **kwargs)
158 +
        return super().get(request, *args, **kwargs)
159 159
160 160
    def get_path(self):
161 161
        file = getattr(self.object, self.model_file_field)

@@ -11,7 +11,7 @@
Loading
11 11
        """
12 12
        Empty the test folder after each test case.
13 13
        """
14 -
        super(PrivateFileTestCase, self).tearDown()
14 +
        super().tearDown()
15 15
        if os.path.exists(settings.PRIVATE_STORAGE_ROOT):
16 16
            shutil.rmtree(settings.PRIVATE_STORAGE_ROOT)
17 17

@@ -1,4 +1,3 @@
Loading
1 -
#-*- coding: utf-8 -*-
2 1
import datetime
3 2
import logging
4 3
import os
@@ -41,10 +40,10 @@
Loading
41 40
        self.max_file_size = kwargs.pop("max_file_size", None)
42 41
43 42
        kwargs.setdefault('storage', private_storage)
44 -
        super(PrivateFileField, self).__init__(*args, **kwargs)
43 +
        super().__init__(*args, **kwargs)
45 44
46 45
    def clean(self, *args, **kwargs):
47 -
        data = super(PrivateFileField, self).clean(*args, **kwargs)
46 +
        data = super().clean(*args, **kwargs)
48 47
        file = data.file
49 48
        if isinstance(file, UploadedFile):
50 49
            # content_type is only available for uploaded files,

@@ -1,4 +1,3 @@
Loading
1 -
# encoding: utf-8
2 1
from django.contrib.auth.models import User
3 2
from django.core.files.uploadedfile import SimpleUploadedFile
4 3
from django.http import FileResponse
@@ -92,9 +91,9 @@
Loading
92 91
        """
93 92
        obj = CustomerDossier.objects.create(
94 93
            customer='cust2',
95 -
            file=SimpleUploadedFile(u'Heizölrückstoßabdämpfung.txt', b'test5')
94 +
            file=SimpleUploadedFile('Heizölrückstoßabdämpfung.txt', b'test5')
96 95
        )
97 -
        self.assertExists('CustomerDossier', 'cust2', u'Heizölrückstoßabdämpfung.txt')
96 +
        self.assertExists('CustomerDossier', 'cust2', 'Heizölrückstoßabdämpfung.txt')
98 97
99 98
        # Initialize locally, no need for urls.py etc..
100 99
        # This behaves like a standard DetailView
@@ -116,7 +115,7 @@
Loading
116 115
117 116
                response = view(
118 117
                    request,
119 -
                    path=u'CustomerDossier/cust2/Heizölrückstoßabdämpfung.txt'
118 +
                    path='CustomerDossier/cust2/Heizölrückstoßabdämpfung.txt'
120 119
                )
121 120
                if method == 'HEAD':
122 121
                    self.assertNotIsInstance(response, FileResponse)

@@ -49,7 +49,7 @@
Loading
49 49
    return _dec
50 50
51 51
52 -
class DjangoStreamingServer(object):
52 +
class DjangoStreamingServer:
53 53
    """
54 54
    Serve static files through ``wsgi.file_wrapper`` or streaming chunks.
55 55
@@ -60,10 +60,7 @@
Loading
60 60
    @add_no_cache_headers
61 61
    def serve(private_file):
62 62
        # Support If-Last-Modified
63 -
        if sys.version_info >= (3,):
64 -
            mtime = private_file.modified_time.timestamp()
65 -
        else:
66 -
            mtime = time.mktime(private_file.modified_time.timetuple())
63 +
        mtime = private_file.modified_time.timestamp()
67 64
        size = private_file.size
68 65
        if not was_modified_since(private_file.request.META.get('HTTP_IF_MODIFIED_SINCE'), mtime, size):
69 66
            return HttpResponseNotModified()
@@ -122,7 +119,7 @@
Loading
122 119
                return response
123 120
124 121
125 -
class ApacheXSendfileServer(object):
122 +
class ApacheXSendfileServer:
126 123
    """
127 124
    Serve files for Apache with ``X-Sendfile``.
128 125
    """
@@ -136,7 +133,7 @@
Loading
136 133
        return response
137 134
138 135
139 -
class NginxXAccelRedirectServer(object):
136 +
class NginxXAccelRedirectServer:
140 137
    """
141 138
    Serve the files for Nginx with ``X-Accel-Redirect``.
142 139
    Add the following configuration::

@@ -20,7 +20,7 @@
Loading
20 20
        if location is None:
21 21
            location = appconfig.PRIVATE_STORAGE_ROOT
22 22
23 -
        super(PrivateFileSystemStorage, self).__init__(
23 +
        super().__init__(
24 24
            location=location,
25 25
            base_url=base_url,
26 26
            **kwargs
@@ -34,4 +34,4 @@
Loading
34 34
    def url(self, name):
35 35
        # Make sure reverse_lazy() is evaluated
36 36
        self.base_url = force_str(self.base_url)
37 -
        return super(PrivateFileSystemStorage, self).url(name)
37 +
        return super().url(name)

@@ -4,7 +4,7 @@
Loading
4 4
from django.utils.functional import cached_property
5 5
6 6
7 -
class PrivateFile(object):
7 +
class PrivateFile:
8 8
    """
9 9
    A wrapper object that describes the file that is being accessed.
10 10
    """

@@ -61,7 +61,7 @@
Loading
61 61
            return reverse('serve_private_file', kwargs={'path': name})
62 62
        else:
63 63
            # The S3Boto3Storage can generate a presigned URL that is temporary available.
64 -
            return super(PrivateS3BotoStorage, self).url(name, *args, **kwargs)
64 +
            return super().url(name, *args, **kwargs)
65 65
66 66
67 67
@deconstructible
Files Coverage
private_storage 65.97%
Project Totals (17 files) 65.97%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading