@@ -46,45 +46,6 @@ def unindent(value):
4646 """Remove indentation from string."""
4747 return re .sub ("\n +" , "\n " , value )
4848
49- @register .filter (name = 'parse_email_list' )
50- def parse_email_list (value ):
51- """
52- Parse a list of comma-seperated email addresses into
53- a list of mailto: links.
54-
55- Splitting a string of email addresses should return a list:
56-
57- >>> force_str(parse_email_list('joe@example.org, fred@example.com'))
58- '<a href="mailto:joe@example.org">joe@example.org</a>, <a href="mailto:fred@example.com">fred@example.com</a>'
59-
60- Parsing a non-string should return the input value, rather than fail:
61-
62- >>> [ force_str(e) for e in parse_email_list(['joe@example.org', 'fred@example.com']) ]
63- ['joe@example.org', 'fred@example.com']
64-
65- Null input values should pass through silently:
66-
67- >>> force_str(parse_email_list(''))
68- ''
69-
70- >>> parse_email_list(None)
71-
72-
73- """
74- if value and isinstance (value , str ): # testing for 'value' being true isn't necessary; it's a fast-out route
75- addrs = re .split (", ?" , value )
76- ret = []
77- for addr in addrs :
78- (name , email ) = parseaddr (addr )
79- if not (name ):
80- name = email
81- ret .append ('<a href="mailto:%s">%s</a>' % ( email .replace ('&' , '&' ), escape (name ) ))
82- return mark_safe (", " .join (ret ))
83- elif value and isinstance (value , bytes ):
84- log .assertion ('isinstance(value, str)' )
85- else :
86- return value
87-
8849@register .filter
8950def strip_email (value ):
9051 """Get rid of email part of name/email string like 'Some Name <email@example.com>'."""
0 commit comments