Commits

Antoine Pitrou committed 58b728f

s/NTPath/WindowsPath/

  • Participants
  • Parent commits 8ec3c42
  • Branches pep428

Comments (0)

Files changed (3)

File docs/index.rst

       >>> PurePosixPath('/etc')
       PurePosixPath('/etc')
 
-.. class:: PureNTPath
+.. class:: PureWindowsPath
 
    A subclass of :class:`PurePath`, this path flavour represents Windows
    filesystem paths::
 
-      >>> PureNTPath('c:/Program Files/')
-      PureNTPath('c:\\Program Files')
+      >>> PureWindowsPath('c:/Program Files/')
+      PureWindowsPath('c:\\Program Files')
 
 .. class:: PurePath
 
    A generic class that represents the system's path flavour (instantiating
-   it creates either a :class:`PurePosixPath` or a :class:`PureNTPath`)::
+   it creates either a :class:`PurePosixPath` or a :class:`PureWindowsPath`)::
 
       >>> PurePath('setup.py')
       PurePosixPath('setup.py')
 
    >>> PurePath('/etc', '/usr', 'lib64')
    PurePosixPath('/usr/lib64')
-   >>> PureNTPath('c:/Windows', 'd:bar')
-   PureNTPath('d:bar')
+   >>> PureWindowsPath('c:/Windows', 'd:bar')
+   PureWindowsPath('d:bar')
 
 However, in a Windows path, changing the local root doesn't discard the
 previous drive setting::
 
-   >>> PureNTPath('c:/Windows', '/Program Files')
-   PureNTPath('c:\\Program Files')
+   >>> PureWindowsPath('c:/Windows', '/Program Files')
+   PureWindowsPath('c:\\Program Files')
 
 Spurious slashes and single dots are collapsed, but double dots (``'..'``)
 are not, since this would change the meaning of a path in the face of
 
    >>> PurePosixPath('foo') == PurePosixPath('FOO')
    False
-   >>> PureNTPath('foo') == PureNTPath('FOO')
+   >>> PureWindowsPath('foo') == PureWindowsPath('FOO')
    True
-   >>> PureNTPath('FOO') in { PureNTPath('foo') }
+   >>> PureWindowsPath('FOO') in { PureWindowsPath('foo') }
    True
-   >>> PureNTPath('C:') < PureNTPath('d:')
+   >>> PureWindowsPath('C:') < PureWindowsPath('d:')
    True
 
 Paths of a different flavour compare unequal and cannot be ordered::
 
-   >>> PureNTPath('foo') == PurePosixPath('foo')
+   >>> PureWindowsPath('foo') == PurePosixPath('foo')
    False
-   >>> PureNTPath('foo') < PurePosixPath('foo')
+   >>> PureWindowsPath('foo') < PurePosixPath('foo')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
-   TypeError: unorderable types: PureNTPath() < PurePosixPath()
+   TypeError: unorderable types: PureWindowsPath() < PurePosixPath()
 
 
 Operators
       >>> p.parts[:-1]
       PurePosixPath('/usr/bin')
 
-      >>> p = PureNTPath('c:/Program Files/PSF')
+      >>> p = PureWindowsPath('c:/Program Files/PSF')
       >>> p.parts[0]
       'c:\\'
       >>> p.parts[1:]
-      PureNTPath('Program Files\\PSF')
+      PureWindowsPath('Program Files\\PSF')
 
    (note how the drive and local root are regrouped in a single part)
 
 
    A string representing the drive letter or name, if any::
 
-      >>> PureNTPath('c:/Program Files/').drive
+      >>> PureWindowsPath('c:/Program Files/').drive
       'c:'
-      >>> PureNTPath('/Program Files/').drive
+      >>> PureWindowsPath('/Program Files/').drive
       ''
       >>> PurePosixPath('/etc').drive
       ''
 
    UNC shares are also considered drives::
 
-      >>> PureNTPath('//some/share/foo.txt').drive
+      >>> PureWindowsPath('//some/share/foo.txt').drive
       '\\\\some\\share'
 
 .. data:: PurePath.root
 
    A string representing the (local or global) root, if any::
 
-      >>> PureNTPath('c:/Program Files/').root
+      >>> PureWindowsPath('c:/Program Files/').root
       '\\'
-      >>> PureNTPath('c:Program Files/').root
+      >>> PureWindowsPath('c:Program Files/').root
       ''
       >>> PurePosixPath('/etc').root
       '/'
 
    UNC shares always have a root::
 
-      >>> PureNTPath('//some/share').root
+      >>> PureWindowsPath('//some/share').root
       '\\'
 
 .. data:: PurePath.anchor
 
    The concatenation of the drive and root::
 
-      >>> PureNTPath('c:/Program Files/').anchor
+      >>> PureWindowsPath('c:/Program Files/').anchor
       'c:\\'
-      >>> PureNTPath('c:Program Files/').anchor
+      >>> PureWindowsPath('c:Program Files/').anchor
       'c:'
       >>> PurePosixPath('/etc').anchor
       '/'
-      >>> PureNTPath('//some/share').anchor
+      >>> PureWindowsPath('//some/share').anchor
       '\\\\some\\share\\'
 
 
 
    UNC drive names are not considered::
 
-      >>> PureNTPath('//some/share/setup.py').name
+      >>> PureWindowsPath('//some/share/setup.py').name
       'setup.py'
-      >>> PureNTPath('//some/share').name
+      >>> PureWindowsPath('//some/share').name
       ''
 
 
 
    Return a string representation of the path with forward slashes (``/``)::
 
-      >>> p = PureNTPath('c:\\windows')
+      >>> p = PureWindowsPath('c:\\windows')
       >>> str(p)
       'c:\\windows'
       >>> p.as_posix()
       >>> p = PurePosixPath('/etc/passwd')
       >>> p.as_uri()
       'file:///etc/passwd'
-      >>> p = PureNTPath('c:/Windows')
+      >>> p = PureWindowsPath('c:/Windows')
       >>> p.as_uri()
       'file:///c:/Windows'
 
       >>> PurePosixPath('a/b').is_absolute()
       False
 
-      >>> PureNTPath('c:/a/b').is_absolute()
+      >>> PureWindowsPath('c:/a/b').is_absolute()
       True
-      >>> PureNTPath('/a/b').is_absolute()
+      >>> PureWindowsPath('/a/b').is_absolute()
       False
-      >>> PureNTPath('c:').is_absolute()
+      >>> PureWindowsPath('c:').is_absolute()
       False
-      >>> PureNTPath('//some/share').is_absolute()
+      >>> PureWindowsPath('//some/share').is_absolute()
       True
 
 
 .. method:: PurePath.is_reserved()
 
-   With :class:`PureNTPath`, return True if the path is considered reserved
-   under Windows, False otherwise.  With :class:`PurePosixPath`, False is
-   always returned.
+   With :class:`PureWindowsPath`, return True if the path is considered
+   reserved under Windows, False otherwise.  With :class:`PurePosixPath`,
+   False is always returned.
 
-      >>> PureNTPath('nul').is_reserved()
+      >>> PureWindowsPath('nul').is_reserved()
       True
       >>> PurePosixPath('nul').is_reserved()
       False
       PurePosixPath('/etc/passwd')
       >>> PurePosixPath('/etc').joinpath('init.d', 'apache2')
       PurePosixPath('/etc/init.d/apache2')
-      >>> PureNTPath('c:').joinpath('/Program Files')
-      PureNTPath('c:\\Program Files')
+      >>> PureWindowsPath('c:').joinpath('/Program Files')
+      PureWindowsPath('c:\\Program Files')
 
 
 .. method:: PurePath.match(pattern)
 
    As with other methods, case-sensitivity is observed::
 
-      >>> PureNTPath('b.py').match('*.PY')
+      >>> PureWindowsPath('b.py').match('*.PY')
       True
 
 
 
    Iterate over the path's parents from the most to the least specific::
 
-      >>> for p in PureNTPath('c:/foo/bar/setup.py').parents(): p
+      >>> for p in PureWindowsPath('c:/foo/bar/setup.py').parents(): p
       ...
-      PureNTPath('c:\\foo\\bar')
-      PureNTPath('c:\\foo')
-      PureNTPath('c:\\')
+      PureWindowsPath('c:\\foo\\bar')
+      PureWindowsPath('c:\\foo')
+      PureWindowsPath('c:\\')
 
 
 .. method:: PurePath.relative_to(*other)
       >>> PosixPath('/etc')
       PosixPath('/etc')
 
-.. class:: NTPath
+.. class:: WindowsPath
 
-   A subclass of :class:`Path` and :class:`PureNTPath`, this class represents
-   concrete Windows filesystem paths::
+   A subclass of :class:`Path` and :class:`PureWindowsPath`, this class
+   represents concrete Windows filesystem paths::
 
-      >>> NTPath('c:/Program Files/')
-      NTPath('c:\\Program Files')
+      >>> WindowsPath('c:/Program Files/')
+      WindowsPath('c:\\Program Files')
 
 .. class:: Path
 
    A subclass of :class:`PurePath`, this class represents concrete paths of
    the system's path flavour (instantiating it creates either a
