Commits

Antoine Pitrou committed 8508f6e

Rename the "ext" property into "suffix"

  • Participants
  • Parent commits f6df458
  • Branches pep428

Comments (0)

Files changed (2)

         return parts[-1]
 
     @property
-    def ext(self):
-        """The final component's extension, if any."""
+    def suffix(self):
+        """The final component's final suffix, if any."""
         basename = self.name
         if basename == '' or basename == '.':
             return ''
-        i = basename.find('.')
+        i = basename.rfind('.')
         if i == -1:
             return ''
         return basename[i:]
         self.assertEqual(P('a/b.py').name, 'b.py')
         self.assertEqual(P('/a/b.py').name, 'b.py')
 
-    def test_ext_common(self):
+    def test_suffix_common(self):
         P = self.cls
-        self.assertEqual(P('').ext, '')
-        self.assertEqual(P('.').ext, '')
-        self.assertEqual(P('/').ext, '')
-        self.assertEqual(P('a/b').ext, '')
-        self.assertEqual(P('/a/b').ext, '')
-        self.assertEqual(P('/a/b/.').ext, '')
-        self.assertEqual(P('a/b.py').ext, '.py')
-        self.assertEqual(P('/a/b.py').ext, '.py')
-        self.assertEqual(P('a/b.tar.gz').ext, '.tar.gz')
-        self.assertEqual(P('/a/b.tar.gz').ext, '.tar.gz')
+        self.assertEqual(P('').suffix, '')
+        self.assertEqual(P('.').suffix, '')
+        self.assertEqual(P('/').suffix, '')
+        self.assertEqual(P('a/b').suffix, '')
+        self.assertEqual(P('/a/b').suffix, '')
+        self.assertEqual(P('/a/b/.').suffix, '')
+        self.assertEqual(P('a/b.py').suffix, '.py')
+        self.assertEqual(P('/a/b.py').suffix, '.py')
+        self.assertEqual(P('a/b.tar.gz').suffix, '.gz')
+        self.assertEqual(P('/a/b.tar.gz').suffix, '.gz')
 
     def test_relative_common(self):
         P = self.cls
         self.assertEqual(P('//My.py/Share.php').name, '')
         self.assertEqual(P('//My.py/Share.php/a/b').name, 'b')
 
-    def test_ext(self):
+    def test_suffix(self):
         P = self.cls
-        self.assertEqual(P('c:').ext, '')
-        self.assertEqual(P('c:/').ext, '')
-        self.assertEqual(P('c:a/b').ext, '')
-        self.assertEqual(P('c:/a/b').ext, '')
-        self.assertEqual(P('c:a/b.py').ext, '.py')
-        self.assertEqual(P('c:/a/b.py').ext, '.py')
-        self.assertEqual(P('c:a/b.tar.gz').ext, '.tar.gz')
-        self.assertEqual(P('c:/a/b.tar.gz').ext, '.tar.gz')
-        self.assertEqual(P('//My.py/Share.php').ext, '')
-        self.assertEqual(P('//My.py/Share.php/a/b').ext, '')
+        self.assertEqual(P('c:').suffix, '')
+        self.assertEqual(P('c:/').suffix, '')
+        self.assertEqual(P('c:a/b').suffix, '')
+        self.assertEqual(P('c:/a/b').suffix, '')
+        self.assertEqual(P('c:a/b.py').suffix, '.py')
+        self.assertEqual(P('c:/a/b.py').suffix, '.py')
+        self.assertEqual(P('c:a/b.tar.gz').suffix, '.gz')
+        self.assertEqual(P('c:/a/b.tar.gz').suffix, '.gz')
+        self.assertEqual(P('//My.py/Share.php').suffix, '')
+        self.assertEqual(P('//My.py/Share.php/a/b').suffix, '')
 
     def test_relative(self):
         P = self.cls