From 674001781f51fcc5c6a9c62878aec922e0507546 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 11 Nov 2015 18:19:49 +0100 Subject: [PATCH] plugins XEP-0234, file: moved human file size conversion to file plugi --- src/plugins/plugin_misc_file.py | 3 +++ src/plugins/plugin_xep_0234.py | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/plugin_misc_file.py b/src/plugins/plugin_misc_file.py index 4d036b7b..b37b07ce 100644 --- a/src/plugins/plugin_misc_file.py +++ b/src/plugins/plugin_misc_file.py @@ -170,11 +170,14 @@ class FilePlugin(object): 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), diff --git a/src/plugins/plugin_xep_0234.py b/src/plugins/plugin_xep_0234.py index eaba7101..529dca0f 100644 --- a/src/plugins/plugin_xep_0234.py +++ b/src/plugins/plugin_xep_0234.py @@ -114,12 +114,9 @@ class XEP_0234(object): 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: