equal
deleted
inserted
replaced
129 r = author.find('>') |
129 r = author.find('>') |
130 if r == -1: |
130 if r == -1: |
131 r = None |
131 r = None |
132 return author[author.find('<') + 1:r] |
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 def ellipsis(text, maxlength=400): |
157 def ellipsis(text, maxlength=400): |
135 """Trim string to at most maxlength (default: 400) columns in display.""" |
158 """Trim string to at most maxlength (default: 400) columns in display.""" |
136 return encoding.trim(text, maxlength, ellipsis='...') |
159 return encoding.trim(text, maxlength, ellipsis='...') |
137 |
160 |
138 def escapestr(s): |
161 def escapestr(s): |