Format donwload string so it jumps less
This commit is contained in:
parent
c9f60caa12
commit
cd7d6b87f9
@ -89,18 +89,18 @@ class DownloadItem(QObject):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Get the download as a string.
|
"""Get the download as a string.
|
||||||
|
|
||||||
Example: foo.pdf [699.2K/s|0.34|16%|4.253/25.124]
|
Example: foo.pdf [699.2kB/s|0.34|16%|4.253/25.124]
|
||||||
"""
|
"""
|
||||||
perc = 0 if self.percentage is None else round(self.percentage)
|
perc = 0 if self.percentage is None else round(self.percentage)
|
||||||
remaining = (format_seconds(self.remaining_time)
|
remaining = (format_seconds(self.remaining_time)
|
||||||
if self.remaining_time is not None else
|
if self.remaining_time is not None else '?')
|
||||||
'?')
|
|
||||||
speed = format_size(self.speed, suffix='B/s')
|
speed = format_size(self.speed, suffix='B/s')
|
||||||
down = format_size(self.bytes_done, suffix='B')
|
down = format_size(self.bytes_done, suffix='B')
|
||||||
total = format_size(self.bytes_total, suffix='B')
|
total = format_size(self.bytes_total, suffix='B')
|
||||||
return '{name} [{speed}|{remaining}|{perc: 2}%|{down}/{total}]'.format(
|
return ('{name} [{speed:>10}|{remaining:>5}|{perc:>2}%|'
|
||||||
name=self.basename, speed=speed, remaining=remaining, perc=perc,
|
'{down}/{total}]'.format(name=self.basename, speed=speed,
|
||||||
down=down, total=total)
|
remaining=remaining, perc=perc,
|
||||||
|
down=down, total=total))
|
||||||
|
|
||||||
def _die(self, msg):
|
def _die(self, msg):
|
||||||
"""Abort the download and emit an error."""
|
"""Abort the download and emit an error."""
|
||||||
|
Loading…
Reference in New Issue
Block a user