
    :v#a	                     b   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Zd dl	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZmZmZmZmZmZmZ 	 d dlmZmZ n# e$ r d dlmZm Z Y nw xY w	 e!Z!n# e"$ r
 ej!        Z!Y nw xY w	 e#Z#n# e"$ r e$Z#Y nw xY wd	Z%	 d dl&Z& ej'                    dd
         dk    rej(        dk    rd dl&m)Z) ndZ%dZ)n# e$ r dZ&Y nw xY wg dZ*ej(        dk     Z+dZ,d Z-d Z. G d de/          Z0 G d de0          Z1 G d de0          Z2 e1            Z3 e2            Z4 G d d          Z5 G d de5          Z6 e6            Z7ed             Z8d Z9 e:ed           r  ej;                    e9          Z9 G d! d"          Z< G d# d$          Z= G d% d&e<          Z> G d' d(e<          Z? G d) d*e<          Z@ G d+ d,e
          ZA G d- d.e/          ZB G d/ d0eB          ZC G d1 d2eB          ZD G d3 d4eB          ZE G d5 d6eEeC          ZF G d7 d8eEeD          ZGdS )9    N)Sequence)contextmanager)EINVALENOENT)
attrgetter)S_ISDIRS_ISLNKS_ISREGS_ISSOCKS_ISBLKS_ISCHRS_ISFIFO)quoter   )r   quote_from_bytesT   )   r      r   )_getfinalpathnameF)PurePathPurePosixPathPureWindowsPathPath	PosixPathWindowsPathr   asciic                     d | D             S )Nc                 p    g | ]3}t          |t                    r|                    t                    n|4S  )
isinstanceunicodeencode_py2_fs_encoding).0parts     'lib/python3.11/site-packages/pathlib.py
<listcomp>z!_py2_fsencode.<locals>.<listcomp>9   sL     ) ) ) .8g-F-F DKK()))) ) )    r    )partss    r'   _py2_fsencoder+   7   s#    ) )"') ) ) )r)   c                     d| v pd| v pd| v S )N*?[r    )pats    r'   _is_wildcard_patternr1   <   s      #:11scz1r)   c                   $    e Zd ZdZd Zd Zd ZdS )_FlavourzPA flavour implements a particular (platform-specific) set of path
    semantics.c                 (    | j         j        | _        d S N)sepjoinselfs    r'   __init__z_Flavour.__init__F   s    HM			r)   c                    t           rt          |          }g }| j        }| j        }dx}}t	          |          }|D ]}|s|r|                    ||          }|                     |          \  }}}	||	v rPt	          |	                    |                    D ],}
|
r(|
dk    r"|                    t          |
                     -n*|	r(|	dk    r"|                    t          |	                     |s|r(|s$|D ]!}|                     |          d         }|r n" n|s|r|                    ||z              |
                                 |||fS )N .r   )_py2r+   r6   altsepreversedreplace	splitrootsplitappendinternreverse)r9   r*   parsedr6   r?   drvrootitr&   relxs              r'   parse_partsz_Flavour.parse_partsI   s    	)!%((Ehde__ 	 	D  1||FC00!^^D11NCsczz!#))C..11 1 1A 1Q#XXfQii0001  /3#::MM&++... 	d 	 " !# " ""nnT2215 "!E"	  	&$ 	&MM#*%%%D&  r)   c                     |r|s|r||||z   g|dd         z   fS nM|rC||k    s,|                      |          |                      |          k    r||||dd         z   fS n||||z   fS |||fS )z
        Join the two paths represented by the respective
        (drive, root, parts) tuples.  Return a new (drive, root, parts) tuple.
           N)casefold)r9   rH   rI   r*   drv2root2parts2s          r'   join_parsed_partsz_Flavour.join_parsed_partsm   s    
  		- >C >EC%K=6!"":#=== 	-s{{dmmD11T]]35G5GGGD%&*"444 H
 efn,,UF""r)   N)__name__
__module____qualname____doc__r:   rM   rT   r    r)   r'   r3   r3   B   sL         " " ""! "! "!H# # # # #r)   r3   c            
          e Zd ZdZdZdZeZeduZ	 e
d  e ed           ed          dz             D                        e
d	  e ed
           ed          dz             D                       z  ZdZ e
g d           e
d  edd          D                       z   e
d  edd          D                       z  ZefdZd Zd Zd ZefdZd Zd Zd ZdS )_WindowsFlavour\/TNc              #   4   K   | ]}t          |          V  d S r5   chrr%   rL   s     r'   	<genexpr>z_WindowsFlavour.<genexpr>   (      ::qCFF::::::r)   azrO   c              #   4   K   | ]}t          |          V  d S r5   r^   r`   s     r'   ra   z_WindowsFlavour.<genexpr>   rb   r)   AZz\\?\)CONPRNAUXNULc                     g | ]}d |z  S )zCOM%dr    r%   is     r'   r(   z_WindowsFlavour.<listcomp>       ///QWq[///r)   
   c                     g | ]}d |z  S )zLPT%dr    rm   s     r'   r(   z_WindowsFlavour.<listcomp>   ro   r)   c                    |dd         }|dd         }||k    r3||k    r-|                      |          \  }}|dd         }|dd         }nd}|dd         }||k    r||k    r||k    r|                    |d          }|dk    rl|                    ||dz             }||dz   k    rJ|dk    rt          |          }|r||d|         z   |||dz   d          fS |d |         |||dz   d          fS dx}	}
|dk    r|| j        v r|d d         }	|dd          }|}||k    r|}
|                    |          }||	z   |
|fS )Nr   rO   r   r<   r   :)_split_extended_pathfindlendrive_letterslstrip)r9   r&   r6   firstsecondprefixthirdindexindex2rH   rI   s              r'   rB   z_WindowsFlavour.splitroot   s   QqS	accMMesll  44T::LFD1IE!A#YFFFQqS	cMMesllu||
 IIc1%%E{{3	22 UQY&&||!$T C%QvX6T&())_LL#GVG}c4q		?BBdS==Ud&888rr(C8DEC<<D;;s##D|T4''r)   c                 *    |                                 S r5   lowerr9   ss     r'   rP   z_WindowsFlavour.casefold   s    wwyyr)   c                     d |D             S )Nc                 6    g | ]}|                                 S r    r   )r%   ps     r'   r(   z2_WindowsFlavour.casefold_parts.<locals>.<listcomp>   s     )))a		)))r)   r    r9   r*   s     r'   casefold_partsz_WindowsFlavour.casefold_parts   s    ))5))))r)   c                     t          |          }|st          j                    S t          "|                     t          |                    S d S r5   )strosgetcwdr   _ext_to_normal)r9   pathr   s      r'   resolvez_WindowsFlavour.resolve   sI    II 	9;;(&&'8';';<<<tr)   c                     d}|                     |          rC|d d         }|dd          }|                     d          r||d d         z  }d|dd          z   }||fS )Nr<      zUNC\r   r[   )
startswith)r9   r   
ext_prefixr|   s       r'   ru   z$_WindowsFlavour._split_extended_path   su    <<
## 	!rrUF!""A||G$$ !!BQB%1QRR5Lqyr)   c                 8    |                      |          d         S NrO   )ru   r   s     r'   r   z_WindowsFlavour._ext_to_normal   s    ((++A..r)   c                     |sdS |d                              d          rdS |d                             d          d                                         | j        v S )NFr   z\\rs   r=   )r   	partitionupperreserved_namesr   s     r'   is_reservedz_WindowsFlavour.is_reserved   sa    
  	58v&& 	5Ry""3''*0022d6IIIr)   c                 j   |j         }t          |          dk    rc|d         dk    rW|                                dd                              d          }d|dt	          |                    d                    S dt	          |                                                    d                    z   S )Nr   rO   rt   r\   zfile:///zutf-8zfile:)driverw   as_posixry   urlquote_from_bytesr#   )r9   r   r   rests       r'   make_uriz_WindowsFlavour.make_uri   s    
u::??uQx3==??122&--c22DD*4;;w+?+?@@@B B 01G1G1P1PQQQQr)   )rU   rV   rW   r6   r?   has_drvntpathpathmodntis_supportedsetrangeordrx   ext_namespace_prefixr   rB   rP   r   r   ru   r   r   r   r    r)   r'   rZ   rZ      s        CFGGdNL 	::EE##c((CCHHqL99:::::::EE##c((CCHHqL99:::::	;  % 	((())//%%2,,///00	1//%%2,,///00	1  #& %( %( %( %(N  * * *   2F    / / /
J 
J 
J
R 
R 
R 
R 
Rr)   rZ   c                   \    e Zd ZdZdZdZeZej	        dk    Z
efdZd Zd Zd Zd	 Zd
 ZdS )_PosixFlavourr\   r<   Fr   c                     |rQ|d         |k    rE|                     |          }t          |          t          |          z
  dk    rd|dz  |fS d||fS dd|fS )Nr   r   r<   )ry   rw   )r9   r&   r6   stripped_parts       r'   rB   z_PosixFlavour.splitroot  sq     	 DGsNN KK,,M 4yy3}---2237M113--r4<r)   c                     |S r5   r    r   s     r'   rP   z_PosixFlavour.casefold  s    r)   c                     |S r5   r    r   s     r'   r   z_PosixFlavour.casefold_parts  s    r)   c                     | j         |j        i fd|                                rdnt          j                    } |t          |                    pS )Nc                    |                     
          rd} |                    
          D ]}|r|dk    r|dk    r|                     
          \  } }}+| 
z   |z   }|	v r	|         } | Bt          d|z            	                     |          }d 	|<    | |          } | 	|<   # t
          $ r}|j        t          k    r |} Y d }~d }~ww xY w| S )Nr<   r=   ..zSymlink loop from %r)r   rC   
rpartitionRuntimeErrorreadlinkOSErrorerrnor   )r   r   name_newpathtargete_resolveaccessorseenr6   s          r'   r   z'_PosixFlavour.resolve.<locals>._resolve  s.   s## 

3 ) ) ts{{4<<!%!5!5JD!Q*t+d??=D' &'='GHHH
)%..w77F %)DM#8D&11D$(DMM  # # #w&(("DDDDDD	# Ks   B//
C9CCr<   )r6   	_accessoris_absoluter   r   r   )r9   r   baser   r   r   r6   s      @@@@r'   r   z_PosixFlavour.resolve  s    h>"	 "	 "	 "	 "	 "	 "	 "	J %%''8rrRY[[xc$ii((/C/r)   c                     dS )NFr    r   s     r'   r   z_PosixFlavour.is_reservedB  s    ur)   c                 D    t          |          }dt          |          z   S )Nzfile://)bytesr   )r9   r   bpaths      r'   r   z_PosixFlavour.make_uriE  s#     d.u5555r)   N)rU   rV   rW   r6   r?   r   	posixpathr   r   r   r   rB   rP   r   r   r   r   r    r)   r'   r   r      s        
CFGGGtOL"%            *0 *0 *0X  6 6 6 6 6r)   r   c                       e Zd ZdZdS )	_AccessorzjAn accessor implements a particular (system-specific or not) way of
    accessing paths on the filesystem.N)rU   rV   rW   rX   r    r)   r'   r   r   P  s        * * * *r)   r   c                      e Zd Zd Zd Z eej                  Z eej                  Z eej                  Z eej	                  Z	 eej
                  Z
 eed          r eej                  Znd Z eej                  Z eej                  Z eej                  Z eej                  Zej        dk    r eej                  Zerer eej                  Znd Zned             Z eej                  Zd Zd	S )
_NormalAccessorc                 `     t          j                    fd            }t          |          S )Nc                 0     t          |           g|R  S r5   r   )pathobjargsstrfuncs     r'   wrappedz._NormalAccessor._wrap_strfunc.<locals>.wrappedX  s!    73w<</$////r)   	functoolswrapsstaticmethodr   r   s   ` r'   _wrap_strfuncz_NormalAccessor._wrap_strfuncW  s?    		!	!	0 	0 	0 	0 
"	!	0G$$$r)   c                 `     t          j                    fd            }t          |          S )Nc                 L     t          |           t          |          g|R  S r5   r   )pathobjApathobjBr   r   s      r'   r   z5_NormalAccessor._wrap_binary_strfunc.<locals>.wrapped^  s)    73x==#h--?$????r)   r   r   s   ` r'   _wrap_binary_strfuncz$_NormalAccessor._wrap_binary_strfunc]  sD    		!	!	@ 	@ 	@ 	@ 
"	!	@G$$$r)   lchmodc                      t          d          )Nz%lchmod() not available on this systemNotImplementedError)r9   r   modes      r'   r   z_NormalAccessor.lchmodp  s    %&MNNNr)   r   r   c                      t          d          )Nz&symlink() not available on this systemr   rc   btarget_is_directorys      r'   symlinkz_NormalAccessor.symlink  s    )*RSSSr)   c                 `    t          j        t          |           t          |                    S r5   )r   r   r   r   s      r'   r   z_NormalAccessor.symlink  s     :c!ffc!ff---r)   c                 *    t          j        |          S r5   )r   r   r9   r   s     r'   r   z_NormalAccessor.readlink  s    {4   r)   N)rU   rV   rW   r   r   r   statlstatopenlistdirchmodhasattrr   mkdirunlinkrmdirrenamesysversion_inforA   r   supports_symlinksr   r   utimer   r    r)   r'   r   r   U  s       % % %% % % =!!DM"(##E=!!DmBJ''GM"(##Ewr8 Ory))	O 	O 	O M"(##E]29%%FM"(##E!!"),,F
6!!&&rz22	 
. 	T**2:66GGT T T T 
	. 	. 
	. M"(##E! ! ! ! !r)   r   c              #       K   	  j           V  d S # t          $ rE i  fd}d|_         	 |V                                   Y d S #                                  w xY ww xY w)Nc                  N    	 |          S # t           $ r  |  x}| <   |cY S w xY wr5   )KeyError)r   valuecachefuncs     r'   wrapperz_cached.<locals>.wrapper  sJ    T{"   &*dDk1ds    $$T)
__cached__AttributeErrorclear)r   r  r   s   ` @r'   _cachedr    s      




   	 	 	 	 	 	 "	MMMKKMMMMMMEKKMMMMs    A"AA"AA"c                     | d         }| dd          }|dk    rt           }n1d|v rt          d          t          |          rt          }nt          } |||          S )Nr   rO   **z:Invalid pattern: '**' can only be an entire path component)_RecursiveWildcardSelector
ValueErrorr1   _WildcardSelector_PreciseSelector)pattern_partsr0   child_partsclss       r'   _make_selectorr    sp    

C#K
d{{(	UVVV	c	"	" 3sK   r)   	lru_cachec                       e Zd ZdZd Zd ZdS )	_SelectorzYA selector matches a specific glob pattern part against the children
    of a given path.c                 j    || _         |rt          |          | _        d S t                      | _        d S r5   )r  r  	successor_TerminatingSelector)r9   r  s     r'   r:   z_Selector.__init__  s6    & 	4+K88DNNN133DNNNr)   c                     t          |          }|j        }|j        }|j        j        }|                     ||||          S )zuIterate over all child paths of `parent_path` matched by this
        selector.  This can contain parent_path itself.)typeis_direxistsr   r   _select_from)r9   parent_pathpath_clsr  r  r   s         r'   select_fromz_Selector.select_from  sD     $$'/  ffgFFFr)   N)rU   rV   rW   rX   r:   r  r    r)   r'   r  r    sA         4 4 4G G G G Gr)   r  c                       e Zd Zd ZdS )r  c              #      K   |V  d S r5   r    )r9   r  r  r  r   s        r'   r  z!_TerminatingSelector._select_from  s      r)   N)rU   rV   rW   r  r    r)   r'   r  r    s#            r)   r  c                       e Zd Zd Zd ZdS )r  c                 J    || _         t                              | |           d S r5   )r   r  r:   )r9   r   r  s      r'   r:   z_PreciseSelector.__init__  s%    	4-----r)   c              #      K    ||          sd S |                     | j                  } ||          r$| j                            ||||          D ]}|V  d S d S r5   )_make_child_relpathr   r  r  )r9   r  r  r  r   r   r   s          r'   r  z_PreciseSelector._select_from  s      vk"" 	F..ty996$<< 	^00vvwOO  	 	 r)   NrU   rV   rW   r:   r  r    r)   r'   r  r    s2        . . .    r)   r  c                       e Zd Zd Zd ZdS )r
  c                     t          j        t          j        |                    | _        t
                              | |           d S r5   )recompilefnmatch	translater0   r  r:   r9   r0   r  s      r'   r:   z_WildcardSelector.__init__  s:    :g/44554-----r)   c              #     K    ||          sd S |j         j        } ||          D ]`} ||          }| j                            |          r9|                    |          }| j                            ||||          D ]}	|	V  ad S r5   )_flavourrP   r0   matchr#  r  r  )
