@@ -329,6 +329,7 @@ class PurePath(object):
329
329
'_drv' , '_root' , '_parts' ,
330
330
'_str' , '_hash' , '_pparts' , '_cached_cparts' ,
331
331
)
332
+ _case_insensitive = False
332
333
333
334
def __new__ (cls , * args ):
334
335
"""Construct a PurePath from one or several strings and or existing
@@ -345,6 +346,23 @@ def __reduce__(self):
345
346
# when pickling related paths.
346
347
return (type (self ), tuple (self ._parts ))
347
348
349
+ @classmethod
350
+ def _splitroot (cls , part ):
351
+ sep = cls ._pathmod .sep
352
+ if part and part [0 ] == sep :
353
+ stripped_part = part .lstrip (sep )
354
+ # According to POSIX path resolution:
355
+ # http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11
356
+ # "A pathname that begins with two successive slashes may be
357
+ # interpreted in an implementation-defined manner, although more
358
+ # than two leading slashes shall be treated as a single slash".
359
+ if len (part ) - len (stripped_part ) == 2 :
360
+ return '' , sep * 2 , stripped_part
361
+ else :
362
+ return '' , sep , stripped_part
363
+ else :
364
+ return '' , '' , part
365
+
348
366
@classmethod
349
367
def _parse_args (cls , args ):
350
368
# This is useful when you don't want to create an instance, just
@@ -724,12 +742,12 @@ def parents(self):
724
742
def is_absolute (self ):
725
743
"""True if the path is absolute (has both a root and, if applicable,
726
744
a drive)."""
727
- raise NotImplementedError
745
+ return bool ( self . _root )
728
746
729
747
def is_reserved (self ):
730
748
"""Return True if the path contains one of the special names reserved
731
749
by the system, if any."""
732
- raise NotImplementedError
750
+ return False
733
751
734
752
def match (self , path_pattern ):
735
753
"""
@@ -768,32 +786,8 @@ class PurePosixPath(PurePath):
768
786
However, you can also instantiate it directly on any system.
769
787
"""
770
788
_pathmod = posixpath
771
- _case_insensitive = False
772
789
__slots__ = ()
773
790
774
- @classmethod
775
- def _splitroot (cls , part ):
776
- sep = cls ._pathmod .sep
777
- if part and part [0 ] == sep :
778
- stripped_part = part .lstrip (sep )
779
- # According to POSIX path resolution:
780
- # http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11
781
- # "A pathname that begins with two successive slashes may be
782
- # interpreted in an implementation-defined manner, although more
783
- # than two leading slashes shall be treated as a single slash".
784
- if len (part ) - len (stripped_part ) == 2 :
785
- return '' , sep * 2 , stripped_part
786
- else :
787
- return '' , sep , stripped_part
788
- else :
789
- return '' , '' , part
790
-
791
- def is_absolute (self ):
792
- return bool (self ._root )
793
-
794
- def is_reserved (self ):
795
- return False
796
-
797
791
def as_uri (self ):
798
792
# We represent the path using the local filesystem encoding,
799
793
# for portability to other applications.
0 commit comments