From f0b24807e42ad95395a3885775cb1ee3322571a6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Jan 2021 10:31:16 +0100 Subject: helper: rewrite mailto_to_envelope/parse_mailto to Envelope.from_mailto --- alot/helper.py | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'alot/helper.py') 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) -- cgit v1.2.3