
    Rh                        d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
 ddlmZmZmZmZ ddlmZmZmZmZmZmZmZ ddlmZ g dZ eh dd	D  ch c]  } d
|  	 c} z  d	D  ch c]  } d|  	 c} z        ZdZdZdZ eeeefZ!eee fZ"d Z#ejH                  d        Z% ejL                  d      jO                  d      \  Z(Z) e* e+e(       e+e)             Z,e-j]                  ddd      e-j]                  ddd      dZ/ ej`                         d        Z1 ej`                  d      d        Z2 ej`                         d        Z3 G d d      Z4 G d d       Z5 G d! d"e4      Z6 G d# d$e4      Z7 G d% d&e4      Z8 G d' d(e8      Z9 G d) d*e
      Z: G d+ d,e;      Z<ejz                  j}                  e<        G d- d.e<      Z? G d/ d0e<      Z@ G d1 d2e<      ZA G d3 d4eAe?      ZB G d5 d6eAe@      ZCyc c} w c c} w )7zObject-oriented filesystem paths.

This module provides classes to represent abstract paths and concrete
paths with operations that have semantics appropriate for different
operating systems.
    N)Sequence)ENOENTENOTDIREBADFELOOP)S_ISDIRS_ISLNKS_ISREGS_ISSOCKS_ISBLKS_ISCHRS_ISFIFO)quote_from_bytes)PurePathPurePosixPathPureWindowsPathPath	PosixPathWindowsPath>   CONIN$CONOUT$AUXCONNULPRNu   123456789¹²³COMLPT   {   i  c                 R    t        | dd       t        v xs t        | dd       t        v S )Nerrnowinerror)getattr_IGNORED_ERRNOS_IGNORED_WINERRORS)	exceptions    /usr/lib/python3.12/pathlib.py_ignore_errorr(   3   s1    Iw-@ GIz404FFH    c                 *    | j                  d      dk(  S )NAa)normcase)flavours    r'   _is_case_sensitiver.   8   s    D!T))r)   _
/)r1   r0   \)r2   r0   )r1   r2   c                 &   | d   }|s
t               S |dk(  rKd}|t        |       k  r$| |   dk(  r|dz  }|t        |       k  r	| |   dk(  r| |d  }d|v rt        }n-t        }n&| dd  }|dk(  rt        }nd|v rt        d      t        } |||||      S )Nr   **   ..z:Invalid pattern: '**' can only be an entire path component)_TerminatingSelectorlen _DoubleRecursiveWildcardSelector_RecursiveWildcardSelector_ParentSelector
ValueError_WildcardSelector)pattern_partsr-   case_sensitivepatchild_parts_idxchild_partsclss          r'   _make_selectorrD   P   s    

C#%%
d{M 22}_7UY]7]q O M 22}_7UY]7]#O$45;2C,C#AB'$;!CS[YZZ#CsK.99r)      )maxsizec                     |rt         j                  nt         j                  }t        j                  t	        j
                  |       |      j                  S N)reNOFLAG
IGNORECASEcompilefnmatch	translatematch)r@   r?   flagss      r'   _compile_patternrQ   i   s5    'BIIR]]E::g'',e4:::r)   c                 h   dg}| j                  d      D ]?  }|dk(  rd}n$|dk(  rd}nt        j                  |      t           }|j	                  |       A |j	                  d       t
        j                  }|s|t
        j                  z  }t        j                  d	j                  |      |
      S )aY  Compile the given pattern lines to an `re.Pattern` object.

    The *pattern_lines* argument is a glob-style pattern (e.g. '*/*.py') with
    its path separators and newlines swapped (e.g. '*
*.py`). By using
    newlines to separate path components, and not setting `re.DOTALL`, we
    ensure that the `*` wildcard cannot match path separators.

    The returned `re.Pattern` object may have its `match()` method called to
    match a complete pattern, or `search()` to match from the right. The
    argument supplied to these methods must also have its path separators and
    newlines swapped.
    ^T)keependsz*
z.+\n*z.+z\Z )rP   )

splitlinesrM   rN   _FNMATCH_SLICEappendrI   	MULTILINErK   rL   join)pattern_linesr?   partspartrP   s        r'   _compile_pattern_linesr_   o   s      EE(($(7 5=DS[D $$T*>:DT 
LLLLE::bggenE22r)   c                       e Zd ZdZd Zd Zy)	_SelectorzYA selector matches a specific glob pattern part against the children
    of a given path.c                 v    || _         |rt        |||      | _        d| _        y t	               | _        d| _        y )NTF)rB   rD   	successordironlyr7   )selfrB   r-   r?   s       r'   __init__z_Selector.__init__   s5    &+K.QDNDL13DN DLr)   c                     t        |      }|j                  }|j                         st        g       S | j	                  ||      S )zuIterate over all child paths of `parent_path` matched by this
        selector.  This can contain parent_path itself.)type_scandiris_diriter_select_from)re   parent_pathpath_clsscandirs       r'   select_fromz_Selector.select_from   sA     $##!!#8O  g66r)   N)__name__
__module____qualname____doc__rf   rp    r)   r'   ra   ra      s    !7r)   ra   c                       e Zd Zd Zy)r7   c              #      K   | y wrH   ru   )re   rm   ro   s      r'   rl   z!_TerminatingSelector._select_from   s     s   N)rq   rr   rs   rl   ru   r)   r'   r7   r7      s    r)   r7   c                       e Zd Zd Zd Zy)r;   c                 4    t         j                  | |||       y rH   ra   rf   )re   namerB   r-   r?   s        r'   rf   z_ParentSelector.__init__       4g~Fr)   c              #   x   K   |j                  d      }| j                  j                  ||      D ]  }|  y w)Nr6   )_make_child_relpathrc   rl   )re   rm   ro   pathps        r'   rl   z_ParentSelector._select_from   s;     ..t4,,T7; 	AG	s   8:Nrq   rr   rs   rf   rl   ru   r)   r'   r;   r;      s    Gr)   r;   c                       e Zd Zd Zd Zy)r=   c                 p    t         j                  | |||       |t        |      }t        ||      | _        y rH   )ra   rf   r.   rQ   rO   re   r@   rB   r-   r?   s        r'   rf   z_WildcardSelector.__init__   s4    4g~F!/8N%c>:
r)   c              #     K   	  ||      5 }t        |      }d d d        D ]u  }| j                  r	 |j                         s!	 |j                  }| j                  |      s@|j                  |      }| j                  j                  ||      D ]  }|  w y # 1 sw Y   xY w# t        $ r Y w xY w# t        $ r Y y w xY wwrH   )	listrd   rj   OSErrorr{   rO   r~   rc   rl   )	re   rm   ro   
scandir_itentriesentryr{   r   r   s	            r'   rl   z_WildcardSelector._select_from   s     	  % +z*+
 !  <<!$||~$  . zz::d#&::4@D!^^88wG    + + # ! !  		sf   CB6 BB6 CB'C"9CB$ B6 '	B30C2B33C6	C?CCCNr   ru   r)   r'   r=   r=      s    ; r)   r=   c                       e Zd Zd Zd Zd Zy)r:   c                 4    t         j                  | |||       y rH   rz   r   s        r'   rf   z#_RecursiveWildcardSelector.__init__   r|   r)   c              #   z   K   | |j                         D ]   \  }}}|D ]  }|j                  |        " y wrH   )walkr~   )re   rm   dirpathdirnamesr/   dirnames         r'   _iterate_directoriesz/_RecursiveWildcardSelector._iterate_directories   sK     $/$4$4$6 	; GXq# ;11'::;	;s   9;c              #      K   | j                   j                  }| j                  |      D ]  } |||      D ]  }|   y wrH   )rc   rl   r   )re   rm   ro   successor_selectstarting_pointr   s         r'   rl   z'_RecursiveWildcardSelector._select_from   sK     >>66"77D 	N%ng> 	s   A AN)rq   rr   rs   rf   r   rl   ru   r)   r'   r:   r:      s    G;r)   r:   c                   "     e Zd ZdZ fdZ xZS )r9   z
    Like _RecursiveWildcardSelector, but also de-duplicates results from
    successive selectors. This is necessary if the pattern contains
    multiple non-adjacent '**' segments.
    c              #      K   t               }	 t        | 	  ||      D ]  }||vs| |j                  |        	 |j	                          y # |j	                          w xY wwrH   )setsuperrl   addclear)re   rm   ro   yieldedr   	__class__s        r'   rl   z-_DoubleRecursiveWildcardSelector._select_from   sZ     %	W)+w? #G#GKKN#
 MMOGMMOs    A%A A A%A""A%)rq   rr   rs   rt   rl   __classcell__r   s   @r'   r9   r9      s     r)   r9   c                   ,    e Zd ZdZdZd Zd Zd Zd Zy)_PathParentszvThis object provides sequence-like access to the logical ancestors
    of a path.  Don't try to construct it yourself.)_path_drv_root_tailc                 x    || _         |j                  | _        |j                  | _        |j
                  | _        y rH   )r   driver   rootr   r   )re   r   s     r'   rf   z_PathParents.__init__  s*    
JJ	YY
ZZ
r)   c                 ,    t        | j                        S rH   )r8   r   re   s    r'   __len__z_PathParents.__len__  s    4::r)   c           
          t        |t              r2t         fdt        |j	                  t                      D              S |t               k\  s|t                k  rt        |      |dk  r|t               z  } j                  j                   j                   j                   j                  d | dz
         S )Nc              3   (   K   | ]	  }|     y wrH   ru   ).0ire   s     r'   	<genexpr>z+_PathParents.__getitem__.<locals>.<genexpr>  s     IQaIs   r   r5   )
isinstanceslicetuplerangeindicesr8   
IndexErrorr   _from_parsed_partsr   r   r   )re   idxs   ` r'   __getitem__z_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                 ^    dj                  t        | j                        j                        S )Nz<{}.parents>)formatrh   r   rq   r   s    r'   __repr__z_PathParents.__repr__  s"    $$T$**%5%>%>??r)   N)	rq   rr   rs   rt   	__slots__rf   r   r   r   ru   r)   r'   r   r     s"    73I 	D@r)   r   c                      e Zd ZdZdZej                  Zd Zd Z	d Z
d Zed        Zd Zd	 Zed
        Zd Zd Zd Zd Zd Zd Zed        Zed        Zed        Zd Zd Zd Zd Zd Zd Z ed        Z!ed        Z"ed        Z#ed        Z$ed        Z%ed        Z&ed         Z'ed!        Z(d" Z)d# Z*d$ Z+d%d&d'Z,d( Z-ed)        Z.d* Z/d+ Z0d, Z1ed-        Z2ed.        Z3d/ Z4d0 Z5d1d2d3Z6y1)4r   a|  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_lines_cached_hashc                 z    | t         u rt        j                  dk(  rt        nt        } t
        j                  |       S )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   osr{   r   r   object__new__rC   argskwargss      r'   r   zPurePath.__new__V  s+     (?%'WW_/-C~~c""r)   c                 2    | j                   | j                  fS rH   )r   r]   r   s    r'   
__reduce__zPurePath.__reduce__`  s     

++r)   c                    dd l }g }|D ]  }t        |t              r_|j                  |u r5| j                  t        u r#|j                  d |j                  D               V|j                  |j                         r	 t        j                  |      }t        |t              s!t        dt        |      j                        |j                  |        || _        y # t        $ r |}Y Yw xY w)Nr   c              3   @   K   | ]  }|j                  d d        yw)r2   r1   N)replace)r   r   s     r'   r   z$PurePath.__init__.<locals>.<genexpr>l  s      TTdC!8 Ts   zVargument should be a str or an os.PathLike object where __fspath__ returns a str, not )ntpathr   r   _flavour	posixpathextendr   r   fspath	TypeErrorstrrh   rq   rY   )re   r   r   pathsargr   s         r'   rf   zPurePath.__init__e  s     	#C#x(<<6)dmmy.HLL TS^^ TTLL099S>D "$,##Dz22578 8 T"#	#$   ! Ds   <CC+*C+c                      t        |       | S )zConstruct a new path object from any number of path-like objects.
        Subclasses may override this method to customize how new path objects
        are created from methods like `iterdir()`.
        )rh   re   pathsegmentss     r'   with_segmentszPurePath.with_segments|  s    
 tDz<((r)   c                 "   |sddg fS | j                   j                  }| j                   j                  }|r|j                  ||      }| j                   j	                  |      \  }}}|s[|j                  |      rJ|j                  |      s9|j                  |      }t        |      dk(  r
|d   dvr|}nt        |      dk(  r|}|j                  |      D cg c])  }|s|dk7  st        j                  t        |            + }	}|||	fS c c}w )NrV         z?.   .)r   sepaltsepr   	splitroot
startswithendswithsplitr8   sysinternr   )
rC   r   r   r   drvr   rel	drv_partsxparseds
             r'   _parse_pathzPurePath._parse_path  s    r2:ll$$<<,D//5T3s+CLL4E		#I9~"y|4'?Y1$.1iinOa3h#**SV$OOD&   Ps   DD% Dc                     | j                   }t        |      dk(  rd}n-t        |      dk(  r|d   }n | j                  j                  | }| j	                  |      \  }}}|| _        || _        || _        y )Nr   rV   r5   )r   r8   r   r[   r   r   r   r   )re   r   r   r   r   tails         r'   _load_partszPurePath._load_parts  sq    u:?DZ1_8D%4==%%u-D**40T4	
 r)   c                     | j                  |||      }| j                  |      }|xs d|_        ||_        ||_        ||_        |S Nr   )_format_parsed_partsr   r   r   r   r   )re   r   r   r   path_strr   s         r'   r   zPurePath._from_parsed_parts  sL    ,,S$=!!(+O		
 r)   c                     |s|r+||z   | j                   j                  j                  |      z   S |r'| j                   j                  |d         d   rdg|z   }| j                   j                  j                  |      S )Nr   r   )r   r   r[   
splitdrive)rC   r   r   r   s       r'   r   zPurePath._format_parsed_parts  sn    $: 0 0 5 5d ;;;cll--d1g6q954<D||$$T**r)   c                     	 | j                   S # t        $ rI | j                  | j                  | j                  | j
                        xs d| _         | j                   cY S w xY w)z[Return the string representation of the path, suitable for
        passing to system calls.r   )r   AttributeErrorr   r   r   r   r   s    r'   __str__zPurePath.__str__  s[    	99 	11$**dii26**> EAD I99	s    AA A c                     t        |       S rH   )r   r   s    r'   
__fspath__zPurePath.__fspath__  s    4yr)   c                 d    | j                   }t        |       j                  |j                  d      S )zNReturn the string representation of the path with forward (/)
        slashes.r1   )r   r   r   r   re   fs     r'   as_posixzPurePath.as_posix  s(     MM4y  ,,r)   c                 ,    t        j                  |       S )zaReturn the bytes representation of the path.  This is only
        recommended to use under Unix.)r   fsencoder   s    r'   	__bytes__zPurePath.__bytes__  s     {{4  r)   c                 j    dj                  | j                  j                  | j                               S )Nz{}({!r}))r   r   rq   r  r   s    r'   r   zPurePath.__repr__  s%      !8!8$--/JJr)   c                 4   | j                         st        d      | j                  }t        |      dk(  r!|d   dk(  rd|z   }| j	                         dd }n"|rd}| j	                         }nd}t        |       }|t        t        j                  |            z   S )	z Return the path as a 'file' URI.z.relative path can't be expressed as a file URIr   r5   :zfile:///Nzfile:zfile://)	is_absoluter<   r   r8   r  r   urlquote_from_bytesr   r  )re   r   prefixr   s       r'   as_urizPurePath.as_uri  s    !MNN

u:?uQx3%'F==?12&DF==?D Ft9D+BKK,=>>>r)   c                     	 | j                   S # t        $ rS t        | j                        rt	        |       | _         nt	        |       j                         | _         | j                   cY S w xY wrH   )r   r   r.   r   r   lowerr   s    r'   _str_normcasezPurePath._str_normcase  sY    	-,,, 	-!$--0,/I),/IOO,=),,,	-s    AA*)A*c                     	 | j                   S # t        $ rC | j                  j                  | j                  j
                        | _         | j                   cY S w xY wrH   )r   r   r  r   r   r   r   s    r'   _parts_normcasezPurePath._parts_normcase  sQ    	/... 	/*.*<*<*B*B4==CTCT*UD'...	/s    A	AAc                     	 | j                   S # t        $ rZ t        |       }|dk(  rd| _         n3t        | j                  j
                     }|j                  |      | _         | j                   cY S w xY w)Nr   rV   )r   r   r   _SWAP_SEP_AND_NEWLINEr   r   rN   )re   r   transs      r'   _lineszPurePath._lines  sm    		&%%% 	&4yH3%'"-dmm.?.?@%-%7%7%>"%%%	&s    A A10A1c                     t        |t              st        S | j                  |j                  k(  xr | j                  |j                  u S rH   )r   r   NotImplementedr  r   re   others     r'   __eq__zPurePath.__eq__  s;    %*!!!!U%8%88\T]]enn=\\r)   c                     	 | j                   S # t        $ r) t        | j                        | _         | j                   cY S w xY wrH   )r   r   hashr  r   s    r'   __hash__zPurePath.__hash__  s<    	:: 	d001DJ::	s    /A A c                     t        |t              r| j                  |j                  urt        S | j                  |j                  k  S rH   r   r   r   r  r  r  s     r'   __lt__zPurePath.__lt__  8    %*dmm5>>.Q!!##e&;&;;;r)   c                     t        |t              r| j                  |j                  urt        S | j                  |j                  k  S rH   r!  r  s     r'   __le__zPurePath.__le__  8    %*dmm5>>.Q!!##u'<'<<<r)   c                     t        |t              r| j                  |j                  urt        S | j                  |j                  kD  S rH   r!  r  s     r'   __gt__zPurePath.__gt__  r#  r)   c                     t        |t              r| j                  |j                  urt        S | j                  |j                  k\  S rH   r!  r  s     r'   __ge__zPurePath.__ge__"  r&  r)   c                 r    	 | j                   S # t        $ r | j                          | j                   cY S w xY w)z.The drive prefix (letter or UNC path), if any.)r   r   r   r   s    r'   r   zPurePath.drive'  s6    	99 	99	    %66c                 r    	 | j                   S # t        $ r | j                          | j                   cY S w xY w)zThe root of the path, if any.)r   r   r   r   s    r'   r   zPurePath.root0  s6    	:: 	::	r,  c                 r    	 | j                   S # t        $ r | j                          | j                   cY S w xY wrH   )r   r   r   r   s    r'   r   zPurePath._tail9  s:    	%$$$ 	%$$$	%r,  c                 8    | j                   | j                  z   }|S )z/The concatenation of the drive and root, or ''.)r   r   )re   anchors     r'   r0  zPurePath.anchorA  s     dii'r)   c                 *    | j                   }|sy|d   S )z!The final path component, if any.rV   )r   )re   r   s     r'   r{   zPurePath.nameG  s     zzBxr)   c                 |    | j                   }|j                  d      }d|cxk  rt        |      dz
  k  rn y||d S y)z{
        The final component's last suffix, if any.

        This includes the leading period. For example: '.txt'
        r   r   r5   NrV   r{   rfindr8   re   r{   r   s      r'   suffixzPurePath.suffixO  sD     yyJJsOq 3t9q=   8Or)   c                     | j                   }|j                  d      rg S |j                  d      }|j                  d      dd D cg c]  }d|z   	 c}S c c}w )z
        A list of the final component's suffixes, if any.

        These include the leading periods. For example: ['.tar', '.gz']
        r   r5   N)r{   r   lstripr   )re   r{   r7  s      r'   suffixeszPurePath.suffixes]  sS     yy==I{{3+/::c?12+>?f???s   Ac                     | j                   }|j                  d      }d|cxk  rt        |      dz
  k  r	n |S |d| S |S )z0The final path component, minus its last suffix.r   r   r5   Nr4  r6  s      r'   stemzPurePath.stemj  sH     yyJJsOq 3t9q=  K 8OKr)   c                 8   | j                   st        | d      | j                  }|r-|j                  |v s|j                  r|j                  |v s|dk(  rt        d|z        | j                  | j                  | j                  | j                  dd |gz         S )z-Return a new path with the file name changed. has an empty namer   zInvalid name %rNr2  )	r{   r<   r   r   r   r   r   r   r   )re   r{   r  s      r'   	with_namezPurePath.with_namet  s    yyt=>>MMquu}ahh$6F4SV;.$788&&tzz499'+zz#2$'?A 	Ar)   c                 >    | j                  || j                  z         S )z(Return a new path with the stem changed.)r?  r7  )re   r<  s     r'   	with_stemzPurePath.with_stem~  s    ~~dT[[011r)   c                    | j                   }|j                  |v s|j                  r|j                  |v rt        d|      |r|j	                  d      r|dk(  rt        d|z        | j
                  }|st        | d      | j                  }|s||z   }n|dt        |        |z   }| j                  | j                  | j                  | j                  dd |gz         S )zReturn a new path with the file suffix changed.  If the path
        has no suffix, add given suffix.  If the given suffix is an empty
        string, remove the suffix from the path.
        zInvalid suffix r   zInvalid suffix %rr>  Nr2  )r   r   r   r<   r   r{   r7  r8   r   r   r   r   )re   r7  r  r{   
old_suffixs        r'   with_suffixzPurePath.with_suffix  s    
 MM55F?ahh188v+=F<==&++C0FcM0F;<<yyt=>>[[
&=D)#j/)*V3D&&tzz499'+zz#2$'?A 	Ar)   F)walk_upc               &   |rd}t        j                  d|d        | j                  |g| }t        |gt	        |j
                        z         D ]c  \  }}| j                  |      r np|s"t        t        |       dt        |            |j                  dk(  sMt        dt        |      d       t        t        |       d	t        |      d
      dg|z  | j                  t        |j                        d z   } | j                  | S )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 {remove}z#pathlib.PurePath.relative_to(*args)      removez is not in the subpath of r6   z'..' segment in z cannot be walkedz and z have different anchorsN)warnings_deprecatedr   	enumerater   parentsis_relative_tor<   r   r{   r   r8   )re   r  rE  rM  msgstepr   r]   s           r'   relative_tozPurePath.relative_to  s    >C   !F(/1"""57;7#UGd5==.A$AB 	YJD$""4( CI=0J3u:.!YZZd" #3CJ>AR!STT	Y D	}E#e*?VWXX

3tzz?+; <<!t!!5))r)   c                    |rd}t        j                  d|d        | j                  |g| }|| k(  xs || j                  v S )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 {remove}z&pathlib.PurePath.is_relative_to(*args)rG  rJ  )rL  rM  r   rO  )re   r  rM  rQ  s       r'   rP  zPurePath.is_relative_to  sU     >C   !I!$W6"""57;7}5 55r)   c                     | j                   s| j                  r0| j                   | j                  z   ft        | j                        z   S t        | j                        S )zZAn object providing sequence-like access to the
        components in the filesystem path.)r   r   r   r   r   s    r'   r]   zPurePath.parts  sD     ::JJ*,uTZZ/@@@$$r)   c                 (     | j                   | g| S )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).
        )r   r   s     r'   joinpathzPurePath.joinpath  s     "t!!$666r)   c                 P    	 | j                  |      S # t        $ r	 t        cY S w xY wrH   )rW  r   r  re   keys     r'   __truediv__zPurePath.__truediv__  s+    	"==%% 	"!!	"s    %%c                 R    	 | j                  ||       S # t        $ r	 t        cY S w xY wrH   )r   r   r  rY  s     r'   __rtruediv__zPurePath.__rtruediv__  s/    	"%%c400 	"!!	"s    &&c                 ~    | j                   }| j                  }| j                  }|s| S | j                  |||dd       S )zThe logical parent of the path.Nr2  )r   r   r   r   )re   r   r   r   s       r'   parentzPurePath.parent  sB     jjyyzzK&&sD$s)<<r)   c                     t        |       S )z*A sequence of this path's logical parents.)r   r   s    r'   rO  zPurePath.parents  s    
 D!!r)   c                 "   ddl }| j                  |u r#t        | j                  xr | j                        S | j                  t
        u r%| j                  D ]  }|j                  d      s y y| j                  j                  t        |             S )zSTrue if the path is absolute (has both a root and, if applicable,
        a drive).r   Nr1   TF)
r   r   boolr   r   r   r   r   isabsr   )re   r   r   s      r'   r  zPurePath.is_absolute  sw     	==F"

0tyy11]]i'  ??3'  ==&&s4y11r)   c                 (   | j                   t        u s| j                  sy| j                  j	                  d      ry| j                  d   j                  d      d   j                  d      d   j                  d      }|j                         t        v S )zaReturn True if the path contains one of the special names reserved
        by the system, if any.Fz\\r2  r   r   r
   )	r   r   r   r   r   	partitionrstripupper_WIN_RESERVED_NAMESre   r{   s     r'   is_reservedzPurePath.is_reserved  sz     ==I%TZZ ::  (zz"~'',Q/99#>qAHHMzz|222r)   Nr?   c                p   t        |t              s| j                  |      }|t        | j                        }t        |j                  |      }|j                  s|j                  r|j                  | j                        duS |j                  r|j                  | j                        duS t        d      )zE
        Return True if this path matches the given pattern.
        Nzempty pattern)r   r   r   r.   r   r_   r  r   r   rO   r   searchr<   )re   path_patternr?   patterns       r'   rO   zPurePath.match  s     ,1--l;L!/>N()<)<nM!2!2==-T99>>$++.d::_--r)   )7rq   rr   rs   rt   r   r   r   r   r   r   rf   r   classmethodr   r   r   r   r   r   r  r  r   r  propertyr  r  r  r  r  r"  r%  r(  r*  r   r   r   r0  r{   r7  r:  r<  r?  rA  rD  rS  rP  r]   rW  r[  r]  r_  rO  r  rk  rO   ru   r)   r'   r   r   #  s   &IN wwH#,
 .) ! !&! + +-!
K?( 	- 	- / / & &]
<
=
<
=
     % %  
     
@ 
@  A2A* ;@ *6
6 % %7"" = = " "2 3  59 .r)   r   c                       e Zd ZdZeZdZy)r   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.
    ru   N)rq   rr   rs   rt   r   r   r   ru   r)   r'   r   r   "  s    
 HIr)   r   c                        e Zd ZdZddlZeZdZy)r   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   Nru   )rq   rr   rs   rt   r   r   r   ru   r)   r'   r   r   ,  s    
 HIr)   r   c                   |    e Zd ZdZdZdddZd ZdddZd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zd Z	 	 d5dZd Zd6dZd Zd7dZd Zd Zd ZdddZdddZd8dZ fdZd  Zd! Zd" Z e!d#        Z"e!d$        Z#d% Z$d9d&Z%d' Z&d( Z'd) Z(d:d*Z)d;d+Z*ddd,Z+d- Z,d9d.Z-d/ Z.d0 Z/d1 Z0d9d2Z1d3 Z2d4 Z3 xZ4S )<r   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.
    ru   Tfollow_symlinksc                0    t        j                  | |      S )zh
        Return the result of the stat() system call on this path, like
        os.stat() does.
        rv  )r   stat)re   rw  s     r'   ry  z	Path.statE  s    
 wwt_==r)   c                 &    | j                  d      S )z
        Like stat(), except if the path points to a symlink, the symlink's
        status information is returned, rather than its target's.
        Frv  )ry  r   s    r'   lstatz
Path.lstatL  s    
 yyy//r)   c                    	 | j                  |       y# t        $ r}t        |      s Y d}~yd}~wt        $ r Y yw xY w)z
        Whether this path exists.

        This method normally follows symlinks; to check whether a symlink exists,
        add the argument follow_symlinks=False.
        rv  NFT)ry  r   r(   r<   )re   rw  es      r'   existszPath.existsV  sE    	IIoI6   	 # 		s    	>/>>c                     	 t        | j                         j                        S # t        $ r}t	        |      s Y d}~yd}~wt
        $ r Y yw xY w)z3
        Whether this path is a directory.
        NF)r   ry  st_moder   r(   r<   re   r}  s     r'   rj   zPath.is_dirh  I    
	499;..// 	 #  		   "% 	A?AAc                     	 t        | j                         j                        S # t        $ r}t	        |      s Y d}~yd}~wt
        $ r Y yw xY w)zq
        Whether this path is a regular file (also True for symlinks pointing
        to regular files).
        NF)r
   ry  r  r   r(   r<   r  s     r'   is_filezPath.is_filex  sI    

	499;..// 	 #  		r  c                 8    | j                   j                  |       S )z5
        Check if this path is a mount point
        )r   ismountr   s    r'   is_mountzPath.is_mount  s     }}$$T**r)   c                     	 t        | j                         j                        S # t        $ r}t	        |      s Y d}~yd}~wt
        $ r Y yw xY w)z7
        Whether this path is a symbolic link.
        NF)r	   r{  r  r   r(   r<   r  s     r'   
is_symlinkzPath.is_symlink  sG    		4::<//00 	 # 		r  c                 8    | j                   j                  |       S )z2
        Whether this path is a junction.
        )r   
isjunctionr   s    r'   is_junctionzPath.is_junction  s     }}''--r)   c                     	 t        | j                         j                        S # t        $ r}t	        |      s Y d}~yd}~wt
        $ r Y yw xY w)z6
        Whether this path is a block device.
        NF)r   ry  r  r   r(   r<   r  s     r'   is_block_devicezPath.is_block_device  r  r  c                     	 t        | j                         j                        S # t        $ r}t	        |      s Y d}~yd}~wt
        $ r Y yw xY w)z:
        Whether this path is a character device.
        NF)r   ry  r  r   r(   r<   r  s     r'   is_char_devicezPath.is_char_device  r  r  c                     	 t        | j                         j                        S # t        $ r}t	        |      s Y d}~yd}~wt
        $ r Y yw xY w)z.
        Whether this path is a FIFO.
        NF)r   ry  r  r   r(   r<   r  s     r'   is_fifozPath.is_fifo  I    
	DIIK//00 	 #  		r  c                     	 t        | j                         j                        S # t        $ r}t	        |      s Y d}~yd}~wt
        $ r Y yw xY w)z0
        Whether this path is a socket.
        NF)r   ry  r  r   r(   r<   r  s     r'   	is_socketzPath.is_socket  r  r  c                     | j                         }	 |j                         }| j                  j	                  ||      S # t        $ r" | j                  |      j                         }Y Fw xY w)zoReturn whether other_path is the same or not as this file
        (as returned by os.path.samefile()).
        )ry  r   r   r   samestat)re   
other_pathstother_sts       r'   samefilezPath.samefile  sc     YY[	=!(H }}%%b(33  	=))*5::<H	=s   > (A)(A)Nc                 h    d|vrt        j                  |      }t        j                  | |||||      S )z|
        Open the file pointed by this path and return a file object, as
        the built-in open() function does.
        b)iotext_encodingopen)re   mode	bufferingencodingerrorsnewlines         r'   r  z	Path.open  s4     d?''1HwwtT9hHHr)   c                 r    | j                  d      5 }|j                         cddd       S # 1 sw Y   yxY w)zK
        Open the file in bytes mode, read it, and close the file.
        rbr  N)r  readr  s     r'   
read_byteszPath.read_bytes  s2     YYDY! 	Q668	 	 	s   -6c                     t        j                  |      }| j                  d||      5 }|j                         cddd       S # 1 sw Y   yxY w)zJ
        Open the file in text mode, read it, and close the file.
        r)r  r  r  N)r  r  r  r  )re   r  r  r  s       r'   	read_textzPath.read_text   sF     ##H-YYC(6YB 	a668	 	 	s   AAc                     t        |      }| j                  d      5 }|j                  |      cddd       S # 1 sw Y   yxY w)zO
        Open the file in bytes mode, write to it, and close the file.
        wbr  N)
memoryviewr  write)re   dataviewr  s       r'   write_byteszPath.write_bytes  s>    
 $YYDY! 	!Q774=	! 	! 	!s	   9Ac                    t        |t              s"t        d|j                  j                  z        t        j                  |      }| j                  d|||      5 }|j                  |      cddd       S # 1 sw Y   yxY w)zN
        Open the file in text mode, write to it, and close the file.
        zdata must be str, not %sw)r  r  r  r  N)	r   r   r   r   rq   r  r  r  r  )re   r  r  r  r  r  s         r'   
write_textzPath.write_text  sw     $$6 NN334 5 5##H-YYC(67YS 	!WX774=	! 	! 	!s   A88Bc              #   f   K   t        j                  |       D ]  }| j                  |        yw)zYield path objects of the directory contents.

        The children are yielded in arbitrary order, and the
        special entries '.' and '..' are not included.
        N)r   listdirr~   rj  s     r'   iterdirzPath.iterdir  s1      JJt$ 	1D**400	1s   /1c                 ,    t        j                  |       S rH   )r   ro   r   s    r'   ri   zPath._scandir%  s     zz$r)   c                    t        |       }| j                  }|r| | j                  j                   | }n|dk7  r| | }n|}| j	                  |      }||_        | j                  |_        | j                  |_	        ||gz   |_
        |S r   )r   r   r   r   r   r   r   r   r   r   r   )re   r{   r   r   r   s        r'   r~   zPath._make_child_relpath+  s    t9zz"DMM$5$5#6tf=H_"D6*HH!!(+	JJ	YY
 D6Mr)   rl  c             #     K   t        j                  d| |       |st        dj                  |            | j	                  |      \  }}}|s|rt        d      |d   | j                  j                  | j                  j                  fv r|j                  d       t        t        |      | j                  |      }|j                  |       D ]  }|  yw)zIterate over this subtree and yield all existing files (of any
        kind, including directories) matching the given relative pattern.
        zpathlib.Path.globzUnacceptable pattern: {!r}%Non-relative patterns are unsupportedr2  rV   N)r   auditr<   r   r   NotImplementedErrorr   r   r   rY   rD   r   rp   re   rp  r?   r   r   r>   selectorr   s           r'   globz	Path.glob;  s      			%tW59@@IJJ#'#3#3G#< T=$%&MNN2;4==,,dmm.B.BCC  $!%"6~V%%d+ 	AG	s   CCc             #     K   t        j                  d| |       | j                  |      \  }}}|s|rt        d      |rB|d   | j                  j
                  | j                  j                  fv r|j                  d       t        dt        |      z   | j                  |      }|j                  |       D ]  }|  yw)zRecursively yield all existing files (of any kind, including
        directories) matching the given relative pattern, anywhere in
        this subtree.
        zpathlib.Path.rglobr  r2  rV   )r4   N)r   r  r   r  r   r   r   rY   rD   r   rp   r  s           r'   rglobz
Path.rglobK  s     
 			&g6#'#3#3G#< T=$%&MNNwr{t}}'8'8$--:N:N&OO  $!'E-,@"@$--Q_`%%d+ 	AG	s   B>C c              #     K   t        j                  d| ||       | g}|r|j                         }t        |t              r| '	 |j                         }|5  g }g }	|D ]N  }
	 |
j                  |      }|r|j                  |
j                         4|	j                  |
j                         P 	 ddd       |r|	f n|j                  |	f       |t        |      D cg c]  }|j                  |       c}z  }|ryy# t        $ r}| ||       Y d}~d}~ww xY w# t        $ r d}Y w xY w# 1 sw Y   xY wc c}w w)zBWalk the directory tree from this directory, similar to os.walk().zpathlib.Path.walkNrv  F)r   r  popr   r   ri   r   rj   rY   r{   reversedr~   )re   top_downon_errorrw  r   r   r   errorr   	filenamesr   rj   ds                r'   r   z	Path.walkZ  sK    		%tXG99;D$&
!]]_
  5	' 
5E'!&o!N
  

3!((4
55 Hi//dHi898H;MNad..q1NNEM   'UO # '!&'5 5( Os~   AE
D E

D9#D(5;D914E
%E=E
E
	D%
D E
 D%%E
(D63D95D66D99E>E
c                 V    |rd}t        j                  d|d       t        |   |  y )Nzvsupport for supplying keyword arguments to pathlib.PurePath is deprecated and scheduled for removal in Python {remove}zpathlib.PurePath(**kwargs)rG  rJ  )rL  rM  r   rf   )re   r   r   rQ  r   s       r'   rf   zPath.__init__  s.    PC  !=s7S$r)   c                 z    | t         u rt        j                  dk(  rt        nt        } t
        j                  |       S )Nr   )r   r   r{   r   r   r   r   r   s      r'   r   zPath.__new__  s)    $;!#D+iC~~c""r)   c                 >    t        j                  dt        d       | S )Nz}pathlib.Path.__enter__() is deprecated and scheduled for removal in Python 3.13; Path objects as a context manager is a no-opr   )
stacklevel)rL  warnDeprecationWarningr   s    r'   	__enter__zPath.__enter__  s#     	 + )Q	8 r)   c                      y rH   ru   )re   tvtbs       r'   __exit__zPath.__exit__  s    r)   c                 ,     |        j                         S )z<Return a new path pointing to the current working directory.)absoluterC   s    r'   cwdzPath.cwd  s     u~~r)   c                 .     | d      j                         S )zrReturn a new path pointing to the user's home directory (as
        returned by os.path.expanduser('~')).
        ~)
expanduserr  s    r'   homez	Path.home  s    
 3x""$$r)   c                 :   | j                         r| S | j                  r&| j                  j                  | j                        }nFt	        j
                         }| j                  s&| j                  s| j                  |      }||_	        |S | j                  ||       S )zReturn an absolute version of this path by prepending the current
        working directory. No normalization or symlink resolution is performed.

        Use resolve() to get the canonical path to a file.
        )
r  r   r   abspathr   getcwdr   r   r   r   )re   r  results      r'   r  zPath.absolute  s}     KZZ--''

3C))+C 99TZZ++C0!!!#t,,r)   c                    d }	 | j                   j                  | |      }| j                  |      }|s	 |j	                          |S |S # t        $ r} ||        d}~ww xY w# t        $ r} ||       Y d}~|S d}~ww xY w)zl
        Make the path absolute, resolving all symlinks on the way and also
        normalizing it.
        c                     t        | dd      }| j                  t        k(  s	|t        k(  rt	        d| j
                  z        y )Nr"   r   zSymlink loop from %r)r#   r!   r   _WINERROR_CANT_RESOLVE_FILENAMERuntimeErrorfilename)r}  r"   s     r'   check_eloopz!Path.resolve.<locals>.check_eloop  s?    q*a0Hww%8/N#N"#9AJJ#FGG $Or)   )strictN)r   realpathr   r   ry  )re   r  r  sr}  r   s         r'   resolvezPath.resolve  s    	H
	&&tF&;A q!  q  	N	  As.   A
 A$ 
	A!	AA!$	B -A;;B c                     	 ddl }|j                  | j                         j                        j                  S # t
        $ r t        d      w xY w)z:
        Return the login name of the file owner.
        r   Nz*Path.owner() is unsupported on this system)pwdgetpwuidry  st_uidpw_nameImportErrorr  )re   r  s     r'   ownerz
Path.owner  sI    	T<<		 2 23;;; 	T%&RSS	T	   69 Ac                     	 ddl }|j                  | j                         j                        j                  S # t
        $ r t        d      w xY w)z8
        Return the group name of the file gid.
        r   Nz*Path.group() is unsupported on this system)grpgetgrgidry  st_gidgr_namer  r  )re   r  s     r'   groupz
Path.group  sI    
	T<<		 2 23;;; 	T%&RSS	Tr  c                     t        t        d      st        d      | j                  t        j                  |             S )zD
        Return the path to which the symbolic link points.
        readlinkz*os.readlink() not available on this system)hasattrr   r  r   r   r   s    r'   r   zPath.readlink  s4     r:&%&RSS!!"++d"344r)   c                    |r	 t        j                  | d       yt         j                  t         j                  z  }|s|t         j
                  z  }t        j                  | ||      }t        j                  |       y# t        $ r Y nw xY w)zS
        Create this file with the given access mode, if it doesn't exist.
        N)r   utimer   O_CREATO_WRONLYO_EXCLr  close)re   r  exist_okrP   fds        r'   touchz
Path.touch  ss    
 t$
 

R[[(RYYEWWT5$'
  s   A> >	B
	B
c                    	 t        j                  | |       y# t        $ rF |r| j                  | k(  r | j                  j                  dd       | j                  |d|       Y yt        $ r |r| j                         s Y yw xY w)z<
        Create a new directory at this given path.
        T)rO  r  FN)r   mkdirFileNotFoundErrorr_  r   rj   )re   r  rO  r  s       r'   r  z
Path.mkdir  s{    	HHT4   	?dkkT1KKdT:JJtUXJ> 	 4;;= $1	s    AB'BBc                4    t        j                  | ||       y)zF
        Change the permissions of the path, like os.chmod().
        rv  N)r   chmod)re   r  rw  s      r'   r  z
Path.chmod-  s     	t_=r)   c                 *    | j                  |d       y)z
        Like chmod(), except if the path points to a symlink, the symlink's
        permissions are changed, rather than its target's.
        Frv  N)r  )re   r  s     r'   lchmodzPath.lchmod3  s    
 	

4
/r)   c                 T    	 t        j                  |        y# t        $ r |s Y yw xY w)zd
        Remove this file or link.
        If the path is a directory, use rmdir() instead.
        N)r   unlinkr  )re   
missing_oks     r'   r  zPath.unlink:  s,    
	IIdO  	 	s    ''c                 .    t        j                  |        y)zF
        Remove this directory.  The directory must be empty.
        N)r   rmdirr   s    r'   r  z
Path.rmdirE  s     	r)   c                 P    t        j                  | |       | j                  |      S )a2  
        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.
        )r   renamer   re   targets     r'   r  zPath.renameK  s#     			$!!&))r)   c                 P    t        j                  | |       | j                  |      S )aS  
        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.
        )r   r   r   r  s     r'   r   zPath.replaceX  s#     	

