Currently only e-mails of the form "Name <email>" are accepted by
stgit import etc, however some people use "email (Name)". Accept this
alternate form.
Signed-off-by: Sam Vilain <sam@vilain.net>
def name_email(address):
"""Return a tuple consisting of the name and email parsed from a
def name_email(address):
"""Return a tuple consisting of the name and email parsed from a
- standard 'name <email>' string
+ standard 'name <email>' or 'email (name)' string
"""
address = re.sub('[\\\\"]', '\\\\\g<0>', address)
str_list = re.findall('^(.*)\s*<(.*)>\s*$', address)
if not str_list:
"""
address = re.sub('[\\\\"]', '\\\\\g<0>', address)
str_list = re.findall('^(.*)\s*<(.*)>\s*$', address)
if not str_list:
- raise CmdException, 'Incorrect "name <email>" string: %s' % address
+ str_list = re.findall('^(.*)\s*\((.*)\)\s*$', address)
+ if not str_list:
+ raise CmdException, 'Incorrect "name <email>"/"email (name)" string: %s' % address
+ return ( str_list[0][1], str_list[0][0] )