Skip to content

Commit d7522b1

Browse files
committed
commit 6c9bc9f, but compatible with Python 2
1 parent 6c9bc9f commit d7522b1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

remi/gui.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
unescape = html.unescape
4545

4646
from .server import runtimeInstances
47-
import urllib.parse
47+
try:
48+
from urllib.parse import quote
49+
except ImportError:
50+
from urllib import quote
4851

4952
log = logging.getLogger('remi.gui')
5053

@@ -4136,9 +4139,9 @@ def __init__(self, text, filename, path_separator='/', *args, **kwargs):
41364139
def download(self):
41374140
with open(self._filename, 'r+b') as f:
41384141
content = f.read()
4139-
filename = urllib.parse.quote(os.path.basename(self._filename))
4142+
filename = quote(os.path.basename(self._filename))
41404143
headers = {'Content-type': 'application/octet-stream',
4141-
'Content-Disposition': f'attachment; filename="{filename}"; filename*=UTF-8\'\'{filename}'}
4144+
'Content-Disposition': 'attachment; filename="{0}"; filename*=UTF-8\'\'{0}'.format(filename)}
41424145
return [content, headers]
41434146

41444147

0 commit comments

Comments
 (0)