
    F\hz                        S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
Jr   S SKr S SKrSSKJrJrJr  / SQr " S S	\5      r " S
 S\5      r\R,                  R/                  \5         " S S\5      r " S S\5      r " S S\\5      r " S S\\5      r " S S\\5      rg! \ a    Sr Nf = f! \ a    Sr Nf = f)    N)_StringGlobber)chain)Sequence   )UnsupportedOperationPurePathBasePathBase)PurePathPurePosixPathPureWindowsPathPath	PosixPathWindowsPathc                   4    \ rS rSrSrSrS rS rS rS r	Sr
g	)
_PathParents   zrThis object provides sequence-like access to the logical ancestors
of a path.  Don't try to construct it yourself.)_path_drv_root_tailc                 v    Xl         UR                  U l        UR                  U l        UR
                  U l        g N)r   driver   rootr   r   selfpaths     %/usr/lib/python3.13/pathlib/_local.py__init___PathParents.__init__"   s(    
JJ	YY
ZZ
    c                 ,    [        U R                  5      $ r   )lenr   r   s    r   __len___PathParents.__len__(   s    4::r!   c           
        ^  [        U[        5      (       a3  [        U 4S j[        UR	                  [        T 5      5      6  5       5      $ U[        T 5      :  d  U[        T 5      * :  a  [        U5      eUS:  a  U[        T 5      -  nT R                  R                  T R                  T R                  T R                  S U* S-
   5      $ )Nc              3   .   >#    U  H
  nTU   v   M     g 7fr    ).0ir   s     r   	<genexpr>+_PathParents.__getitem__.<locals>.<genexpr>-   s     I*HQa*Hs   r   r   )
isinstanceslicetuplerangeindicesr#   
IndexErrorr   _from_parsed_partsr   r   r   )r   idxs   ` r   __getitem___PathParents.__getitem__+   s    c5!!I%SY1G*HIII#d)sc$iZ/S/!73t9Czz,,TYY

-1ZZ	#-BD 	Dr!   c                 ^    SR                  [        U R                  5      R                  5      $ )Nz<{}.parents>)formattyper   __name__r$   s    r   __repr___PathParents.__repr__6   s"    $$T$**%5%>%>??r!   )r   r   r   r   N)r;   
__module____qualname____firstlineno____doc__	__slots__r   r%   r6   r<   __static_attributes__r)   r!   r   r   r      s"    73I 	D@r!   r   c                      \ rS rSrSrSr\R                  r\	r
S rS rS rS rS rS	 rS
 rS rS r\S 5       rS rS r\S 5       rS rS rS rS rS r\S 5       rS r S r!\S 5       r"\S 5       r#\S 5       r$\S 5       r%\S 5       r&\S 5       r'\S 5       r(\S  5       r)\S! 5       r*\S" 5       r+S# r,S$S%.S& jr-S' r.S( r/S) r0S* r1\S+ 5       r2S,r3g-).r
   :   ad  Base class for manipulating paths without I/O.

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
PureWindowsPath object.  You can also instantiate either of these classes
directly, regardless of your system.
)
_raw_pathsr   r   _tail_cached_str_str_normcase_cached_parts_normcase_cached_hashc                 ~    U [         L a   [        R                  S:X  a  [        O[        n [
        R                  U 5      $ )zConstruct a PurePath from one or several strings and or existing
PurePath objects.  The strings and path objects are combined so as
to yield a canonicalized path, which is incorporated into the
new PurePath object.
nt)r
   osnamer   r   object__new__clsargskwargss      r   rQ   PurePath.__new__j   s+     (?%'WW_/-C~~c""r!   c                    SS K n/ nU H  n[        U[        5      (       aW  UR                  U R                  La!  UR	                  UR                  5       5        MR  UR                  UR                  5        Mo   [        R                  " U5      n[        U[        5      (       d"  [        S[        U5      R                  < 35      eUR	                  U5        M     X0l        g ! [         a    Un Naf = f)Nr   zVargument should be a str or an os.PathLike object where __fspath__ returns a str, not )ntpathr.   r
   parserappendas_posixextendrF   rN   fspath	TypeErrorstrr:   r;   )r   rT   rX   pathsargr   s         r   r   PurePath.__init__t   s    C#x((::T[[0LL0LL099S>D "$,,##Dz22578 8 T"# &   ! Ds   9C""C10C1c                 (    U R                   " U /UQ76 $ )zCombine this path with one or several arguments, and return a
new path representing either a subpath (if all arguments are relative
paths) or a totally different path (if one of the arguments is
anchored).
)with_segments)r   pathsegmentss     r   joinpathPurePath.joinpath   s     !!$666r!   c                 R     U R                  X5      $ ! [         a	    [        s $ f = fr   rd   r^   NotImplementedr   keys     r   __truediv__PurePath.__truediv__   s-    	"%%d00 	"!!	"    &&c                 R     U R                  X5      $ ! [         a	    [        s $ f = fr   ri   rk   s     r   __rtruediv__PurePath.__rtruediv__   s-    	"%%c00 	"!!	"ro   c                 D    U R                   [        U R                  5      4$ r   )	__class__r0   rF   r$   s    r   
__reduce__PurePath.__reduce__   s    ~~uT__555r!   c                 j    SR                  U R                  R                  U R                  5       5      $ )Nz{}({!r}))r9   rt   r;   r[   r$   s    r   r<   PurePath.__repr__   s%      !8!8$--/JJr!   c                     [        U 5      $ r   r_   r$   s    r   
__fspath__PurePath.__fspath__   s    4yr!   c                 .    [         R                  " U 5      $ )zYReturn the bytes representation of the path.  This is only
recommended to use under Unix.)rN   fsencoder$   s    r   	__bytes__PurePath.__bytes__   s     {{4  r!   c                      U R                   $ ! [         aQ    U R                  [        L a  [	        U 5      U l         O[	        U 5      R                  5       U l         U R                   s $ f = fr   )rI   AttributeErrorrY   	posixpathr_   lowerr$   s    r   _str_normcasePurePath._str_normcase   sY    	-,,, 	-{{i',/I),/IOO,=),,,	-s    AA)(A)c                      U R                   $ ! [         a)    [        U R                  5      U l         U R                   s $ f = fr   )rK   r   hashr   r$   s    r   __hash__PurePath.__hash__   s<    	:: 	d001DJ::	s    0A Ac                     [        U[        5      (       d  [        $ U R                  UR                  :H  =(       a    U R                  UR                  L $ r   )r.   r
   rj   r   rY   r   others     r   __eq__PurePath.__eq__   s>    %**!!!!U%8%88XT[[ELL=XXr!   c                      U R                   $ ! [         aC    U R                  R                  U R                  R
                  5      U l         U R                   s $ f = fr   )rJ   r   r   splitrY   sepr$   s    r   _parts_normcasePurePath._parts_normcase   sO    	/... 	/*.*<*<*B*B4;;??*SD'...	/s    A
AAc                     [        U[        5      (       a  U R                  UR                  La  [        $ U R                  UR                  :  $ r   r.   r
   rY   rj   r   r   s     r   __lt__PurePath.__lt__   ;    %**dkk.M!!##e&;&;;;r!   c                     [        U[        5      (       a  U R                  UR                  La  [        $ U R                  UR                  :*  $ r   r   r   s     r   __le__PurePath.__le__   ;    %**dkk.M!!##u'<'<<<r!   c                     [        U[        5      (       a  U R                  UR                  La  [        $ U R                  UR                  :  $ r   r   r   s     r   __gt__PurePath.__gt__   r   r!   c                     [        U[        5      (       a  U R                  UR                  La  [        $ U R                  UR                  :  $ r   r   r   s     r   __ge__PurePath.__ge__   r   r!   c                      U R                   $ ! [         aN    U R                  U R                  U R                  U R
                  5      =(       d    SU l         U R                   s $ f = f)zSReturn the string representation of the path, suitable for
passing to system calls..)rH   r   _format_parsed_partsr   r   r   r$   s    r   __str__PurePath.__str__   s[    	99 	11$**dii26**> EAD I99	s    AA&%A&c                 "   U(       d  U(       a*  X-   U R                   R                  R                  U5      -   $ U(       a,  U R                   R                  US   5      S   (       a  S/U-   nU R                   R                  R                  U5      $ )Nr   r   )rY   r   join
splitdrive)rS   drvr   tails       r   r   PurePath._format_parsed_parts   sh    $:

 3 3D 999cjj++DG4Q754<Dzz~~""4((r!   c                 l    U R                  U R                  XU5      5      nXl        X$l        X4l        U$ r   )_from_parsed_stringr   r   r   rG   )r   r   r   r   r   s        r   r4   PurePath._from_parsed_parts   s4    ''(A(A#T(RS	
 r!   c                 H    U R                  U5      nU=(       d    SUl        U$ )Nr   )rd   rH   )r   path_strr   s      r   r   PurePath._from_parsed_string   s"    !!(+O	r!   c                 l   U(       d  SS/ 4$ U R                   R                  nU R                   R                  nU(       a  UR                  X25      nU R                   R	                  U5      u  pEnU(       di  UR                  U5      (       aS  UR                  U5      (       d=  UR                  U5      n[        U5      S:X  a  US   S;  a  UnO[        U5      S:X  a  UnUR                  U5       Vs/ s H2  o(       d  M  US:w  d  M  [        R                  " [        U5      5      PM4     n	nXEU	4$ s  snf )N       z?.   r   )rY   r   altsepreplace	splitroot
startswithendswithr   r#   sysinternr_   )
rS   r   r   r   r   r   rel	drv_partsxparseds
             r   _parse_pathPurePath._parse_path  s    r2:jjnn""<<,D--d33s++CLL4E4E		#I9~"y|4'?Y1$.1iinOn$a3h$#**SV$nO&   Ps   2
D1 D1#D1c                     U R                   n[        U5      S:X  a  SnU$ [        U5      S:X  a  US   nU$ U R                  R                  " U6 nU$ )z!The joined but unnormalized path.r   r   r   )rF   r#   rY   r   )r   r`   r   s      r   	_raw_pathPurePath._raw_path  s\     u:?D
 	 Z1_8D  ;;##U+Dr!   c                      U R                   $ ! [         a=    U R                  U R                  5      u  U l         U l        U l        U R                   s $ f = f)z.The drive prefix (letter or UNC path), if any.)r   r   r   r   r   rG   r$   s    r   r   PurePath.drive!  sL    	99 	7;7G7G7W4DItz4#499	    AAAc                      U R                   $ ! [         a=    U R                  U R                  5      u  U l        U l         U l        U R                   s $ f = f)zThe root of the path, if any.)r   r   r   r   r   rG   r$   s    r   r   PurePath.root*  sL    	:: 	7;7G7G7W4DItz4#4::	r   c                      U R                   $ ! [         a=    U R                  U R                  5      u  U l        U l        U l         U R                   s $ f = fr   )rG   r   r   r   r   r   r$   s    r   r   PurePath._tail3  sP    	%$$$ 	%7;7G7G7W4DItz4#4$$$	%r   c                 4    U R                   U R                  -   $ )z/The concatenation of the drive and root, or ''.)r   r   r$   s    r   anchorPurePath.anchor;  s     zzDII%%r!   c                     U R                   (       d  U R                  (       a0  U R                   U R                  -   4[        U R                  5      -   $ [        U R                  5      $ )zRAn object providing sequence-like access to the
components in the filesystem path.)r   r   r0   r   r$   s    r   partsPurePath.parts@  sD     ::JJ*,uTZZ/@@@$$r!   c                     U R                   nU R                  nU R                  nU(       d  U $ U R                  XUSS 5      $ )zThe logical parent of the path.N)r   r   r   r4   )r   r   r   r   s       r   parentPurePath.parentI  s@     jjyyzzK&&s$s)<<r!   c                     [        U 5      $ )z*A sequence of this path's logical parents.)r   r$   s    r   parentsPurePath.parentsS  s    
 D!!r!   c                 4    U R                   nU(       d  gUS   $ )z!The final path component, if any.r   r   )r   )r   r   s     r   rO   PurePath.nameZ  s     zzBxr!   c                 j   U R                   nU(       a7  UR                  U;   d'  UR                  (       a  UR                  U;   d  US:X  a  [        SU< 35      eU R                  R                  5       nU(       d  [        U < S35      eXS'   U R                  U R                  U R                  U5      $ )z-Return a new path with the file name changed.r   zInvalid name z has an empty namer   )	rY   r   r   
ValueErrorr   copyr4   r   r   )r   rO   pr   s       r   	with_namePurePath.with_nameb  s    KKquu}ahh$6F4SV;}TH566zz x'9:;;R&&tzz499dCCr!   F)walk_upc                  U(       a0  Sn[         R                  " U[        SS9  U R                  " U/UQ76 nO&[	        U[
        5      (       d  U R                  U5      n[        [        U/UR                  5      5       Ho  u  pVX`:X  d  X`R                  ;   a    O}U(       d$  [        [        U 5      < S[        U5      < 35      eUR                  S:X  d  MX  [        S[        U5      < S35      e   [        [        U 5      < S[        U5      < S	35      eS/U-  U R                  [        UR                  5      S
 -   nU R                  SSU5      $ )a  Return the relative path to another path identified by the passed
arguments.  If the operation is not possible (because this is not
related to the other path), raise ValueError.

The *walk_up* parameter controls whether `..` may be used to resolve
the path.
zsupport for supplying more than one positional argument to pathlib.PurePath.relative_to() is deprecated and scheduled for removal in Python 3.14r   
stacklevelz is not in the subpath of z..z'..' segment in z cannot be walkedz and z have different anchorsNr   )warningswarnDeprecationWarningrd   r.   r
   	enumerater   r   r   r_   rO   r   r#   r4   )r   r   r   _deprecatedmsgstepr   r   s           r   relative_toPurePath.relative_tom  s'    :C MM#1a@&&u;{;EE8,,&&u-E#E5'5==$ABJD|t||3 CI=0J3u:.!YZZd" #3CJ>AR!STT C D	}E#e*?VWXX

3tzz?+; <<&&r2u55r!   c                    U(       a0  Sn[         R                  " U[        SS9  U R                  " U/UQ76 nO&[	        U[
        5      (       d  U R                  U5      nX:H  =(       d    XR                  ;   $ )zFReturn True if the path is relative to another path or False.
        zsupport for supplying more than one argument to pathlib.PurePath.is_relative_to() is deprecated and scheduled for removal in Python 3.14r   r   )r   r   r   rd   r.   r
   r   )r   r   r   r   s       r   is_relative_toPurePath.is_relative_to  sg     :C MM#1a@&&u;{;EE8,,&&u-E}5 55r!   c                     U R                   [        L a,  U R                   H  nUR                  S5      (       d  M    g   gU R                   R	                  U 5      $ )zKTrue if the path is absolute (has both a root and, if applicable,
a drive)./TF)rY   r   rF   r   isabsr   s     r   is_absolutePurePath.is_absolute  sJ     ;;)#??3'' ( {{  &&r!   c                     SSK nSn[        R                  " U[        SS9  U R                  UL a  U R                  R                  U 5      $ g)zYReturn True if the path contains one of the special names reserved
by the system, if any.r   Nzpathlib.PurePath.is_reserved() is deprecated and scheduled for removal in Python 3.15. Use os.path.isreserved() to detect reserved paths on Windows.r   r   F)rX   r   r   r   rY   
isreserved)r   rX   r   s      r   is_reservedPurePath.is_reserved  sE     	3 	c-!<;;& ;;))$//r!   c                 R   U R                  5       (       d  [        S5      eU R                  n[        U5      S:X  a"  US   S:X  a  SU-   nU R	                  5       SS nO'U(       a  SnU R	                  5       nOSn[        U 5      nS	S
KJn  X$" [        R                  " U5      5      -   $ )zReturn the path as a URI.z.relative path can't be expressed as a file URIr   r   :zfile:///Nfile:zfile://r   )quote_from_bytes)
r   r   r   r#   r[   r_   urllib.parser  rN   r~   )r   r   prefixr   r  s        r   as_uriPurePath.as_uri  s    !!MNN

u:?uQx3%'F==?12&DF==?D Ft9D1(T):;;;r!   c                 ,    [        U 5      nUS:X  a  S$ U$ )z<The path expressed as a string, for use in pattern-matching.r   r   rz   )r   r   s     r   _pattern_strPurePath._pattern_str  s    
 t9_r2(2r!   )r   rK   rJ   rF   r   rH   rI   rG   N)4r;   r>   r?   r@   rA   rB   rN   r   rY   r   _globberrQ   r   rf   rm   rq   ru   r<   r{   r   propertyr   r   r   r   r   r   r   r   r   classmethodr   r4   r   r   r   r   r   r   r   r   r   r   rO   r   r   r   r   r   r  r  rC   r)   r!   r   r
   r
   :   s   "IF WWFH# 07""6K!
 	- 	-Y
 / /<
=
<
=
 ) )
 ! !& 	 	     % % & & % % = = " "  	D ;@ 686	'
<* 3 3r!   r
   c                        \ rS rSrSr\rSrSrg)r   i  zPurePath subclass for non-Windows systems.

On a POSIX system, instantiating a PurePath should return this object.
However, you can also instantiate it directly on any system.
r)   N)	r;   r>   r?   r@   rA   r   rY   rB   rC   r)   r!   r   r   r     s    
 FIr!   r   c                   (    \ rS rSrSrSSKr\rSrSrg)r   i  zPurePath subclass for Windows systems.

