summaryrefslogtreecommitdiff
path: root/alot/commands/thread.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/commands/thread.py')
-rw-r--r--alot/commands/thread.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 17fc6c3b..a6380ac9 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -14,7 +14,8 @@ from email.utils import getaddresses, parseaddr, formataddr
from email.message import Message
from twisted.internet.defer import inlineCallbacks
-from io import BytesIO
+import urwid
+from io import StringIO
from . import Command, registerCommand
from .globals import ExternalCommand
@@ -71,12 +72,12 @@ def determine_sender(mail, action='reply'):
# pick the most important account that has an address in candidates
# and use that accounts realname and the address found here
for account in my_accounts:
- acc_addresses = [re.escape(unicode(a)) for a in account.get_addresses()]
+ acc_addresses = [re.escape(str(a)) for a in account.get_addresses()]
if account.alias_regexp is not None:
acc_addresses.append(account.alias_regexp)
for alias in acc_addresses:
regex = re.compile(
- u'^' + unicode(alias) + u'$',
+ u'^' + str(alias) + u'$',
flags=re.IGNORECASE if not account.address.case_sensitive else 0)
for seen_name, seen_address in candidate_addresses:
if regex.match(seen_address):
@@ -93,7 +94,7 @@ def determine_sender(mail, action='reply'):
logging.debug('using realname: "%s"', realname)
logging.debug('using address: %s', address)
- from_value = formataddr((realname, address))
+ from_value = formataddr((realname, str(address)))
return from_value, account
# revert to default account if nothing found
@@ -103,7 +104,7 @@ def determine_sender(mail, action='reply'):
logging.debug('using realname: "%s"', realname)
logging.debug('using address: %s', address)
- from_value = formataddr((realname, address))
+ from_value = formataddr((realname, str(address)))
return from_value, account
@@ -301,7 +302,7 @@ class ReplyCommand(Command):
new_value = []
for name, address in getaddresses(value):
if address not in my_addresses:
- new_value.append(formataddr((name, address)))
+ new_value.append(formataddr((name, str(address))))
return new_value
@staticmethod
@@ -313,7 +314,7 @@ class ReplyCommand(Command):
res = dict()
for name, address in getaddresses(recipients):
res[address] = name
- urecipients = [formataddr((n, a)) for a, n in res.iteritems()]
+ urecipients = [formataddr((n, str(a))) for a, n in res.items()]
return sorted(urecipients)
@@ -689,7 +690,7 @@ class PipeCommand(Command):
:type field_key: str
"""
Command.__init__(self, **kwargs)
- if isinstance(cmd, unicode):
+ if isinstance(cmd, str):
cmd = split_commandstring(cmd)
self.cmd = cmd
self.whole_thread = all
@@ -759,13 +760,14 @@ class PipeCommand(Command):
# do the monkey
for mail in pipestrings:
+ encoded_mail = mail.encode(urwid.util.detected_encoding)
if self.background:
logging.debug('call in background: %s', self.cmd)
proc = subprocess.Popen(self.cmd,
shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- out, err = proc.communicate(mail)
+ out, err = proc.communicate(encoded_mail)
if self.notify_stdout:
ui.notify(out)
else:
@@ -777,7 +779,7 @@ class PipeCommand(Command):
stdin=subprocess.PIPE,
# stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- out, err = proc.communicate(mail)
+ out, err = proc.communicate(encoded_mail)
if err:
ui.notify(err, priority='error')
return
@@ -993,7 +995,7 @@ class OpenAttachmentCommand(Command):
def afterwards():
os.unlink(tempfile_name)
else:
- handler_stdin = BytesIO()
+ handler_stdin = StringIO()
self.attachment.write(handler_stdin)
# create handler command list