-   :class:`PosixPath` or a :class:`NTPath`)::
+   :class:`PosixPath` or a :class:`WindowsPath`)::
 
       >>> Path('setup.py')
       PosixPath('setup.py')
    PosixPath('setup.py')
    >>> PosixPath('setup.py')
    PosixPath('setup.py')
-   >>> NTPath('setup.py')
+   >>> WindowsPath('setup.py')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "pathlib.py", line 798, in __new__
        % (cls.__name__,))
-   NotImplementedError: cannot instantiate 'NTPath' on your system
+   NotImplementedError: cannot instantiate 'WindowsPath' on your system
 
 
 Methods
 
 
 __all__ = [
-    "PurePath", "PurePosixPath", "PureNTPath",
-    "Path", "PosixPath", "NTPath",
+    "PurePath", "PurePosixPath", "PureWindowsPath",
+    "Path", "PosixPath", "WindowsPath",
     ]
 
 #
     """PurePath represents a filesystem path and offers operations which
     don't imply any actual filesystem I/O.  Depending on your system,
     instantiating a PurePath will return either a PurePosixPath or a
-    PureNTPath object.  You can also instantiate either of these classes
+    PureWindowsPath object.  You can also instantiate either of these classes
     directly, regardless of your system.
     """
     __slots__ = (
         new PurePath object.
         """
         if cls is PurePath:
-            cls = PureNTPath if os.name == 'nt' else PurePosixPath
+            cls = PureWindowsPath if os.name == 'nt' else PurePosixPath
         return cls._from_parts(args)
 
     def __reduce__(self):
     __slots__ = ()
 
 
-class PureNTPath(PurePath):
+class PureWindowsPath(PurePath):
     _flavour = _nt_flavour
     __slots__ = ()
 
 
     def __new__(cls, *args, **kwargs):
         if cls is Path:
-            cls = NTPath if os.name == 'nt' else PosixPath
+            cls = WindowsPath if os.name == 'nt' else PosixPath
         self = cls._from_parts(args, init=False)
         if not self._flavour.is_supported:
             raise NotImplementedError("cannot instantiate %r on your system"
 class PosixPath(Path, PurePosixPath):
     __slots__ = ()
 
-class NTPath(Path, PureNTPath):
+class WindowsPath(Path, PureWindowsPath):
     __slots__ = ()
 

File test_pathlib.py

         self.assertEqual(pp, P('/c'))
 
 
-class PureNTPathTest(_BasePurePathTest, unittest.TestCase):
-    cls = pathlib.PureNTPath
+class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
+    cls = pathlib.PureWindowsPath
 
     equivalences = _BasePurePathTest.equivalences.copy()
     equivalences.update({
     def test_concrete_class(self):
         p = self.cls('a')
         self.assertIs(type(p),
-            pathlib.PureNTPath if os.name == 'nt' else pathlib.PurePosixPath)
+            pathlib.PureWindowsPath if os.name == 'nt' else pathlib.PurePosixPath)
 
     def test_different_flavours_unequal(self):
         p = pathlib.PurePosixPath('a')
-        q = pathlib.PureNTPath('a')
+        q = pathlib.PureWindowsPath('a')
         self.assertNotEqual(p, q)
 
     @unittest.skipIf(sys.version_info < (3, 0),
                      'Most types are orderable in Python 2')
     def test_different_flavours_unordered(self):
         p = pathlib.PurePosixPath('a')
-        q = pathlib.PureNTPath('a')
+        q = pathlib.PureWindowsPath('a')
         with self.assertRaises(TypeError):
             p < q
         with self.assertRaises(TypeError):
     cls = pathlib.PosixPath
 
 @only_nt
-class NTPathAsPureTest(PureNTPathTest):
-    cls = pathlib.NTPath
+class WindowsPathAsPureTest(PureWindowsPathTest):
+    cls = pathlib.WindowsPath
 
 
 class _BasePathTest(object):
     def test_concrete_class(self):
         p = self.cls('a')
         self.assertIs(type(p),
-            pathlib.NTPath if os.name == 'nt' else pathlib.PosixPath)
+            pathlib.WindowsPath if os.name == 'nt' else pathlib.PosixPath)
 
     def test_unsupported_flavour(self):
         if os.name == 'nt':
             self.assertRaises(NotImplementedError, pathlib.PosixPath)
         else:
-            self.assertRaises(NotImplementedError, pathlib.NTPath)
+            self.assertRaises(NotImplementedError, pathlib.WindowsPath)
 
 
 @only_posix
 
 
 @only_nt
-class NTPathTest(_BasePathTest, unittest.TestCase):
-    cls = pathlib.NTPath
+class Windows(_BasePathTest, unittest.TestCase):
+    cls = pathlib.WindowsPath
 
     def test_glob(self):
         P = self.cls