Mercurial > hg
comparison mercurial/templatefilters.py @ 13951:7a6a8a069aac
templatefilters: improve person() for john.doe@example.com
BEFORE: person('john.doe@example.com') -> 'john'
AFTER: person('john.doe@example.com') -> 'john doe'
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sun, 17 Apr 2011 21:34:25 +0200 |
parents | c49cddce0a81 |
children | 1f46be4689ed |
comparison
equal
deleted
inserted
replaced
13950:14d0553bd48b | 13951:7a6a8a069aac |
---|---|
243 def person(author): | 243 def person(author): |
244 """:person: Any text. Returns the text before an email address.""" | 244 """:person: Any text. Returns the text before an email address.""" |
245 if not '@' in author: | 245 if not '@' in author: |
246 return author | 246 return author |
247 f = author.find('<') | 247 f = author.find('<') |
248 if f == -1: | 248 if f != -1: |
249 return util.shortuser(author) | 249 return author[:f].rstrip() |
250 return author[:f].rstrip() | 250 f = author.find('@') |
251 return author[:f].replace('.', ' ') | |
251 | 252 |
252 def rfc3339date(text): | 253 def rfc3339date(text): |
253 """:rfc3339date: Date. Returns a date using the Internet date format | 254 """:rfc3339date: Date. Returns a date using the Internet date format |
254 specified in RFC 3339: "2009-08-18T13:00:13+02:00". | 255 specified in RFC 3339: "2009-08-18T13:00:13+02:00". |
255 """ | 256 """ |