Show More
@@ -131,6 +131,29 b' def email(author):' | |||
|
131 | 131 | r = None |
|
132 | 132 | return author[author.find('<') + 1:r] |
|
133 | 133 | |
|
134 | _correctauthorformat = remod.compile(br'^[^<]+\s\<[^<>]+@[^<>]+\>$') | |
|
135 | ||
|
136 | def isauthorwellformed(author): | |
|
137 | '''Return True if the author field is well formed | |
|
138 | (ie "Contributor Name <contrib@email.dom>") | |
|
139 | ||
|
140 | >>> isauthorwellformed(b'Good Author <good@author.com>') | |
|
141 | True | |
|
142 | >>> isauthorwellformed(b'Author <good@author.com>') | |
|
143 | True | |
|
144 | >>> isauthorwellformed(b'Bad Author') | |
|
145 | False | |
|
146 | >>> isauthorwellformed(b'Bad Author <author@author.com') | |
|
147 | False | |
|
148 | >>> isauthorwellformed(b'Bad Author author@author.com') | |
|
149 | False | |
|
150 | >>> isauthorwellformed(b'<author@author.com>') | |
|
151 | False | |
|
152 | >>> isauthorwellformed(b'Bad Author <author>') | |
|
153 | False | |
|
154 | ''' | |
|
155 | return _correctauthorformat.match(author) is not None | |
|
156 | ||
|
134 | 157 | def ellipsis(text, maxlength=400): |
|
135 | 158 | """Trim string to at most maxlength (default: 400) columns in display.""" |
|
136 | 159 | return encoding.trim(text, maxlength, ellipsis='...') |
General Comments 0
You need to be logged in to leave comments.
Login now