4 !!&))r)   c                 h    t        t        d      st        d      t        j                  || |       y)z
        Make this path a symlink pointing to the target path.
        Note the order of arguments (link, target) is the reverse of os.symlink.
        symlinkz)os.symlink() not available on this systemN)r  r   r  r  )re   r  target_is_directorys      r'   
symlink_tozPath.symlink_toe  s+    
 r9%%&QRR


64!45r)   c                 f    t        t        d      st        d      t        j                  ||        y)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.
        linkz&os.link() not available on this systemN)r  r   r  r!  r  s     r'   hardlink_tozPath.hardlink_ton  s(     r6"%&NOO
r)   c                 ^   | j                   s| j                  s| j                  r| j                  d   dd dk(  rs| j                  j	                  | j                  d         }|dd dk(  rt        d      | j                  |      \  }}}| j                  |||| j                  dd z         S | S )zl Return a new path with expanded ~ and ~user constructs
        (as returned by os.path.expanduser)
        r   Nr5   r  z#Could not determine home directory.)r   r   r   r   r  r  r   r   )re   homedirr   r   r   s        r'   r  zPath.expanduserx  s     tyyJJ4::a=!,3mm..tzz!}=Gr{c!"#HII"..w7OCt**3dTZZ^6KLLr)   )r  r2  NNN)NN)NNN)TNF)F)i  T)i  FF)5rq   rr   rs   rt   r   ry  r{  r~  rj   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  ri   r~   r  r  r   rf   r   r  r  rq  r  r  r  r  r  r  r   r
  r  r  r  r  r  r  r   r  r"  r  r   r   s   @r'   r   r   :  s7    I&* >0 )- $ "+.    	4 59"&I!	!1   /3   04 +OZ #

     % %-06T	T5," .2 >0	**6r)   r   c                   :    e Zd ZdZdZej                  dk(  rd Zyy)r   zsPath subclass for non-Windows systems.

    On a POSIX system, instantiating a Path should return this object.
    ru   r   c                 4    t        d| j                  d      Nzcannot instantiate z on your systemr  rq   r   s      r'   r   zPosixPath.__new__  "    %%cll%5_EG Gr)   Nrq   rr   rs   rt   r   r   r{   r   ru   r)   r'   r   r     $     I	ww$	G r)   r   c                   :    e Zd ZdZdZej                  dk7  rd Zyy)r   zqPath subclass for Windows systems.

    On a Windows system, instantiating a Path should return this object.
    ru   r   c                 4    t        d| j                  d      r'  r(  r   s      r'   r   zWindowsPath.__new__  r)  r)   Nr*  ru   r)   r'   r   r     r+  r)   r   )Drt   rM   	functoolsr  r   r   rI   r   rL  _collections_abcr   r!   r   r   r   r   ry  r   r	   r
   r   r   r   r   urllib.parser   r  __all__	frozensetri  _WINERROR_NOT_READY_WINERROR_INVALID_NAMEr  r$   r%   r(   cacher.   rN   r   _FNMATCH_PREFIX_FNMATCH_SUFFIXr   r8   rX   r   	maketransr  	lru_cacherD   rQ   r_   ra   r7   r;   r=   r:   r9   r   r   r   PathLikeregisterr   r   r   r   r   )cs   0r'   <module>r=     se     	 	  	 
  % / / P P P @  5/01s1#Y01/01s1#Y01    "&  7E51 #% 
H
 * * $57#4#4S#9#?#?#D  s?+c/.B-BC	T-	.
--t40
1  : :0 S!; ";
 #3 #3L7 7. i  	  @ $'A ,@8 @:w.v w.x   X H h J	8 J	Z
Gm 
G
G$ 
Ga+ 10s   G>
.H
