From edf1d627377ba04da5664107f185e3652598f666 Mon Sep 17 00:00:00 2001 From: Delirious Lettuce Date: Mon, 10 Jul 2017 20:00:19 -0600 Subject: [PATCH] Remove: unused import, `round`, formatting indexes. Use tuple --- onionshare/common.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/onionshare/common.py b/onionshare/common.py index 89d4695f..4c36d211 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -20,7 +20,6 @@ along with this program. If not, see . import base64 import hashlib import inspect -import math import os import platform import random @@ -143,14 +142,14 @@ def human_readable_filesize(b): """ thresh = 1024.0 if b < thresh: - return '{0:.1f} B'.format(b) - units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] + return '{:.1f} B'.format(b) + units = ('KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB') u = 0 b /= thresh while b >= thresh: b /= thresh u += 1 - return '{0:.1f} {1:s}'.format(round(b, 1), units[u]) + return '{:.1f} {}'.format(b, units[u]) def format_seconds(seconds):