Unverified Commit 7e02c9e9 authored by Diederik van der Boor's avatar Diederik van der Boor
Browse files

Perform f-string updates using py-upgrade

parent d4c0c7bd
......@@ -16,7 +16,7 @@ class PrivateFile:
self.parent_object = parent_object
def __repr__(self):
return '<PrivateFile: {}>'.format(self.relative_name)
return f'<PrivateFile: {self.relative_name}>'
@cached_property
def full_path(self):
......
......@@ -16,7 +16,7 @@ from django.utils.module_loading import import_string
from django.views.static import serve, was_modified_since
@lru_cache()
@lru_cache
def get_server_class(path):
if '.' in path:
return import_string(path)
......
......@@ -126,17 +126,17 @@ class PrivateStorageView(View):
if 'WebKit' in user_agent:
# Support available for UTF-8 encoded strings.
# This also matches Edgee.
return 'filename={}'.format(filename).encode("utf-8")
return f'filename={filename}'.encode("utf-8")
elif 'MSIE' in user_agent:
# IE does not support RFC2231 for internationalized headers, but somehow
# percent-decodes it so this can be used instead. Note that using the word
# "attachment" anywhere in the filename overrides an inline content-disposition.
url_encoded = quote(filename.encode("utf-8")).replace('attachment', "a%74tachment")
return "filename={}".format(url_encoded).encode("utf-8")
return f"filename={url_encoded}".encode("utf-8")
else:
# For others like Firefox, we follow RFC2231 (encoding extension in HTTP headers).
rfc2231_filename = quote(filename.encode("utf-8"))
return "filename*=UTF-8''{}".format(rfc2231_filename).encode("utf-8")
return f"filename*=UTF-8''{rfc2231_filename}".encode("utf-8")
class PrivateStorageDetailView(SingleObjectMixin, PrivateStorageView):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment