mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-03-16 22:40:25 +00:00
Remove u'' in front of strings.
This commit is contained in:
parent
6c7c8d9a60
commit
af30524bd2
10 changed files with 24 additions and 24 deletions
|
|
@ -12,7 +12,7 @@ from demoproject.compat import reverse
|
|||
def setup_file():
|
||||
if not os.path.exists(storage_dir):
|
||||
os.makedirs(storage_dir)
|
||||
storage.save("hello-world.txt", ContentFile(u"Hello world!\n"))
|
||||
storage.save("hello-world.txt", ContentFile("Hello world!\n"))
|
||||
|
||||
|
||||
class OptimizedByMiddlewareTestCase(django.test.TestCase):
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from demoproject.lighttpd.views import storage, storage_dir
|
|||
def setup_file():
|
||||
if not os.path.exists(storage_dir):
|
||||
os.makedirs(storage_dir)
|
||||
storage.save("hello-world.txt", ContentFile(u"Hello world!\n"))
|
||||
storage.save("hello-world.txt", ContentFile("Hello world!\n"))
|
||||
|
||||
|
||||
class OptimizedByMiddlewareTestCase(django.test.TestCase):
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from demoproject.nginx.views import storage, storage_dir
|
|||
def setup_file():
|
||||
if not os.path.exists(storage_dir):
|
||||
os.makedirs(storage_dir)
|
||||
storage.save("hello-world.txt", ContentFile(u"Hello world!\n"))
|
||||
storage.save("hello-world.txt", ContentFile("Hello world!\n"))
|
||||
|
||||
|
||||
class OptimizedByMiddlewareTestCase(django.test.TestCase):
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ class TextDownloadView(VirtualDownloadView):
|
|||
class StringIODownloadView(VirtualDownloadView):
|
||||
def get_file(self):
|
||||
"""Return wrapper on ``six.StringIO`` object."""
|
||||
file_obj = StringIO(u"Hello world!\n")
|
||||
file_obj = StringIO("Hello world!\n")
|
||||
return VirtualFile(file_obj, name="hello-world.txt")
|
||||
|
||||
|
||||
def generate_hello():
|
||||
yield u"Hello "
|
||||
yield u"world!"
|
||||
yield u"\n"
|
||||
yield "Hello "
|
||||
yield "world!"
|
||||
yield "\n"
|
||||
|
||||
|
||||
class GeneratedDownloadView(VirtualDownloadView):
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ NAME = "django-downloadview-demo"
|
|||
DESCRIPTION = "Serve files with Django and reverse-proxies."
|
||||
README = open(os.path.join(here, "README.rst")).read()
|
||||
VERSION = open(os.path.join(project_root, "VERSION")).read().strip()
|
||||
AUTHOR = u"Benoît Bryon"
|
||||
EMAIL = u"benoit@marmelune.net"
|
||||
AUTHOR = "Benoît Bryon"
|
||||
EMAIL = "benoit@marmelune.net"
|
||||
URL = "https://django-downloadview.readthedocs.io/"
|
||||
CLASSIFIERS = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class StorageFile(File):
|
|||
class VirtualFile(File):
|
||||
"""Wrapper for files that live in memory."""
|
||||
|
||||
def __init__(self, file=None, name=u"", url="", size=None):
|
||||
def __init__(self, file=None, name="", url="", size=None):
|
||||
"""Constructor.
|
||||
|
||||
file:
|
||||
|
|
@ -224,7 +224,7 @@ class HTTPFile(File):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, request_factory=requests.get, url="", name=u"", **kwargs):
|
||||
def __init__(self, request_factory=requests.get, url="", name="", **kwargs):
|
||||
self.request_factory = request_factory
|
||||
self.url = url
|
||||
if name is None:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class TextIteratorIO(io.TextIOBase):
|
|||
self._iter = iterator
|
||||
|
||||
#: Internal buffer.
|
||||
self._left = u""
|
||||
self._left = ""
|
||||
|
||||
def readable(self):
|
||||
return True
|
||||
|
|
@ -53,24 +53,24 @@ class TextIteratorIO(io.TextIOBase):
|
|||
break
|
||||
n -= len(m)
|
||||
chunks.append(m)
|
||||
return u"".join(chunks)
|
||||
return "".join(chunks)
|
||||
|
||||
def readline(self):
|
||||
chunks = []
|
||||
while True:
|
||||
i = self._left.find(u"\n")
|
||||
i = self._left.find("\n")
|
||||
if i == -1:
|
||||
chunks.append(self._left)
|
||||
try:
|
||||
self._left = next(self._iter)
|
||||
except StopIteration:
|
||||
self._left = u""
|
||||
self._left = ""
|
||||
break
|
||||
else:
|
||||
chunks.append(self._left[: i + 1])
|
||||
self._left = self._left[i + 1 :]
|
||||
break
|
||||
return u"".join(chunks)
|
||||
return "".join(chunks)
|
||||
|
||||
|
||||
class BytesIteratorIO(io.BytesIO):
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class HTTPDownloadView(BaseDownloadView):
|
|||
"""Proxy files that live on remote servers."""
|
||||
|
||||
#: URL to download (the one we are proxying).
|
||||
url = u""
|
||||
url = ""
|
||||
|
||||
#: Additional keyword arguments for request handler.
|
||||
request_kwargs = {}
|
||||
|
|
|
|||
12
tests/io.py
12
tests/io.py
|
|
@ -3,17 +3,17 @@ import unittest
|
|||
|
||||
from django_downloadview import BytesIteratorIO, TextIteratorIO
|
||||
|
||||
HELLO_TEXT = u"Hello world!\né\n"
|
||||
HELLO_TEXT = "Hello world!\né\n"
|
||||
HELLO_BYTES = b"Hello world!\n\xc3\xa9\n"
|
||||
|
||||
|
||||
def generate_hello_text():
|
||||
"""Generate u'Hello world!\n'."""
|
||||
yield u"Hello "
|
||||
yield u"world!"
|
||||
yield u"\n"
|
||||
yield u"é"
|
||||
yield u"\n"
|
||||
yield "Hello "
|
||||
yield "world!"
|
||||
yield "\n"
|
||||
yield "é"
|
||||
yield "\n"
|
||||
|
||||
|
||||
def generate_hello_bytes():
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class DownloadResponseTestCase(unittest.TestCase):
|
|||
def test_content_disposition_encoding(self):
|
||||
"""Content-Disposition header is encoded."""
|
||||
response = DownloadResponse(
|
||||
"fake file", attachment=True, basename=u"espacé .txt",
|
||||
"fake file", attachment=True, basename="espacé .txt",
|
||||
)
|
||||
headers = response.default_headers
|
||||
self.assertIn('filename="espace_.txt"', headers["Content-Disposition"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue