35
35
_WINERROR_INVALID_NAME ,
36
36
_WINERROR_CANT_RESOLVE_FILENAME )
37
37
38
+ _win_drive_letters = set ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' )
39
+ _win_ext_namespace_prefix = '\\ \\ ?\\ '
40
+ _win_reserved_names = (
41
+ {'CON' , 'PRN' , 'AUX' , 'NUL' } |
42
+ {'COM%d' % i for i in range (1 , 10 )} |
43
+ {'LPT%d' % i for i in range (1 , 10 )}
44
+ )
45
+
38
46
def _ignore_error (exception ):
39
47
return (getattr (exception , 'errno' , None ) in _IGNORED_ERROS or
40
48
getattr (exception , 'winerror' , None ) in _IGNORED_WINERRORS )
@@ -807,13 +815,6 @@ class PureWindowsPath(PurePath):
807
815
_pathmod = ntpath
808
816
_supported = (os .name == 'nt' )
809
817
_case_insensitive = True
810
- _drive_letters = set ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' )
811
- _ext_namespace_prefix = '\\ \\ ?\\ '
812
- _reserved_names = (
813
- {'CON' , 'PRN' , 'AUX' , 'NUL' } |
814
- {'COM%d' % i for i in range (1 , 10 )} |
815
- {'LPT%d' % i for i in range (1 , 10 )}
816
- )
817
818
__slots__ = ()
818
819
819
820
# Interesting findings about extended paths:
@@ -854,7 +855,7 @@ def _splitroot(cls, part):
854
855
else :
855
856
return part [:index2 ], sep , part [index2 + 1 :]
856
857
drv = root = ''
857
- if second == ':' and first in cls . _drive_letters :
858
+ if second == ':' and first in _win_drive_letters :
858
859
drv = part [:2 ]
859
860
part = part [2 :]
860
861
first = third
@@ -864,7 +865,7 @@ def _splitroot(cls, part):
864
865
return prefix + drv , root , part
865
866
866
867
@classmethod
867
- def _split_extended_path (cls , s , ext_prefix = _ext_namespace_prefix ):
868
+ def _split_extended_path (cls , s , ext_prefix = _win_ext_namespace_prefix ):
868
869
prefix = ''
869
870
if s .startswith (ext_prefix ):
870
871
prefix = s [:4 ]
@@ -887,7 +888,7 @@ def is_reserved(self):
887
888
if self ._parts [0 ].startswith ('\\ \\ ' ):
888
889
# UNC paths are never reserved
889
890
return False
890
- return self ._parts [- 1 ].partition ('.' )[0 ].upper () in self . _reserved_names
891
+ return self ._parts [- 1 ].partition ('.' )[0 ].upper () in _win_reserved_names
891
892
892
893
def as_uri (self ):
893
894
if not self .is_absolute ():
0 commit comments