From e81d92555e88dbf275b465a306e8461e9f3991aa Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Sun, 24 Jul 2011 15:18:55 +0200 Subject: [PATCH] Improve splitting of Uploaders list. Signed-off-by: Torsten Werner --- daklib/dbconn.py | 3 ++- tests/test_split_uploaders.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/daklib/dbconn.py b/daklib/dbconn.py index f314b3f7..64437561 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2640,7 +2640,8 @@ def split_uploaders(uploaders_list): Split the Uploaders field into the individual uploaders and yield each of them. Beware: email addresses might contain commas. ''' - for uploader in uploaders_list.replace(">, ", ">\t").split("\t"): + import re + for uploader in re.sub(">[ ]*,", ">\t", uploaders_list).split("\t"): yield uploader.strip() @session_wrapper diff --git a/tests/test_split_uploaders.py b/tests/test_split_uploaders.py index 062fd357..fe6bd91e 100755 --- a/tests/test_split_uploaders.py +++ b/tests/test_split_uploaders.py @@ -11,6 +11,12 @@ class SplitUploadersTestCase(DakTestCase): expected = ['"A, B" ', 'D E '] l = list(split_uploaders('"A, B" , D E ')) self.assertEqual(expected, l) + l = list(split_uploaders('"A, B" , D E ')) + self.assertEqual(expected, l) + l = list(split_uploaders('"A, B" ,D E ')) + self.assertEqual(expected, l) + l = list(split_uploaders('"A, B" ,D E ')) + self.assertEqual(expected, l) if __name__ == '__main__': unittest.main() -- 2.39.5