comparison mercurial/util.py @ 16360:e5788269741a

templates/filters: extracting the user portion of an email address Currently, the 'user' filter is using util.shortuser(text) (which clearly doesn't extract only the user portion of an email address, even though the help text says it does). The new 'emailuser' filter uses the new util.emailuser(text) function which, instead, does exactly that. The help text on the 'user' filter has been modified accordingly.
author Matteo Capobianco <m.capobianco@gmail.com>
date Wed, 28 Mar 2012 16:06:20 +0200
parents 3bcfea777efc
children f5dd179bfa4a
comparison
equal deleted inserted replaced
16358:d23197e08d05 16360:e5788269741a
1123 f = user.find('.') 1123 f = user.find('.')
1124 if f >= 0: 1124 if f >= 0:
1125 user = user[:f] 1125 user = user[:f]
1126 return user 1126 return user
1127 1127
1128 def emailuser(user):
1129 """Return the user portion of an email address."""
1130 f = user.find('@')
1131 if f >= 0:
1132 user = user[:f]
1133 f = user.find('<')
1134 if f >= 0:
1135 user = user[f + 1:]
1136 return user
1137
1128 def email(author): 1138 def email(author):
1129 '''get email of author.''' 1139 '''get email of author.'''
1130 r = author.find('>') 1140 r = author.find('>')
1131 if r == -1: 1141 if r == -1:
1132 r = None 1142 r = None