On a Windows system, instantiating a PurePath should return this object.
However, you can also instantiate it directly on any system.
r   Nr)   )	r;   r>   r?   r@   rA   rX   rY   rB   rC   r)   r!   r   r   r     s    
 FIr!   r   c                   8  ^  \ rS rSrSrSr\R                  r\S 5       r	U 4S jr
S rSS.S	 jrS
 rS r  S,S jrS-S jrS-S jr\R&                  " \" SS5      5      r\R&                  " \" S5      5      rS rS rSSS.S jrSSS.S jrS.S jrS rS/S jr\(       a  SS.S jr\ (       a  SS.S jr!\"" \#S5      (       a  S r$S0S jr%S1S  jr&SS.S! jr'S/S" jr(S# r)S$ r*S% r+\"" \#S&5      (       a  S/S' jr,\"" \#S(5      (       a  S) r-S* r.\S+ 5       r/Sr0U =r1$ )2r   i  a  PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers
methods to do system calls on path objects. Depending on your system,
instantiating a Path will return either a PosixPath or a WindowsPath
object. You can also instantiate a PosixPath or WindowsPath directly,
but cannot instantiate a WindowsPath on a POSIX system or vice versa.
r)   c                 &    U R                    SU S3$ )Nr   z is unsupported on this system)r;   )rS   	attributes     r   _unsupported_msgPath._unsupported_msg  s    ,,q+IJJr!   c                 ^   > U(       a  Sn[         R                  " SUSS9  [        TU ]  " U6   g )Nzvsupport for supplying keyword arguments to pathlib.PurePath is deprecated and scheduled for removal in Python {remove}zpathlib.PurePath(**kwargs))      )remove)r   r   superr   )r   rT   rU   r   rt   s       r   r   Path.__init__  s.    PC  !=s7S$r!   c                 ~    U [         L a   [        R                  S:X  a  [        O[        n [
        R                  U 5      $ )NrM   )r   rN   rO   r   r   rP   rQ   rR   s      r   rQ   Path.__new__  s)    $;!#D+iC~~c""r!   Tfollow_symlinksc                *    [         R                  " XS9$ )zP
Return the result of the stat() system call on this path, like
os.stat() does.
r  )rN   stat)r   r  s     r   r  	Path.stat   s    
 wwt==r!   c                 @    [         R                  R                  U 5      $ )z%
Check if this path is a mount point
)rN   r   ismountr$   s    r   is_mountPath.is_mount  s     wwt$$r!   c                 @    [         R                  R                  U 5      $ )z"
Whether this path is a junction.
)rN   r   
isjunctionr$   s    r   is_junctionPath.is_junction  s     ww!!$''r!   r   Nc                 j    SU;  a  [         R                  " U5      n[         R                  " XX#XE5      $ )zg
Open the file pointed to by this path and return a file object, as
the built-in open() function does.
b)iotext_encodingopen)r   mode	bufferingencodingerrorsnewlines         r   r-  	Path.open  s.     d?''1Hwwt9HHr!   c                 \    [         R                  " U5      n[        R                  " XX#5      $ )z:
Open the file in text mode, read it, and close the file.
)r+  r,  r	   	read_text)r   r0  r1  r2  s       r   r5  Path.read_text  s'     ##H-!!$&BBr!   c                 ^    [         R                  " U5      n[        R                  " XX#U5      $ )z>
Open the file in text mode, write to it, and close the file.
)r+  r,  r	   
write_text)r   datar0  r1  r2  s        r   r8  Path.write_text&  s)     ##H-""4xIIr!   r   c              #      #    U R                   R                  n[        U R                  5      nU H$  n[        U5      U:  a  US   U:X  a  US S nUv   M&     g 7f)Nr   )rY   r   r#   r   )r   r`   r   
anchor_lenr   s        r   _filter_trailing_slashPath._filter_trailing_slash2  sQ     kkoo%
H8}z)hrlc.A#CR=N s   AAc                    [        U 5      n[        R                  " U5       nU Vs/ s H  o3R                  PM     nnSSS5        US:X  a  [	        U R
                  W5      n[	        U R                  W5      $ s  snf ! , (       d  f       NE= f)zYield path objects of the directory contents.

The children are yielded in arbitrary order, and the
special entries '.' and '..' are not included.
Nr   )r_   rN   scandirr   map_remove_leading_dotr   )r   root_dir
scandir_itentryr`   s        r   iterdirPath.iterdir:  sp     t9ZZ!Z-78ZEZZZE8 "s?00%8E4++U33 9 "!s   A=A8A=8A==
BFcase_sensitiverecurse_symlinksc                   [         R                  " SX5        [        U[        5      (       d  U R	                  U5      nUR
                  (       a  [        S5      eUR                  R                  5       nU(       d  [        SR                  U5      5      eUR                  nUS   U R                  R                  U R                  R                  4;   a  UR                  S5        U R!                  USSS2   X#5      n[#        U 5      nU" U5      nUS:X  a  [%        U R&                  U5      nUS   S:X  a  [%        U R(                  U5      nOUS   S:X  a  U R+                  U5      n[%        U R,                  U5      nU$ )	zIterate over this subtree and yield all existing files (of any
kind, including directories) matching the given relative pattern.
zpathlib.Path.globz%Non-relative patterns are unsupportedzUnacceptable pattern: {!r}r   r   Nr   **)r   auditr.   r
   rd   r   NotImplementedErrorr   r   r   r9   r   rY   r   r   rZ   _glob_selectorr_   rA  rB  _remove_trailing_slashr=  r   )	r   patternrI  rJ  r   rawselectr   r`   s	            r   glob	Path.globG  s@    			%t5'8,,((1G>>%&MNN""$9@@IJJr7t{{(:(:;;LL$$U4R4[.S4yt 3;00%8E9?33U;E2Y$//6ED,,e4r!   c                    [         R                  " SX5        [        U[        5      (       d  U R	                  U5      nSU-  nU R                  XUS9$ )zRecursively yield all existing files (of any kind, including
directories) matching the given relative pattern, anywhere in
this subtree.
zpathlib.Path.rglobrL  rH  )r   rM  r.   r
   rd   rT  )r   rQ  rI  rJ  s       r   rglob
Path.rglobe  sM    
 			&6'8,,((1G.yyRbyccr!   c              #     #    [         R                  " SXU5        [        U 5      nU(       d  [        R                  n[        R
                  " XAX#5      nU H&  u  pgnUS:X  a  USS nU R                  U5      Xx4v   M(     g7f)zBWalk the directory tree from this directory, similar to os.walk().zpathlib.Path.walkr   r   N)r   rM  r_   rN   _walk_symlinks_as_fileswalkr   )	r   top_downon_errorr  rC  resultsr   dirnames	filenamess	            r   r[  	Path.walkp  st     		%tGt9 88O''(hH-4)H	3#AB<**84hII .5s   A?Bc                    U R                  5       (       a  U $ U R                  (       a[  [        R                  R	                  [        R
                  " 5       5      S   nU R                  XR                  U R                  5      $ U R                  (       a*  [        R                  R                  U R                  5      nO[        R
                  " 5       nU R                  (       d  U R                  U5      $ [        R                  R	                  U5      u  pnU(       d  U R                  XU R                  5      $ UR                  U R                  R                  5      nUR                  U R                  5        U R                  XU5      $ )zReturn an absolute version of this path
