Mercurial > libervia-backend
changeset 1575:833bdb227b16
plugins XEP-0234, file: moved human file size conversion to file plugi
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 11 Nov 2015 18:19:49 +0100 (2015-11-11) |
parents | babd97d80049 |
children | d5f59ba166fe |
files | src/plugins/plugin_misc_file.py src/plugins/plugin_xep_0234.py |
diffstat | 2 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_file.py Wed Nov 11 18:19:47 2015 +0100 +++ b/src/plugins/plugin_misc_file.py Wed Nov 11 18:19:49 2015 +0100 @@ -170,11 +170,14 @@ It may content the key used in CONFIRM constant It *MUST NOT* contain the "peer" key "file_path" will be added to this dict once destination selected + "size_human" will also be added with human readable file size @param profile: %(doc_profile)s return (defer.Deferred): True if transfer is accepted """ filename = file_data['name'] assert filename and not '/' in filename + # human readable size + file_data['size_human'] = u'{:.6n} Mio'.format(float(file_data['size'])/(1024**2)) d = xml_tools.deferDialog(self.host, _(CONFIRM).format(peer=peer_jid.full(), **file_data), _(CONFIRM_TITLE),
--- a/src/plugins/plugin_xep_0234.py Wed Nov 11 18:19:47 2015 +0100 +++ b/src/plugins/plugin_xep_0234.py Wed Nov 11 18:19:49 2015 +0100 @@ -114,12 +114,9 @@ file_data[name] = '' try: - size = file_data['size'] = int(file_data['size']) + file_data['size'] = int(file_data['size']) except ValueError: raise failure.Failure(exceptions.DataError) - else: - # human readable size - file_data['size_human'] = u'{:.6n} Mio'.format(float(size)/(1024**2)) name = file_data['name'] if '/' in name or '\\' in name: