From: Torsten Werner Date: Sun, 24 Jul 2011 13:18:55 +0000 (+0200) Subject: Improve splitting of Uploaders list. X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e81d92555e88dbf275b465a306e8461e9f3991aa;p=dak.git Improve splitting of Uploaders list. Signed-off-by: Torsten Werner --- 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()