r9   r  r  r  r   cfr   
casefoldedr   r   s
             r'   r  z_WildcardSelector._select_from  s      vk"" 	F!*GK(( 	 	DDJx~~j)) "66t<<44T667SS  AGGGG	 	r)   Nr$  r    r)   r'   r
  r
    s2        . . .	 	 	 	 	r)   r
  c                        e Zd Zd Zd Zd ZdS )r  c                 <    t                               | |           d S r5   )r  r:   r+  s      r'   r:   z#_RecursiveWildcardSelector.__init__  s    4-----r)   c              #      K   |V   ||          D ]@}|                     |          } ||          r|                     |||          D ]}|V  Ad S r5   )r#  _iterate_directories)r9   r  r  r   r   r   r   s          r'   r4  z/_RecursiveWildcardSelector._iterate_directories  s      GK(( 	 	D22488Dvd|| 224II  AGGGG		 	r)   c              #     K    ||          sd S t          |          5 }t                      }	 | j        j        }|                     |||          D ]0} |||||          D ]}||vr|V  |                    |            1	 |                                 n# |                                 w xY w	 d d d            d S # 1 swxY w Y   d S r5   )r  r   r  r  r4  addr  )	r9   r  r  r  r   yieldedsuccessor_selectstarting_pointr   s	            r'   r  z'_RecursiveWildcardSelector._select_from  s:     vk"" 	FW 
	 eeG #'>#> &*&?&?VU\&]&] + +N--nffgVV + +G++"#GGG#KKNNN++ 
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	 s)   C ABC B//C  CCN)rU   rV   rW   r:   r4  r  r    r)   r'   r  r    sA        . . .           r)   r  c                   .    e Zd ZdZdZd Zd Zd Zd ZdS )_PathParentszvThis object provides sequence-like access to the logical ancestors
    of a path.  Don't try to construct it yourself.)_pathcls_drv_root_partsc                 v    t          |          | _        |j        | _        |j        | _        |j        | _        d S r5   )r  r<  r=  r>  r?  r   s     r'   r:   z_PathParents.__init__  s.    T

I	Z
kr)   c                 t    | j         s| j        rt          | j                  dz
  S t          | j                  S r   )r=  r>  rw   r?  r8   s    r'   __len__z_PathParents.__len__%  s:    9 	$
 	$t{##a''t{###r)   c                     |dk     s|t          |           k    rt          |          | j                            | j        | j        | j        d | dz
                     S )Nr   rO   )rw   
IndexErrorr<  _from_parsed_partsr=  r>  r?  )r9   idxs     r'   __getitem__z_PathParents.__getitem__+  s`    77cSYY&&S//!}//	4:04IcTAXI0FH H 	Hr)   c                 @    d                     | j        j                  S )Nz<{0}.parents>)formatr<  rU   r8   s    r'   __repr__z_PathParents.__repr__1  s    %%dm&<===r)   N)	rU   rV   rW   rX   	__slots__r:   rB  rG  rJ  r    r)   r'   r;  r;    sb        7 77I" " "$ $ $H H H> > > > >r)   r;  c                   D   e Zd ZdZdZd Zd Zed             Zed1d            Z	ed1d            Z
ed	             Zd
 Zd Zd Zd Zd Zd Zd Zed             Zd Zd Zd Zd Zd Zd Zd Z e ed          d          Z e ed          d          Zed             Zed             Z ed              Z!ed!             Z"ed"             Z#d# Z$d$ Z%d% Z&ed&             Z'd' Z(d( Z)d) Z*e+j,        d*k     re)Z-e*Z.ed+             Z/ed,             Z0d- Z1d. Z2d/ Z3d0S )2r   aH  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.
    )r=  r>  r?  _str_hash_pparts_cached_cpartsc                 z    | t           u rt          j        dk    rt          nt          } |                     |          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.
        r   )r   r   r   r   r   _from_parts)r  r   s     r'   __new__zPurePath.__new__A  s2     (??%'W__//-Ct$$$r)   c                 8    | j         t          | j                  fS r5   )	__class__tupler?  r8   s    r'   
