--- a/eric6/WebBrowser/Download/DownloadItem.py Fri Apr 02 11:59:41 2021 +0200 +++ b/eric6/WebBrowser/Download/DownloadItem.py Sat May 01 14:27:20 2021 +0200 @@ -55,7 +55,7 @@ @param parent reference to the parent widget @type QWidget """ - super(DownloadItem, self).__init__(parent) + super().__init__(parent) self.setupUi(self) p = self.infoLabel.palette() @@ -245,15 +245,17 @@ # check file path for saving saveDirPath = QFileInfo(self.__fileName).dir() - if not saveDirPath.exists(): - if not saveDirPath.mkpath(saveDirPath.absolutePath()): - self.progressBar.setVisible(False) - self.on_stopButton_clicked() - self.infoLabel.setText(self.tr( - "Download directory ({0}) couldn't be created.") - .format(saveDirPath.absolutePath())) - self.__setDateTime() - return + if ( + not saveDirPath.exists() and + not saveDirPath.mkpath(saveDirPath.absolutePath()) + ): + self.progressBar.setVisible(False) + self.on_stopButton_clicked() + self.infoLabel.setText(self.tr( + "Download directory ({0}) couldn't be created.") + .format(saveDirPath.absolutePath())) + self.__setDateTime() + return self.filenameLabel.setText(QFileInfo(self.__fileName).fileName()) @@ -398,10 +400,11 @@ return -1.0 cSpeed = self.currentSpeed() - if cSpeed != 0: - timeRemaining = (self.bytesTotal() - self.bytesReceived()) / cSpeed - else: - timeRemaining = 1 + timeRemaining = ( + (self.bytesTotal() - self.bytesReceived()) / cSpeed + if cSpeed != 0 else + 1 + ) # ETA should never be 0 if timeRemaining == 0: @@ -447,7 +450,7 @@ remaining ) else: - if self.__bytesReceived == bytesTotal or bytesTotal == -1: + if bytesTotal in (self.__bytesReceived, -1): info = self.tr( "{0} downloaded" ).format(dataString(self.__bytesReceived))