diff --git a/awesome-wm-widgets/email-widget/read_unread_emails.py b/awesome-wm-widgets/email-widget/read_unread_emails.py index c9c5857..acf6a9a 100755 --- a/awesome-wm-widgets/email-widget/read_unread_emails.py +++ b/awesome-wm-widgets/email-widget/read_unread_emails.py @@ -5,7 +5,7 @@ import email.header import datetime def decode_mime_words(s): - return u''.join( + return ''.join( word.decode(encoding or 'utf8') if isinstance(word, bytes) else word for word, encoding in email.header.decode_header(s)) @@ -27,14 +27,14 @@ def process_mailbox(mailbox, to = None): print('To: ', to) print('From:', msg['From']) - decode = email.header.decode_header(msg['Subject']) - subject = decode_mime_words(decode) + subject = decode_mime_words(msg['Subject']) - print('Subject: %s' % subject) + print('Subject: %s' % decode_mime_words(msg['Subject'])) date_tuple = email.utils.parsedate_tz(msg['Date']) if date_tuple: local_date = datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple)) print("Local Date:", local_date.strftime("%a, %d %b %Y %H:%M:%S")) + print() # with code below you can process text of email # if msg.is_multipart(): # for payload in msg.get_payload():