mirror of
https://github.com/imputnet/helium.git
synced 2026-08-20 00:57:32 +02:00
Merge branch 'patch-1' of github.com:pwindle/ungoogled-chromium
This commit is contained in:
@@ -38,15 +38,16 @@ class _UrlRetrieveReportHook: #pylint: disable=too-few-public-methods
|
||||
self._last_percentage = None
|
||||
|
||||
def __call__(self, block_count, block_size, total_size):
|
||||
downloaded_estimate = block_count * block_size
|
||||
percentage = round(downloaded_estimate / total_size, ndigits=3)
|
||||
if percentage == self._last_percentage:
|
||||
return # Do not needlessly update the console
|
||||
self._last_percentage = percentage
|
||||
print('\r' + ' ' * self._max_len_printed, end='')
|
||||
if total_size > 0:
|
||||
total_blocks = (total_size + (block_size - total_size % block_size)) / block_size
|
||||
percentage = block_count / total_blocks
|
||||
if percentage == self._last_percentage:
|
||||
return # Do not needlessly update the console
|
||||
self._last_percentage = percentage
|
||||
print('\r' + ' ' * self._max_len_printed, end='')
|
||||
status_line = 'Progress: {:.1%} of {:,d} B'.format(percentage, total_size)
|
||||
else:
|
||||
downloaded_estimate = block_count * block_size
|
||||
status_line = 'Progress: {:,d} B of unknown size'.format(downloaded_estimate)
|
||||
self._max_len_printed = len(status_line)
|
||||
print('\r' + status_line, end='')
|
||||
|
||||
Reference in New Issue
Block a user