Commits

Antoine Pitrou committed e2447d9

Fix suffix and suffixes for names ending with a dot.

Comments (0)

Files changed (2)

     @property
     def suffix(self):
         """The final component's last suffix, if any."""
-        basename = self.name.strip('.')
+        basename = self.name
+        if basename.endswith('.'):
+            return ''
+        basename = basename.lstrip('.')
         i = basename.rfind('.')
         if i == -1:
             return ''
     @property
     def suffixes(self):
         """A list of the final component's suffixes, if any."""
-        basename = self.name.strip('.')
-        if basename == '' or basename == '.':
+        basename = self.name
+        if basename.endswith('.'):
             return []
+        basename = basename.lstrip('.')
         return ['.' + suffix for suffix in basename.split('.')[1:]]
 
     def relative(self):
         self.assertEqual(P('/a/.hg.rc').suffix, '.rc')
         self.assertEqual(P('a/b.tar.gz').suffix, '.gz')
         self.assertEqual(P('/a/b.tar.gz').suffix, '.gz')
-        self.assertEqual(P('a/Some name ending with a dot.').suffix, '')
-        self.assertEqual(P('/a/Some name ending with a dot.').suffix, '')
+        self.assertEqual(P('a/Some name. Ending with a dot.').suffix, '')
+        self.assertEqual(P('/a/Some name. Ending with a dot.').suffix, '')
 
     def test_suffixes_common(self):
         P = self.cls
         self.assertEqual(P('/a/.hg.rc').suffixes, ['.rc'])
         self.assertEqual(P('a/b.tar.gz').suffixes, ['.tar', '.gz'])
         self.assertEqual(P('/a/b.tar.gz').suffixes, ['.tar', '.gz'])
-        self.assertEqual(P('a/Some name ending with a dot.').suffixes, [])
-        self.assertEqual(P('/a/Some name ending with a dot.').suffixes, [])
+        self.assertEqual(P('a/Some name. Ending with a dot.').suffixes, [])
+        self.assertEqual(P('/a/Some name. Ending with a dot.').suffixes, [])
 
     def test_relative_common(self):
         P = self.cls
         self.assertEqual(P('c:/a/.hg.rc').suffix, '.rc')
         self.assertEqual(P('c:a/b.tar.gz').suffix, '.gz')
         self.assertEqual(P('c:/a/b.tar.gz').suffix, '.gz')
-        self.assertEqual(P('c:a/Some name ending with a dot.').suffix, '')
-        self.assertEqual(P('c:/a/Some name ending with a dot.').suffix, '')
+        self.assertEqual(P('c:a/Some name. Ending with a dot.').suffix, '')
+        self.assertEqual(P('c:/a/Some name. Ending with a dot.').suffix, '')
         self.assertEqual(P('//My.py/Share.php').suffix, '')
         self.assertEqual(P('//My.py/Share.php/a/b').suffix, '')
 
         self.assertEqual(P('c:/a/b.tar.gz').suffixes, ['.tar', '.gz'])
         self.assertEqual(P('//My.py/Share.php').suffixes, [])
         self.assertEqual(P('//My.py/Share.php/a/b').suffixes, [])
-        self.assertEqual(P('c:a/Some name ending with a dot.').suffixes, [])
-        self.assertEqual(P('c:/a/Some name ending with a dot.').suffixes, [])
+        self.assertEqual(P('c:a/Some name. Ending with a dot.').suffixes, [])
+        self.assertEqual(P('c:/a/Some name. Ending with a dot.').suffixes, [])
 
     def test_relative(self):
         P = self.cls