Helpviewer/DownloadDialog.py

changeset 12
1d8dd9706f46
parent 7
c679fb30c8f3
child 13
1af94a91f439
equal deleted inserted replaced
11:b0996e4a289e 12:1d8dd9706f46
13 13
14 import Preferences 14 import Preferences
15 15
16 import Helpviewer.HelpWindow 16 import Helpviewer.HelpWindow
17 17
18 from Ui_DownloadDialog import Ui_DownloadDialog 18 from .Ui_DownloadDialog import Ui_DownloadDialog
19 19
20 class DownloadDialog(QWidget, Ui_DownloadDialog): 20 class DownloadDialog(QWidget, Ui_DownloadDialog):
21 """ 21 """
22 Class implementing the download dialog. 22 Class implementing the download dialog.
23 23
155 @param directory name of the directory to store the file into (string) 155 @param directory name of the directory to store the file into (string)
156 @return proposed filename (string) 156 @return proposed filename (string)
157 """ 157 """
158 path = "" 158 path = ""
159 if self.__reply.hasRawHeader("Content-Disposition"): 159 if self.__reply.hasRawHeader("Content-Disposition"):
160 header = unicode(self.__reply.rawHeader("Content-Disposition")) 160 header = str(self.__reply.rawHeader("Content-Disposition"))
161 if header: 161 if header:
162 pos = header.find("filename=") 162 pos = header.find("filename=")
163 if pos != -1: 163 if pos != -1:
164 path = header[pos + 9:] 164 path = header[pos + 9:]
165 if path.startswith('"') and path.endswith('"'): 165 if path.startswith('"') and path.endswith('"'):
365 """ 365 """
366 unit = "" 366 unit = ""
367 if size < 1024: 367 if size < 1024:
368 unit = self.trUtf8("bytes") 368 unit = self.trUtf8("bytes")
369 elif size < 1024 * 1024: 369 elif size < 1024 * 1024:
370 size /= 1024 370 size //= 1024
371 unit = self.trUtf8("kB") 371 unit = self.trUtf8("kB")
372 else: 372 else:
373 size /= 1024 * 1024 373 size //= 1024 * 1024
374 unit = self.trUtf8("MB") 374 unit = self.trUtf8("MB")
375 return "{0} {1}".format(size, unit) 375 return "{0} {1}".format(size, unit)
376 376
377 def __downloading(self): 377 def __downloading(self):
378 """ 378 """

eric ide

mercurial