__reduce__zPurePath.__reduce__K  s     dk 2 233r)   c                    g }|D ]k}t          |t                    r||j        z  }"t          |t                    r|                    |           Mt          dt          |          z            | j                            |          S )Nz/argument should be a path or str object, not %r)	r!   r   r?  
basestringrD   	TypeErrorr  r-  rM   )r  r   r*   rc   s       r'   _parse_argszPurePath._parse_argsP  s      	 	A!X&& !Az** QE1gg   |''...r)   Tc                     t                               |           }|                    |          \  }}}||_        ||_        ||_        |r|                                 |S r5   )objectrS  r[  r=  r>  r?  _init)r  r   initr9   rH   rI   r*   s          r'   rR  zPurePath._from_parts`  s^     ~~c""++D11T5	
 	JJLLLr)   c                     t                               |           }||_        ||_        ||_        |r|                                 |S r5   )r]  rS  r=  r>  r?  r^  )r  rH   rI   r*   r_  r9   s         r'   rE  zPurePath._from_parsed_partsm  sB    ~~c""	
 	JJLLLr)   c                     |s|r(||z   | j                             |dd                    z   S | j                             |          S r   )r-  r7   )r  rH   rI   r*   s       r'   _format_parsed_partszPurePath._format_parsed_partsw  sN     	,$ 	,: 1 1%) < <<<<$$U+++r)   c                     d S r5   r    r8   s    r'   r^  zPurePath._init~  s    r)   c                     |                      |          \  }}}| j                            | j        | j        | j        |||          \  }}}|                     |||          S r5   )r[  r-  rT   r=  r>  r?  rE  )r9   r   rH   rI   r*   s        r'   _make_childzPurePath._make_child  sg    ++D11T5=::Itz4;T5B BT5&&sD%888r)   c                     	 | j         S # t          $ r7 |                     | j        | j        | j                  pd| _         | j         cY S w xY w)z[Return the string representation of the path, suitable for
        passing to system calls.r=   )rM  r  rb  r=  r>  r?  r8   s    r'   __str__zPurePath.__str__  sh    	9 	 	 	11$)TZ26+? ? FBE I9	s   	 >A
	A
c                 `    | j         }t          |                               |j        d          S )zNReturn the string representation of the path with forward (/)
        slashes.r\   )r-  r   rA   r6   )r9   fs     r'   r   zPurePath.as_posix  s)     M4yy  ,,,r)   c                     t           j        dk     rt          d          t          j        t          |                     S )zaReturn the bytes representation of the path.  This is only
        recommended to use under Unix.r   zneeds Python 3.2 or later)r   r   r   r   fsencoder   r8   s    r'   	__bytes__zPurePath.__bytes__  s7     f$$%&ABBB{3t99%%%r)   c                 f    d                     | j        j        |                                           S )Nz
{0}({1!r}))rI  rU  rU   r   r8   s    r'   rJ  zPurePath.__repr__  s%    ""4>#:DMMOOLLLr)   c                 |    |                                  st          d          | j                            |           S )z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI)r   r	  r-  r   r8   s    r'   as_urizPurePath.as_uri  s<    !! 	OMNNN}%%d+++r)   c                     	 | j         S # t          $ r. | j                            | j                  | _         | j         cY S w xY wr5   )rP  r  r-  r   r?  r8   s    r'   _cpartszPurePath._cparts  sT    	'&& 	' 	' 	'"&-">">t{"K"KD&&&&	's   	 5A Ac                 v    t          |t                    st          S | j        |j        k    o| j        |j        u S r5   )r!   r   NotImplementedrq  r-  r9   others     r'   __eq__zPurePath.__eq__  s7    %** 	"!!|u},P%.1PPr)   c                     | |k     S r5   r    rt  s     r'   __ne__zPurePath.__ne__  s    5=  r)   c                     	 | j         S # t          $ r0 t          t          | j                            | _         | j         cY S w xY wr5   )rN  r  hashrV  rq  r8   s    r'   __hash__zPurePath.__hash__  sQ    	: 	 	 	eDL1122DJ:	s   	 7AAc                 v    t          |t                    r| j        |j        urt          S | j        |j        k     S r5   r!   r   r-  rs  rq  rt  s     r'   __lt__zPurePath.__lt__  7    %** 	"dm5>.Q.Q!!|em++r)   c                 v    t          |t                    r| j        |j        urt          S | j        |j        k    S r5   r}  rt  s     r'   __le__zPurePath.__le__  7    %** 	"dm5>.Q.Q!!|u},,r)   c                 v    t          |t                    r| j        |j        urt          S | j        |j        k    S r5   r}  rt  s     r'   __gt__zPurePath.__gt__  r  r)   c                 v    t          |t                    r| j        |j        urt          S | j        |j        k    S r5   r}  rt  s     r'   __ge__zPurePath.__ge__  r  r)   r=  z.The drive prefix (letter or UNC path), if any.)docr>  zThe root of the path, if any.c                 $    | j         | j        z   }|S )z/The concatenation of the drive and root, or ''.)r=  r>  )r9   anchors     r'   r  zPurePath.anchor  s     TZ'r)   c                 j    | j         }t          |          | j        s| j        rdndk    rdS |d         S )z!The final path component, if any.rO   r   r<   rs   )r?  rw   r=  r>  r   s     r'   r   zPurePath.name  s=     u::	?TZ?!!a@@2Ryr)   c                     | j         }|                    d          }d|cxk     rt          |          dz
  k     rn n
||d         S dS )z*The final component's last suffix, if any.r=   r   rO   Nr<   r   rfindrw   r9   r   rn   s      r'   suffixzPurePath.suffix  sX     yJJsOOq    3t99q=     8O2r)   c                     | j         }|                    d          rg S |                    d          }d |                    d          dd         D             S )z1A list of the final component's suffixes, if any.r=   c                     g | ]}d |z   S )r=   r    )r%   r  s     r'   r(   z%PurePath.suffixes.<locals>.<listcomp>  s    ???f???r)   rO   N)r   endswithry   rC   r9   r   s     r'   suffixeszPurePath.suffixes  s\     y== 	I{{3??4::c??122+>????r)   c                     | j         }|                    d          }d|cxk     rt          |          dz
  k     rn n
|d|         S |S )z0The final path component, minus its last suffix.r=   r   rO   Nr  r  s      r'   stemzPurePath.stem  sX     yJJsOOq    3t99q=     8OKr)   c                     | j         st          | d          |                     | j        | j        | j        dd         |gz             S )z-Return a new path with the file name changed. has an empty nameNrs   )r   r	  rE  r=  r>  r?  r  s     r'   	with_namezPurePath.with_name  sY    y 	?ttt=>>>&&ty$*'+{3B3'74&'@B B 	Br)   c                    | j                             |f          \  }}}|s|st          |          dk    rt          d|z            |d         }|                    d          st          d|z            | j        }|st          | d          | j        }|s||z   }n|dt          |                    |z   }|                     | j        | j	        | j
        dd         |gz             S )zCReturn a new path with the file suffix changed (or added, if none).rO   zInvalid suffix %rr   r=   r  Nrs   )r-  rM   rw   r	  r   r   r  rE  r=  r>  r?  )r9   r  rH   rI   r*   r   
old_suffixs          r'   with_suffixzPurePath.with_suffix  s     =44fY??T5 	=$ 	=#e**//0F;<<<q  %% 	=0F;<<<y 	?ttt=>>>[
 	4&=DD)#j//))*V3D&&ty$*'+{3B3'74&'@B B 	Br)   c                 R   |st          d          | j        }| j        }| j        }|r||g|dd         z   }n|}|                     |          \  }}}|r||g|dd         z   }	n|}	t          |	          }
| j        j        }|
dk    r|s|run  ||d|
                    ||	          k    rT|                     |||          }t          d
                    t          |           t          |                              |                     d|
dk    r|nd||
d                   S )zReturn the relative path to another path identified by the passed
        arguments.  If the operation is not possible (because this is not
        a subpath of the other path), raise ValueError.
        zneed at least one argumentrO   Nr   z{!r} does not start with {!r}r<   )rZ  r?  r=  r>  r[  rw   r-  r   rb  r	  rI  r   rE  )r9   ru  r*   rH   rI   	abs_partsto_drvto_rootto_partsto_abs_partsnr/  	formatteds                r'   relative_tozPurePath.relative_to   sa     	:8999iz 	deABBi/III$($4$4U$;$;! 	$"G,x|;LL#L])FFDFCF9RaR=(9(9RR=M=M(M(M11&'8LLI<$fSYYI??A A A&&r16644r'0}6 6 	6r)   c                 r    	 | j         S # t          $ r# t          | j                  | _         | j         cY S w xY w)zZAn object providing sequence-like access to the
        components in the filesystem path.)rO  r  rV  r?  r8   s    r'   r*   zPurePath.parts@  sI    	 < 	  	  	  --DL<	 s   	 *66c                 ,    |                      |          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).
        re  )r9   r   s     r'   joinpathzPurePath.joinpathL  s     %%%r)   c                 .    |                      |f          S r5   r  r9   keys     r'   __truediv__zPurePath.__truediv__T  s    '''r)   c                 >    |                      |g| j        z             S r5   )rR  r?  r  s     r'   __rtruediv__zPurePath.__rtruediv__W  s     3444r)   r   c                     | j         }| j        }| j        }t          |          dk    r|s|r| S |                     |||dd                   S )zThe logical parent of the path.rO   Nrs   )r=  r>  r?  rw   rE  )r9   rH   rI   r*   s       r'   parentzPurePath.parent^  sU     izu::???t?K&&sD%*===r)   c                      t          |           S )z*A sequence of this path's logical parents.)r;  r8   s    r'   parentszPurePath.parentsh  s     D!!!r)   c                 V    | j         sdS | j        j         pt          | j                  S )zSTrue if the path is absolute (has both a root and, if applicable,
        a drive).F)r>  r-  r   boolr=  r8   s    r'   r   zPurePath.is_absolutem  s.     z 	5=((;DOO;r)   c                 @    | j                             | j                  S )zaReturn True if the path contains one of the special names reserved
        by the system, if any.)r-  r   r?  r8   s    r'   r   zPurePath.is_reservedt  s     }((555r)   c                 8   | j         j        } ||          }| j                             |f          \  }}}|st          d          |r| || j                  k    rdS |r| || j                  k    rdS | j        }|s|r-t          |          t          |          k    rdS |dd         }n"t          |          t          |          k    rdS t          t          |          t          |                    D ]\  }}t          j        ||          s dS dS )zE
        Return True if this path matches the given pattern.
        zempty patternFrO   NT)r-  rP   rM   r	  r=  r>  rq  rw   zipr@   r)  fnmatchcase)	r9   path_patternr/  rH   rI   	pat_partsr*   r&   r0   s	            r'   r.  zPurePath.matchy  sA    ]#r,''#}88,IIT9 	._--- 	3""TY--''5 	DBBtzNN**5 	$ 	9~~U++u!!""II^^c%jj((5Xe__hy.A.ABB 	 	ID#&tS11 uutr)   N)T)4rU   rV   rW   rX   rK  rS  rW  classmethodr[  rR  rE  rb  r^  re  rg  r   rl  rJ  ro  propertyrq  rv  rx  r{  r~  r  r  r  r   r   rI   r  r   r  r  r  r  r  r  r*   r  r  r  r   r   __div____rdiv__r  r  r   r   r.  r    r)   r'   r   r   5  s~        I
% % %4 4 4
 / / [/ 
 
 
 [
    [ , , [,  9 9 9  - - -& & &M M M, , , ' ' X'Q Q Q
! ! !  , , ,
- - -
, , ,
- - -
 HZZ''MO O OE 8JJw'';= = =D   X
   X   X @ @ X@   XB B BB B B(6 6 6@ 	  	  X	 & & &( ( (5 5 5 $> > X> " " X"< < <6 6 6
    r)   r   c                       e Zd ZeZdZdS )r   r    N)rU   rV   rW   _posix_flavourr-  rK  r    r)   r'   r   r     s        HIIIr)   r   c                       e Zd ZeZdZdS )r   r    N)rU   rV   rW   _windows_flavourr-  rK  r    r)   r'   r   r     s        HIIIr)   r   c                       e Zd ZdZd Z	 d*dZd Zd+dZd,d	Ze	d
             Z
d Zd Zd Zd Zd Zd Zd Zd Z	 	 d-dZd.dZd/dZd Zd Zd Zd Zd Zd Zd  Zd0d!Zd" Zd# Zd$ Z d% Z!d& Z"d' Z#d( Z$d) Z%dS )1r   )r   c                     | t           u rt          j        dk    rt          nt          } |                     |d          }|j        j        st          d| j	        d          |
                                 |S )Nr   Fr_  zcannot instantiate z on your system)r   r   r   r   r   rR  r-  r   r   rU   r^  )r  r   kwargsr9   s       r'   rS  zPath.__new__  su    $;;!#D++iCt%00}) 	9%%),'8 9 9 9

r)   Nc                 >    ||j         | _         d S t          | _         d S r5   )r   _normal_accessor)r9   templates     r'   r^  z
Path._init  s#     %/DNNN-DNNNr)   c                 Z    | j         |gz   }|                     | j        | j        |          S r5   )r?  rE  r=  r>  )r9   r&   r*   s      r'   r#  zPath._make_child_relpath  s.     tf$&&ty$*eDDDr)     c                 :    | j                             | ||          S r5   r   r   )r9   r   flagsr   s       r'   _openerzPath._opener  s    ~""4555r)     c                 :    | j                             | ||          S )zm
        Open the file pointed by this path and return a file descriptor,
        as os.open() does.
        r  )r9   r  r   s      r'   	_raw_openzPath._raw_open  s    
 ~""4555r)   c                 :     | t          j                              S )zjReturn a new path pointing to the current working directory
        (as returned by os.getcwd()).
        )r   r   )r  s    r'   cwdzPath.cwd  s    
 s29;;r)   c              #   |   K   | j                             |           D ]}|dv r|                     |          V  dS )zyIterate over the files in this directory.  Does not yield any
        result for the special paths '.' and '..'.
        )r=   r   N)r   r   r#  r  s     r'   iterdirzPath.iterdir  s\       N**400 	1 	1D{""**4000000		1 	1r)   c              #     K   | j                             |          }| j                             |f          \  }}}|s|rt          d          t	          t          |                    }|                    |           D ]}|V  dS )zIterate over this subtree and yield all existing files (of any
        kind, including directories) matching the given pattern.
        %Non-relative patterns are unsupportedNr-  rP   rM   r   r  rV  r  r9   patternrH   rI   r  selectorr   s          r'   globz	Path.glob  s       -((11#'=#<#<gZ#H#H T= 	O$ 	O%&MNNN!%"6"677%%d++ 	 	AGGGG	 	r)   c              #     K   | j                             |          }| j                             |f          \  }}}|s|rt          d          t	          dt          |          z             }|                    |           D ]}|V  dS )zRecursively yield all existing files (of any kind, including
        directories) matching the given pattern, anywhere in this subtree.
        r  )r  Nr  r  s          r'   rglobz
Path.rglob  s       -((11#'=#<#<gZ#H#H T= 	O$ 	O%&MNNN!'E-,@,@"@AA%%d++ 	 	AGGGG	 	r)   c                     |                                  r| S |                     t          j                    g| j        z   d          }|                    |            |S )a  Return an absolute version of this path.  This function works
        even if the path doesn't point to anything.

        No normalization is done, i.e. all '.' and '..' will be kept along.
        Use resolve() to get the canonical path to a file.
        Fr  r  )r   rR  r   r   r?  r^  )r9   objs     r'   absolutezPath.absolute  s_      	K 	}t{:GG		4	   
r)   c                 B   | j                             |           }|5|                                  t          |                                           }| j         j                            |          }|                     |fd          }|                    |            |S )z
        Make the path absolute, resolving all symlinks on the way and also
        normalizing it (for example turning slashes into backslashes under
        Windows).
        NFr  r  )	r-  r   r   r   r  r   normpathrR  r^  )r9   r   normedr  s       r'   r   zPath.resolve  s     M!!$''9 IIKKKDMMOO$$A&//22yu55		4	   
r)   c                 6    | j                             |           S )zh
        Return the result of the stat() system call on this path, like
        os.stat() does.
        )r   r   r8   s    r'   r   z	Path.stat  s    
 ~""4(((r)   c                 l    ddl }|                    |                                 j                  j        S )z:
        Return the login name of the file owner.
        r   N)pwdgetpwuidr   st_uidpw_name)r9   r  s     r'   ownerz
Path.owner  -     	


||DIIKK.//77r)   c                 l    ddl }|                    |                                 j                  j        S )z8
        Return the group name of the file gid.
        r   N)grpgetgrgidr   st_gidgr_name)r9   r  s     r'   groupz
Path.group$  r  r)   rrs   c           	          t           j        dk    r-t          j        t	          |           |||||| j                  S t          j        t	          |           |||||          S )z|
        Open the file pointed by this path and return a file object, as
        the built-in open() function does.
        r   )opener)r   r   ior   r   r  )r9   r   	bufferingencodingerrorsnewlines         r'   r   z	Path.open+  sd     v%%73t99dIx"&,0 0 0 0 73t99dIxQQQr)   Tc                 8   |rCt          j                     }	 | j                            | ||f           dS # t          $ r Y nw xY wt          j        t          j        z  }|s|t          j        z  }|                     ||          }t	          j	        |           dS )zS
        Create this file with the given access mode, if it doesn't exist.
        N)
timer   r   r   r   O_CREATO_WRONLYO_EXCLr  close)r9   r   exist_oktr  fds         r'   touchz
Path.touch7  s      	 	A$$TAq6222
 	    
 
R[( 	RYE^^E4((
s   6 
AAFc                 :   |s| j                             | |           d S 	 | j                             | |           d S # t          $ rR}|j        t          k    r | j                            d           | j                             | |           Y d }~d S d }~ww xY w)NT)r  )r   r   r   r   r   r  )r9   r   r  r   s       r'   r   z
Path.mkdirM  s     		1N  t,,,,,1$$T400000 1 1 17f$$!!$!///$$T4000000000	1s   > 
BABBc                 <    | j                             | |           dS )zF
        Change the permissions of the path, like os.chmod().
        N)r   r   r9   r   s     r'   r   z
Path.chmodY  s"     	T4(((((r)   c                 <    | j                             | |           dS )z
        Like chmod(), except if the path points to a symlink, the symlink's
        permissions are changed, rather than its target's.
        N)r   r   r
  s     r'   r   zPath.lchmod_  s"    
 	dD)))))r)   c                 :    | j                             |            dS )zd
        Remove this file or link.
        If the path is a directory, use rmdir() instead.
        N)r   r   r8   s    r'   r   zPath.unlinkf  s     
 	d#####r)   c                 :    | j                             |            dS )zF
        Remove this directory.  The directory must be empty.
        N)r   r   r8   s    r'   r   z
Path.rmdirm  s      	T"""""r)   c                 6    | j                             |           S )z
        Like stat(), except if the path points to a symlink, the symlink's
        status information is returned, rather than its target's.
        )r   r   r8   s    r'   r   z
Path.lstats  s    
 ~##D)))r)   c                 <    | j                             | |           dS )z5
        Rename this path to the given path.
        N)r   r   r9   r   s     r'   r   zPath.renamez  s"     	dF+++++r)   c                 z    t           j        dk     rt          d          | j                            | |           dS )zo
        Rename this path to the given path, clobbering the existing
        destination if it exists.
        r   z5replace() is only available with Python 3.3 and laterN)r   r   r   r   rA   r  s     r'   rA   zPath.replace  sK    
 f$$% 'B C C CtV,,,,,r)   c                 >    | j                             || |           dS )z
        Make this path a symlink pointing to the given path.
        Note the order of arguments (self, target) is the reverse of os.symlink's.
        N)r   r   )r9   r   r   s      r'   
symlink_tozPath.symlink_to  s%    
 	vt-@AAAAAr)   c                     	 |                                   n)# t          $ r}|j        t          k    r Y d}~dS d}~ww xY wdS )z+
        Whether this path exists.
        NFT)r   r   r   r   r9   r   s     r'   r  zPath.exists  sY    	IIKKKK 	 	 	w&  55555	 ts    
=8=c                     	 t          |                                 j                  S # t          $ r}|j        t
          k    r Y d}~dS d}~ww xY w)z3
        Whether this path is a directory.
        NF)r   r   st_moder   r   r   r  s     r'   r  zPath.is_dir  ^    	499;;./// 	 	 	w&   55555	   %( 
AA		Ac                     	 t          |                                 j                  S # t          $ r}|j        t
          k    r Y d}~dS d}~ww xY w)zq
        Whether this path is a regular file (also True for symlinks pointing
        to regular files).
        NF)r
   r   r  r   r   r   r  s     r'   is_filezPath.is_file  s^    
	499;;./// 	 	 	w&   55555	r  c                     	 t          |                                 j                  S # t          $ r}|j        t
          k    r Y d}~dS d}~w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  s\    	4::<</000 	 	 	w&  55555		r  c                     	 t          |                                 j                  S # t          $ r}|j        t
          k    r Y d}~dS d}~ww xY w)z6
        Whether this path is a block device.
        NF)r   r   r  r   r   r   r  s     r'   is_block_devicezPath.is_block_device  r  r  c                     	 t          |                                 j                  S # t          $ r}|j        t
          k    r Y d}~dS d}~ww xY w)z:
        Whether this path is a character device.
        NF)r   r   r  r   r   r   r  s     r'   is_char_devicezPath.is_char_device  r  r  c                     	 t          |                                 j                  S # t          $ r}|j        t
          k    r Y d}~dS d}~ww xY w)z.
        Whether this path is a FIFO.
        NF)r   r   r  r   r   r   r  s     r'   is_fifozPath.is_fifo  ^    	DIIKK/000 	 	 	w&   55555	r  c                     	 t          |                                 j                  S # t          $ r}|j        t
          k    r Y d}~dS d}~ww xY w)z0
        Whether this path is a socket.
        NF)r   r   r  r   r   r   r  s     r'   	is_socketzPath.is_socket  r$  r  r5   )r  )r  )r  rs   NNN)r  T)r  F)F)&rU   rV   rW   rK  rS  r^  r#  r  r  r  r  r  r  r  r  r   r   r  r  r   r  r   r   r   r   r   r   r   rA   r  r  r  r  r  r  r!  r#  r&  r    r)   r'   r   r     sQ       I   . . . .E E E6 6 6 66 6 6 6     [ 1 1 1
 
 

 
 
     $) ) )8 8 88 8 8 59"&
R 
R 
R 
R   ,
1 
1 
1 
1) ) )* * *$ $ $# # #* * *, , ,- - -B B B B
 
 
    
 
 
          r)   r   c                       e Zd ZdZdS )r   r    NrU   rV   rW   rK  r    r)   r'   r   r             IIIr)   r   c                       e Zd ZdZdS )r   r    Nr(  r    r)   r'   r   r     r)  r)   r   )Hr)  r   r  r   r   r   r'  r   r  collectionsr   
contextlibr   r   r   r   operatorr   r   r   r	   r
   r   r   r   r   urllibr   urlquoter   ImportErrorurllib.parser   rE   	NameErrorrY  r   r   r   getwindowsversionr   r   __all__r>   r$   r+   r1   r]  r3   rZ   r   r  r  r   r   r  r  r  r   r  r  r  r  r
  r  r;  r   r   r   r   r   r   r    r)   r'   <module>r5     s        				  				     				 



              % % % % % %                       P P P P P P P P P P P P P P P P P PXFFFFFFFFF X X XWWWWWWWWWWXFF   ZFFFJJ   JJJ  	!III srr"f,,1AV1K1K(((((((!     	BBB   $ ) ) )
2 2 2:# :# :# :# :#v :# :# :#zwR wR wR wR wRh wR wR wRtP6 P6 P6 P6 P6H P6 P6 P6f #?$$ * * * * * * * *
9! 9! 9! 9! 9!i 9! 9! 9!x #?$$    $! ! ! 79k"" ;*(Y(**>::NG G G G G G G G*           y       	   $               B> > > > >8 > > >8[ [ [ [ [v [ [ [|
    H   
    h   X X X X X8 X X Xv
    m       $     sH   A A+*A+/A2 2B BB BBC CC