diff options
author | Micah Lee <micah@micahflee.com> | 2015-05-14 14:40:55 -0700 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2015-05-14 14:40:55 -0700 |
commit | aab5ae31ab9bfd9493c9d6ea54d286f99456420d (patch) | |
tree | bf6eb255332664c8c2ef7e3ec3d2a774e12908af | |
parent | 5f2aa7272cc6644f3403dc4680b6db80b1788279 (diff) | |
download | onionshare-aab5ae31ab9bfd9493c9d6ea54d286f99456420d.tar.gz onionshare-aab5ae31ab9bfd9493c9d6ea54d286f99456420d.zip |
No longer duplicates human_readable_filesize functions. Closes #170
-rw-r--r-- | onionshare_gui/file_selection.py | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index 89d2e560..c22a2407 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -114,9 +114,9 @@ class FileList(QtGui.QListWidget): icon = ip.icon(fileinfo) if os.path.isfile(filename): - size = self.human_readable_filesize(fileinfo.size()) + size = helpers.human_readable_filesize(fileinfo.size()) else: - size = self.human_readable_filesize(helpers.dir_size(filename)) + size = helpers.human_readable_filesize(helpers.dir_size(filename)) item_name = unicode('{0} ({1})'.format(basename, size)) item = QtGui.QListWidgetItem(item_name) item.setToolTip(QtCore.QString(size)) @@ -126,18 +126,6 @@ class FileList(QtGui.QListWidget): self.files_updated.emit() - def human_readable_filesize(self, b): - thresh = 1024.0 - if b < thresh: - return '{0} 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} {1}'.format(round(b, 1), units[u]) - class FileSelection(QtGui.QVBoxLayout): def __init__(self): @@ -220,4 +208,3 @@ class FileSelection(QtGui.QVBoxLayout): def get_num_files(self): return len(self.file_list.filenames) - |