mercurial/templatefilters.py
changeset 16251 db68ee3289b6
parent 16235 eb39bbda167b
child 16360 e5788269741a
equal deleted inserted replaced
16250:684864d54903 16251:db68ee3289b6
   242     return "-rw-r--r--"
   242     return "-rw-r--r--"
   243 
   243 
   244 def person(author):
   244 def person(author):
   245     """:person: Any text. Returns the name before an email address,
   245     """:person: Any text. Returns the name before an email address,
   246     interpreting it as per RFC 5322.
   246     interpreting it as per RFC 5322.
       
   247 
       
   248     >>> person('foo@bar')
       
   249     'foo'
       
   250     >>> person('Foo Bar <foo@bar>')
       
   251     'Foo Bar'
       
   252     >>> person('"Foo Bar" <foo@bar>')
       
   253     'Foo Bar'
       
   254     >>> person('"Foo \"buz\" Bar" <foo@bar>')
       
   255     'Foo "buz" Bar'
       
   256     >>> # The following are invalid, but do exist in real-life
       
   257     ...
       
   258     >>> person('Foo "buz" Bar <foo@bar>')
       
   259     'Foo "buz" Bar'
       
   260     >>> person('"Foo Bar <foo@bar>')
       
   261     'Foo Bar'
   247     """
   262     """
   248     if not '@' in author:
   263     if not '@' in author:
   249         return author
   264         return author
   250     f = author.find('<')
   265     f = author.find('<')
   251     if f != -1:
   266     if f != -1: