summaryrefslogtreecommitdiff
path: root/alot/helper.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-16 10:31:16 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-16 10:31:16 +0100
commitf0b24807e42ad95395a3885775cb1ee3322571a6 (patch)
treee5340c93471d8eb7a27f4810d57adb86af64b110 /alot/helper.py
parent44bb1b83488ea6acf4b0f9f1deb6384c7dfa98fa (diff)
helper: rewrite mailto_to_envelope/parse_mailto to Envelope.from_mailto
Diffstat (limited to 'alot/helper.py')
-rw-r--r--alot/helper.py41
1 files changed, 0 insertions, 41 deletions
diff --git a/alot/helper.py b/alot/helper.py
index eb6c1969..b7c4f5a1 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -439,47 +439,6 @@ def parse_mailcap_nametemplate(tmplate='%s'):
template_suffix = tmplate
return (template_prefix, template_suffix)
-
-def parse_mailto(mailto_str):
- """
- Interpret mailto-string
-
- :param mailto_str: the string to interpret. Must conform to :rfc:2368.
- :type mailto_str: str
- :return: the header fields and the body found in the mailto link as a tuple
- of length two
- :rtype: tuple(dict(str->list(str)), str)
- """
- if mailto_str.startswith('mailto:'):
- import urllib.parse
- to_str, parms_str = mailto_str[7:].partition('?')[::2]
- headers = {}
- body = ''
-
- to = urllib.parse.unquote(to_str)
- if to:
- headers['To'] = [to]
-
- for s in parms_str.split('&'):
- key, value = s.partition('=')[::2]
- key = key.capitalize()
- if key == 'Body':
- body = urllib.parse.unquote(value)
- elif value:
- headers[key] = [urllib.parse.unquote(value)]
- return (headers, body)
- else:
- return (None, None)
-
-
-def mailto_to_envelope(mailto_str):
- """
- Interpret mailto-string into a :class:`alot.db.envelope.Envelope`
- """
- from alot.db.envelope import Envelope
- headers, body = parse_mailto(mailto_str)
- return Envelope(bodytext=body, headers=headers)
-
def get_xdg_env(env_name, fallback):
""" Used for XDG_* env variables to return fallback if unset *or* empty """
env = os.environ.get(env_name)