Mercurial > libervia-backend
diff sat/plugins/plugin_misc_file.py @ 3524:584379473925
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 May 2021 15:37:33 +0200 |
parents | be6d91572633 |
children | 849374e59178 |
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_file.py Wed May 05 15:37:21 2021 +0200 +++ b/sat/plugins/plugin_misc_file.py Wed May 05 15:37:33 2021 +0200 @@ -29,6 +29,7 @@ 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 @@ 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),