Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/TharinduDR/TransQuest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTharinduDR <rhtdranasinghe@gmail.com>2021-02-11 19:55:55 +0300
committerTharinduDR <rhtdranasinghe@gmail.com>2021-02-11 19:55:55 +0300
commit8f7395d88c3d190b6f4076f7deb0a42977087942 (patch)
tree35a8cc823bdea40526d2695fabd74b1c1b90c9b5
parenta6de1a0368c39ebed4b39ea16086f3800c66a77a (diff)
055: Adding word level examples
-rw-r--r--transquest/app/util/model_downloader.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/transquest/app/util/model_downloader.py b/transquest/app/util/model_downloader.py
index 3a3985c..19b4c46 100644
--- a/transquest/app/util/model_downloader.py
+++ b/transquest/app/util/model_downloader.py
@@ -67,8 +67,8 @@ class GoogleDriveDownloader:
params = {'id': file_id, 'confirm': token}
response = session.get(GoogleDriveDownloader.DOWNLOAD_URL, params=params, stream=True)
- # if showsize:
- # # logger.info("\n") # Skip to the next line
+ if showsize:
+ logger.info("\n") # Skip to the next line
current_download_size = [0]
GoogleDriveDownloader._save_response_content(response, dest_path, showsize, current_download_size, size)
@@ -98,12 +98,16 @@ class GoogleDriveDownloader:
if chunk: # filter out keep-alive new chunks
f.write(chunk)
if showsize:
- print('\r' + str(float(GoogleDriveDownloader.sizeof_fmt(current_size[0]))/total_size), end=' ')
+ # print('\r' + str(float(GoogleDriveDownloader.sizeof_fmt(current_size[0]))/total_size), end=' ')
+ print('\r' + current_size[0]/1024, end=' ')
stdout.flush()
current_size[0] += GoogleDriveDownloader.CHUNK_SIZE
# From https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
@staticmethod
- def sizeof_fmt(num):
- num /= 1024.0
- return '{:.1f} '.format(num)
+ def sizeof_fmt(num, suffix='B'):
+ for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
+ if abs(num) < 1024.0:
+ return '{:.1f} {}{}'.format(num, unit, suffix)
+ num /= 1024.0
+ return '{:.1f} {}{}'.format(num, 'Yi', suffix)