summaryrefslogtreecommitdiff
path: root/alot/helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/helper.py')
-rw-r--r--alot/helper.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/alot/helper.py b/alot/helper.py
index 8d596994..f94e03f2 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -4,6 +4,7 @@ from datetime import datetime
from collections import deque
from string import strip
import subprocess
+import shlex
import email
import os
import re
@@ -21,6 +22,16 @@ import logging
import tempfile
+def split_commandstring(cmdstring):
+ """
+ split command string into a list of strings to pass on to subprocess.Popen
+ and the like. This simply calls shlex.split but works also with unicode
+ bytestrings.
+ """
+ if isinstance(cmdstring, unicode):
+ cmdstring = cmdstring.encode('utf-8', errors='ignore')
+ return shlex.split(cmdstring)
+
def safely_get(clb, E, on_error=''):
"""
returns result of :func:`clb` and falls back to `on_error`