Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _updateDisplay(self, modulo=1):
self.displayCounter += 1
if self.displayCounter % modulo != 0:
return
fileName = self._getFileNameDisplayString()
if self.fileSize is None:
displayString = "{} bytes received: {}\r"
bytesReceived = humanize.filesize.naturalsize(
self.bytesReceived)
self.stream.write(displayString.format(
fileName, bytesReceived))
else:
# TODO contentlength seems to slightly under-report how many
# bytes we have to download... hence the min functions
percentage = min(self.bytesReceived / self.fileSize, 1)
numerator = humanize.filesize.naturalsize(
min(self.bytesReceived, self.fileSize))
denominator = humanize.filesize.naturalsize(
self.fileSize)
displayString = "{} {:<6.2%} ({:>9} / {:<9})\r"
self.stream.write(displayString.format(
fileName, percentage, numerator, denominator))
self.stream.flush()
def _updateDisplay(self, modulo=1):
self.displayCounter += 1
if self.displayCounter % modulo != 0:
return
fileName = self._getFileNameDisplayString()
if self.fileSize is None:
displayString = "{} bytes received: {}\r"
bytesReceived = humanize.filesize.naturalsize(
self.bytesReceived)
self.stream.write(displayString.format(
fileName, bytesReceived))
else:
# TODO contentlength seems to slightly under-report how many
# bytes we have to download... hence the min functions
percentage = min(self.bytesReceived / self.fileSize, 1)
numerator = humanize.filesize.naturalsize(
min(self.bytesReceived, self.fileSize))
denominator = humanize.filesize.naturalsize(
self.fileSize)
displayString = "{} {:<6.2%} ({:>9} / {:<9})\r"
self.stream.write(displayString.format(
fileName, percentage, numerator, denominator))
self.stream.flush()