summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2011-10-07 17:48:26 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2011-10-07 17:48:26 +0200
commitfc0536fb37a58d09eb8b40ccf1580369e35d822b (patch)
treecb418c7f5aa883fe7b8480be459a3b277dd31566 /alot
parent5c21dc0335881f53a54c0cd40a2d7ad650afd3b6 (diff)
Use helper.humanize_size() to display the attachment size
Diffstat (limited to 'alot')
-rw-r--r--alot/message.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/alot/message.py b/alot/message.py
index 4f473172..704f5f47 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -290,7 +290,7 @@ class Attachment(object):
def __str__(self):
return '%s:%s (%s)' % (self.get_content_type(),
self.get_filename(),
- self.get_size())
+ helper.humanize_size(self.get_size()))
def get_filename(self):
"""return the filename, extracted from content-disposition header"""
@@ -305,14 +305,9 @@ class Attachment(object):
if ctype == 'octet/stream' and self.get_filename():
ctype, enc = mimetypes.guess_type(self.get_filename())
return ctype
-
def get_size(self):
- """returns attachments size as human-readable string"""
- size_in_kbyte = len(self.part.get_payload()) / 1024
- if size_in_kbyte > 1024:
- return "%.1fM" % (size_in_kbyte / 1024.0)
- else:
- return "%dK" % size_in_kbyte
+ """returns attachments size in bytes"""
+ return len(self.part.get_payload())
def save(self, path):
"""save the attachment to disk. Uses self.get_filename