blob: 99684afd031fc70b549154c959f3d6ffae6aac10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# encoding=utf-8
# Copyright (C) 2011-2012 Patrick Totzke <patricktotzke@gmail.com>
# Copyright © 2017 Dylan Baker <dylan@pnwbakers.com>
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
import os
import email
import email.charset as charset
import email.policy
import email.utils
import logging
from ..settings.const import settings
charset.add_charset('utf-8', charset.QP, charset.QP, 'utf-8')
def formataddr(pair):
""" this is the inverse of email.utils.parseaddr:
other than email.utils.formataddr, this
- *will not* re-encode unicode strings, and
- *will* re-introduce quotes around real names containing commas
"""
name, address = pair
if not name:
return address
elif ',' in name:
name = "\"" + name + "\""
return "{0} <{1}>".format(name, address)
|