mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-03-31 22:32:28 -04:00
Fix #728 and make size->string conversion more robust.
This commit is contained in:
parent
daa604df81
commit
9c119fc238
@ -57,16 +57,15 @@ def qstring_to_unicode(q):
|
||||
|
||||
def human_readable(size):
|
||||
""" Convert a size in bytes into a human readable form """
|
||||
if size < 1024:
|
||||
divisor, suffix = 1, "B"
|
||||
elif size < 1024*1024:
|
||||
divisor, suffix = 1, "B"
|
||||
if size < 1024*1024:
|
||||
divisor, suffix = 1024., "KB"
|
||||
elif size < 1024*1024*1024:
|
||||
elif size < 1024*1024*1024:
|
||||
divisor, suffix = 1024*1024, "MB"
|
||||
elif size < 1024*1024*1024*1024:
|
||||
elif size < 1024*1024*1024*1024:
|
||||
divisor, suffix = 1024*1024*1024, "GB"
|
||||
size = str(float(size)/divisor)
|
||||
if size.find(".") > -1:
|
||||
if size.find(".") > -1:
|
||||
size = size[:size.find(".")+2]
|
||||
if size.endswith('.0'):
|
||||
size = size[:-2]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import textwrap
|
||||
import textwrap, re
|
||||
|
||||
from PyQt4.QtGui import QStatusBar, QMovie, QLabel, QFrame, QHBoxLayout, QPixmap, \
|
||||
QVBoxLayout, QSizePolicy, QToolButton, QIcon
|
||||
@ -153,7 +153,7 @@ class StatusBar(QStatusBar):
|
||||
|
||||
def jobs(self):
|
||||
src = qstring_to_unicode(self.movie_button.jobs.text())
|
||||
return int(src.rpartition(':')[2].lstrip())
|
||||
return int(re.search(r'\d+', src).group())
|
||||
|
||||
def show_book_info(self):
|
||||
self.emit(SIGNAL('show_book_info()'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user