tools (common/utils): new methods to parse and generate file size with symbols:
- `parseSize` lets parse a size which can be either a int, or a string with a symbol like `Mio` - `getSizeMultiplier` returns a tuple of size with it's multiplier symbol - `getHumanSize` returns a string with size and adapted multiplier.
This commit is contained in:
parent
06054ceeaf
commit
4e36667134
1 changed files with 88 additions and 12 deletions
|
|
@ -29,6 +29,7 @@ from sat.core import exceptions
|
|||
from sat.tools import xml_tools
|
||||
from sat.tools import stream
|
||||
from sat.tools import utils
|
||||
from sat.tools.common import utils as common_utils
|
||||
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
|
@ -321,9 +322,7 @@ class FilePlugin:
|
|||
assert filename and not "/" in filename
|
||||
assert PROGRESS_ID_KEY in file_data
|
||||
# human readable size
|
||||
file_data["size_human"] = "{:.6n} Mio".format(
|
||||
float(file_data["size"]) / (1024 ** 2)
|
||||
)
|
||||
file_data["size_human"] = common_utils.getHumanSize(file_data["size"])
|
||||
d = xml_tools.deferDialog(
|
||||
self.host,
|
||||
_(CONFIRM).format(peer=peer_jid.full(), **file_data),
|
||||
|
|
|
|||
Loading…
Reference in a new issue