From: Sam Vilain Date: Thu, 9 Mar 2006 05:29:58 +0000 (+1300) Subject: common: parse 'email (name)' correctly X-Git-Tag: v0.14.3~527 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/df992d5a864942d572f0235cf9bf124050f790a8 common: parse 'email (name)' correctly Currently only e-mails of the form "Name " are accepted by stgit import etc, however some people use "email (Name)". Accept this alternate form. Signed-off-by: Sam Vilain --- diff --git a/stgit/commands/common.py b/stgit/commands/common.py index 2985379..4bfa4dd 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -175,12 +175,15 @@ def push_patches(patches, check_merged = False): def name_email(address): """Return a tuple consisting of the name and email parsed from a - standard 'name ' string + standard 'name ' or 'email (name)' string """ address = re.sub('[\\\\"]', '\\\\\g<0>', address) str_list = re.findall('^(.*)\s*<(.*)>\s*$', address) if not str_list: - raise CmdException, 'Incorrect "name " string: %s' % address + str_list = re.findall('^(.*)\s*\((.*)\)\s*$', address) + if not str_list: + raise CmdException, 'Incorrect "name "/"email (name)" string: %s' % address + return ( str_list[0][1], str_list[0][0] ) return str_list[0]