From 74c23ac08dda58f08b78f195151949525087f431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarek=20Ziad=C3=A9?= Date: Mon, 17 Aug 2009 21:35:46 +0000 Subject: Merged revisions 74493 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74493 | tarek.ziade | 2009-08-17 23:28:34 +0200 (Mon, 17 Aug 2009) | 1 line fixed how fnmatch.translate is used (since it has changed in r74475 for #6665). Now the code is not harcoding the usage of $ anymore ........ --- Lib/distutils/filelist.py | 4 +++- Lib/distutils/tests/test_filelist.py | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py index 58a2bfb..06a8da9 100644 --- a/Lib/distutils/filelist.py +++ b/Lib/distutils/filelist.py @@ -312,7 +312,9 @@ def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0): pattern_re = '' if prefix is not None: - prefix_re = (glob_to_re(prefix))[0:-1] # ditch trailing $ + # ditch end of pattern character + empty_pattern = glob_to_re('') + prefix_re = (glob_to_re(prefix))[:-len(empty_pattern)] pattern_re = "^" + os.path.join(prefix_re, ".*" + pattern_re) else: # no prefix -- respect anchor flag if anchor: diff --git a/Lib/distutils/tests/test_filelist.py b/Lib/distutils/tests/test_filelist.py index 86db557..1faccfa 100644 --- a/Lib/distutils/tests/test_filelist.py +++ b/Lib/distutils/tests/test_filelist.py @@ -6,15 +6,15 @@ class FileListTestCase(unittest.TestCase): def test_glob_to_re(self): # simple cases - self.assertEquals(glob_to_re('foo*'), 'foo[^/]*$') - self.assertEquals(glob_to_re('foo?'), 'foo[^/]$') - self.assertEquals(glob_to_re('foo??'), 'foo[^/][^/]$') + self.assertEquals(glob_to_re('foo*'), 'foo[^/]*\\Z(?ms)') + self.assertEquals(glob_to_re('foo?'), 'foo[^/]\\Z(?ms)') + self.assertEquals(glob_to_re('foo??'), 'foo[^/][^/]\\Z(?ms)') # special cases - self.assertEquals(glob_to_re(r'foo\\*'), r'foo\\\\[^/]*$') - self.assertEquals(glob_to_re(r'foo\\\*'), r'foo\\\\\\[^/]*$') - self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]$') - self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]$') + self.assertEquals(glob_to_re(r'foo\\*'), r'foo\\\\[^/]*\Z(?ms)') + self.assertEquals(glob_to_re(r'foo\\\*'), r'foo\\\\\\[^/]*\Z(?ms)') + self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]\Z(?ms)') + self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]\Z(?ms)') def test_suite(): return unittest.makeSuite(FileListTestCase) -- cgit v0.12