No normalization or symlink resolution is performed.

Use resolve() to resolve symlinks and remove '..' segments.
r   )r   r   rN   r   r   getcwdr4   r   r   abspathr   r   rY   r   r\   )r   r   cwdr   r   r   s         r   absolutePath.absolute|  s    K99GG%%biik215E**5))TZZHH::''//$**-C))+Czz ++C0077,,S1S**5

CCyy)DJJ&&uD99r!   c                 Z    U R                  [        R                  R                  XS95      $ )zT
Make the path absolute, resolving all symlinks on the way and also
normalizing it.
)strict)rd   rN   r   realpath)r   ri  s     r   resolvePath.resolve  s'     !!"''"2"24"2"GHHr!   c                t    U R                  US9R                  n[        R                  " U5      R                  $ )z*
Return the login name of the file owner.
r  )r  st_uidpwdgetpwuidpw_name)r   r  uids      r   owner
Path.owner  /     ))O)<CCC<<$,,,r!   c                t    U R                  US9R                  n[        R                  " U5      R                  $ )z(
Return the group name of the file gid.
r  )r  st_gidgrpgetgrgidgr_name)r   r  gids      r   group
Path.group  ru  r!   readlinkc                 L    U R                  [        R                  " U 5      5      $ )z4
Return the path to which the symbolic link points.
)rd   rN   r~  r$   s    r   r~  Path.readlink  s     %%bkk$&788r!   c                 4   U(       a   [         R                  " U S5        g[         R                  [         R                  -  nU(       d  U[         R
                  -  n[         R                  " XU5      n[         R                  " U5        g! [         a     Nuf = f)zC
Create this file with the given access mode, if it doesn't exist.
N)rN   utimeOSErrorO_CREATO_WRONLYO_EXCLr-  close)r   r.  exist_okflagsfds        r   touch
Path.touch  sq    
 t$
 

R[[(RYYEWWT$'
  s   B
 

BBc                 (    [         R                  " X5        g! [         aF    U(       a  U R                  U :X  a  e U R                  R                  SSS9  U R                  USUS9   g[         a     U(       a  U R                  5       (       d  e  gf = f)z,
Create a new directory at this given path.
T)r   r  FN)rN   mkdirFileNotFoundErrorr   r  is_dir)r   r.  r   r  s       r   r  
Path.mkdir  s{    	HHT   	?dkkT1KKdT:JJtUXJ> 	 4;;== $1	s    AB(&BBc                .    [         R                  " XUS9  g)z6
Change the permissions of the path, like os.chmod().
r  N)rN   chmod)r   r.  r  s      r   r  
Path.chmod  s     	_=r!   c                 b     [         R                  " U 5        g! [         a    U(       d  e  gf = f)zL
Remove this file or link.
If the path is a directory, use rmdir() instead.
N)rN   unlinkr  )r   
missing_oks     r   r  Path.unlink  s,    
	IIdO  	 	s    ..c                 0    [         R                  " U 5        g)z6
Remove this directory.  The directory must be empty.
N)rN   rmdirr$   s    r   r  
Path.rmdir  s     	r!   c                 P    [         R                  " X5        U R                  U5      $ )a  
Rename this path to the target path.

The target path may be absolute or relative. Relative paths are
interpreted relative to the current working directory, *not* the
directory of the Path object.

Returns the new Path instance pointing to the target path.
)rN   renamerd   r   targets     r   r  Path.rename  s!     			$!!&))r!   c                 P    [         R                  " X5        U R                  U5      $ )a#  
Rename this path to the target path, overwriting if that path exists.

The target path may be absolute or relative. Relative paths are
interpreted relative to the current working directory, *not* the
directory of the Path object.

Returns the new Path instance pointing to the target path.
)rN   r   rd   r  s     r   r   Path.replace  s!     	

4 !!&))r!   symlinkc                 2    [         R                  " XU5        g)z
Make this path a symlink pointing to the target path.
Note the order of arguments (link, target) is the reverse of os.symlink.
N)rN   r  )r   r  target_is_directorys      r   
symlink_toPath.symlink_to  s    
 JJv%89r!   linkc                 0    [         R                  " X5        g)z
Make this path a hard link pointing to the same file as *target*.

Note the order of arguments (self, target) is the reverse of os.link's.
N)rN   r  r  s     r   hardlink_toPath.hardlink_to  s     GGF!r!   c                    U R                   (       d  U R                  (       d  U R                  (       a  U R                  S   SS S:X  au  [        R                  R                  U R                  S   5      nUSS S:X  a  [        S5      eU R                  U5      u  p#nU R                  X#X@R                  SS -   5      $ U $ )z[Return a new path with expanded ~ and ~user constructs
(as returned by os.path.expanduser)
r   Nr   ~z#Could not determine home directory.)	r   r   r   rN   r   
expanduserRuntimeErrorr   r4   )r   homedirr   r   r   s        r   r  Path.expanduser"  s     tyyJJ4::a=!,3gg((A7Gr{c!"#HII"..w7OCt**3dZZ^6KLLr!   c                    UR                  S5      (       d  [        SU< 35      eUSS nUSS S:X  a  USS nOUSS S	:X  a  US
S nUSS S:X  d  USS S:X  a  USS S;   a  USS nUSS S:X  a  USS S-   USS -   nSSKJn  U " [        R
                  " U" U5      5      5      nUR                  5       (       d  [        SU< 35      eU$ )z,Return a new path from the given 'file' URI.r  z!URI does not start with 'file:':    Nr  z///r      z//localhost/   r   r   z:||r   r   )unquote_to_byteszURI is not absolute: )r   r   r  r  rN   fsdecoder   )rS   urir   r  s       r   from_uriPath.from_uri0  s     ~~g&&@HII12w8u8D#2Y.(9D8ubqST!AY$5F8D!98c>DH,D12;;/567!!4SG<==r!   )rr   NNN)NNN)TNF)F)i  T)i  FF)2r;   r>   r?   r@   rA   rB   r
   r  r  r  r   rQ   r  r#  r'  r-  r5  r8  operator
itemgetterr/   rB  rP  r=  rF  rT  rW  r[  rf  rk  ro  rs  rx  r|  hasattrrN   r~  r  r  r  r  r  r  r   r  r  r  r  rC   __classcell__)rt   s   @r   r   r     s]    I__FK K #
 '+ >%( 59"&ICJ #--eAtn=%00r;4 /3U < 04e 	d
J:<I +/ 	- +/ 	- r:	9," .2 >	** r9	: r6	"  r!   r   c                   H    \ rS rSrSrSr\R                  S:X  a  S rSr	gSr	g)r   iI  zkPath subclass for non-Windows systems.

On a POSIX system, instantiating a Path should return this object.
r)   rM   c                 6    [        SU R                  < S35      eNzcannot instantiate z on your systemr   r;   rR   s      r   rQ   PosixPath.__new__Q  "    &%cll%5_EG Gr!   N
r;   r>   r?   r@   rA   rB   rN   rO   rQ   rC   r)   r!   r   r   r   I  $     I	ww$	G r!   r   c                   H    \ rS rSrSrSr\R                  S:w  a  S rSr	gSr	g)r   iU  ziPath subclass for Windows systems.

On a Windows system, instantiating a Path should return this object.
r)   rM   c                 6    [        SU R                  < S35      er  r  rR   s      r   rQ   WindowsPath.__new__]  r  r!   Nr  r)   r!   r   r   r   U  r  r!   r   )r+  r  rN   r   r   r   rT  r   	itertoolsr   _collections_abcr   ro  ImportErrorrx  _abcr   r   r	   __all__r   r
   PathLikeregisterr   r   r   r   r   r)   r!   r   <module>r     s    	  	  
    % ? >@8 @:N3| N3d   X H h b8X bJ
Gm 
G
G$ 
GQ  
C  
Cs"   B/ B= /B:9B:=CC