
    ?g;                    .   S r SSKJr  SSKrSSKJr  SSKrSSKrSSK	r	SSK
r
SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSK!r!SSK"r"SSK#J$r$  \RJ                  S:H  =(       d    \&" \
SS5      S:H  r' " S S5      r( " S S\)5      r* " S  S!5      r+ " S" S#5      r,S$ r- " S% S&5      r.S' r/S( r0 " S) S*5      r1S+ r2S, r3S- r4S. r5\1r6g)/zlocal path implementation.    )annotationsN)contextmanager)abspath)dirname)exists)isabs)isdir)isfile)islink)normpath)S_ISDIR)S_ISLNK)S_ISREG)Any)Callable)cast)Literal)overload)TYPE_CHECKING   )errorwin32_nameFntc                  |    \ rS rSr% SrS rS rS rS rS r	S r
S	 rS
 rS rS\S'   SS jrS rS rS rS rSrg)Checkers)   )r   linkdirfilec                    Xl         g Npath)selfr$   s     2/usr/lib/python3/dist-packages/_pytest/_py/path.py__init__Checkers.__init__,   s    	    c                L    U R                   R                  R                  S5      $ N.r$   basename
startswithr%   s    r&   dotfileCheckers.dotfile/       yy!!,,S11r)   c                j    UR                  S5      (       d  SU-   nU R                  R                  U:H  $ r+   )r/   r$   extr%   args     r&   r5   Checkers.ext2   s-    ~~c"")Cyy}}##r)   c                4    U R                   R                  U:H  $ r"   )r$   r.   r6   s     r&   r.   Checkers.basename7   s    yy!!S((r)   c                L    U R                   R                  R                  U5      $ r"   r-   r6   s     r&   
basestartsCheckers.basestarts:   r3   r)   c                8    U R                   R                  U5      $ r"   )r$   reltor6   s     r&   r?   Checkers.relto=   s    yys##r)   c                8    U R                   R                  U5      $ r"   )r$   fnmatchr6   s     r&   rB   Checkers.fnmatch@   s    yy  %%r)   c                J    [        U R                  5      R                  U5      $ r"   )strr$   endswithr6   s     r&   rF   Checkers.endswithC   s    499~&&s++r)   c                   SSK Jn  UR                  5        H  u  p4SnS n [        X5      nUc  [        SU< SU R                  < 35      e U" U5      R                  S	:  a  U" U5      (       + U-  (       a    gMe  [        U5      [        U" 5       5      -  U-  (       a    gM     g! [         a0    US S S:X  a$  Sn [        XSS  5      n N! [         a      Nf = f Nf = f! [        R                  [        R                  [        R                  4 a]    U R                   HH  nX1;   a  UR                  U5      (       a       gSU-   nX1;   d  M.  UR                  U5      (       a  MF       g    GM\  f = f)
N   )
getrawcodeF   notTzno z checker available for r   )_code.sourcerJ   itemsgetattrAttributeError	TypeErrorr$   co_argcountboolr   ENOENTENOTDIREBUSY_depend_on_existenceget)r%   kwrJ   namevalueinvertmeths          r&   	_evaluateCheckers._evaluateF   sa   -88:KDFDt* |#dX-DTYYM RSS)d#//!3 K61$ 2 E{T$&\1F:$ ;' &B 9 " 8u$!F&t!"X6) 	 %  LL%--= ) !55Dz66$<<#( 4<Dz!vvd||#( 6	)s`   B'+C$<$C$'C!=C
CC!CC! C!$AE4E4E4)E4-E43E4Stat
_statcachec                    U R                   $ ! [         ai     U R                  R                  5       U l         O9! [        R
                   a"    U R                  R                  5       U l          Of = fU R                   s $ f = fr"   )ra   rP   r$   statr   ELOOPlstatr0   s    r&   _statCheckers._statn   sf    	#??" 	#4"&)).."2;; 4"&))//"34??"	#s/    
B9B3A/,B.A//B Bc                H    [        U R                  5       R                  5      $ r"   )r   rf   moder0   s    r&   r   Checkers.dirx       tzz|(())r)   c                H    [        U R                  5       R                  5      $ r"   )r   rf   ri   r0   s    r&   r    Checkers.file{   rk   r)   c                "    U R                  5       $ r"   )rf   r0   s    r&   r   Checkers.exists~       zz|r)   c                `    U R                   R                  5       n[        UR                  5      $ r"   )r$   re   r   ri   )r%   sts     r&   r   Checkers.link   s!    YY__rwwr)   )ra   r$   Nreturnr`   )__name__
__module____qualname____firstlineno__rW   r'   r1   r5   r.   r<   r?   rB   rF   r^   __annotations__rf   r   r    r   r   __static_attributes__ r)   r&   r   r   )   sW    :2$
)2$&,$L #** r)   r   c                      \ rS rSrSrg)NeverRaised   r|   N)rv   rw   rx   ry   r{   r|   r)   r&   r~   r~      s    r)   r~   c                       \ rS rSrS rS rSrg)Visitor   c                p   [        U[        5      (       a  [        U5      n[        U[        5      (       a  [        U5      U l        O'[	        US5      (       d  U(       a	  S U l        OX l        Xl        X0l        X@l        U(       a(  [        [        [        /[        4   [        5      U l        g S U l        g )N__call__c                    gNTr|   r#   s    r&   <lambda>"Visitor.__init__.<locals>.<lambda>   s    Dr)   c                    U $ r"   r|   xs    r&   r   r      s    RSr)   )
isinstancerE   	FNMatcherrechasattrfilignorebreadthfirstr   r   r   sortedoptsortr%   r   r   r   bfsorts         r&   r'   Visitor.__init__   s|    c3C.Cc34=cNDHj))c(DHH=AtHcUCZ0&9r)   c           	   #  f  #     UR                  5       nU R                  nU R                  U Vs/ s H,  oDR	                  SS9(       d  M  Ub  U" U5      (       d  M*  UPM.     sn5      nU R
                  (       d"  U H  nU R                  U5       S h  vN   M     U R                  U5       H,  nU R                  b  U R                  U5      (       d  M(  Uv   M.     U R
                  (       a#  U H  nU R                  U5       S h  vN   M     g g ! U R                   a     g f = fs  snf  N N'7fNr   r   )listdirr   r   r   checkr   genr   )r%   r$   entriesr   pdirssubdirs          r&   r   Visitor.gen   s     	llnG hh||N177q7>Qs{c!fQN
   88F+++ g&Axx488A;; ' 88F+++   {{ 		 O , ,sb   D1D D1D(
D(D("1D1D-=D12D1D/
D1D%"D1$D%%	D1/D1)r   r   r   r   r   N)rv   rw   rx   ry   r'   r   r{   r|   r)   r&   r   r      s    U,r)   r   c                       \ rS rSrS rS rSrg)r      c                    Xl         g r"   patternr%   r   s     r&   r'   FNMatcher.__init__   s    r)   c                   U R                   nUR                  UR                  5      S:X  aX  [        (       aM  UR                  [        R                  5      S:w  a*  UR                  [        R                  UR                  5      nUR                  UR                  5      S:X  a  UR                  nOA[        U5      n[        R                  R                  U5      (       d  SUR                  -   U-   n[        R                  " X25      $ )N*)r   findsepiswin32	posixpathreplacer.   rE   osr$   r   rB   )r%   r$   r   rZ   s       r&   r   FNMatcher.__call__   s    ,, LL"b(Y]]+r1
 ooimmTXX>G<<!R'==Dt9D77==)).72t--r)   r   N)rv   rw   rx   ry   r'   r   r{   r|   r)   r&   r   r      s    .r)   r   c                *    [        [        X5      5      $ r"   )listmap)funciters     r&   map_as_listr      s    D  r)   c                      \ rS rSr\(       a  \SS j5       r\SS j5       rSS jrS r	\S 5       r
\S 5       rS rS	 rS
 rSrg)r`      c                    g r"   r|   r0   s    r&   size	Stat.size   s    "r)   c                    g r"   r|   r0   s    r&   mtime
Stat.mtime   s    "%r)   c                4    [        U R                  SU-   5      $ )Nst_)rO   _osstatresult)r%   rZ   s     r&   __getattr__Stat.__getattr__   s    t))54<88r)   c                    Xl         X l        g r"   )r$   r   )r%   r$   osstatresults      r&   r'   Stat.__init__   s    	)r)   c                    [         (       a  [        S5      eSS Kn[        R                  " UR
                  U R                  5      nUS   $ )N	XXX win32r   )r   NotImplementedErrorpwdr   checked_callgetpwuiduid)r%   r   entrys      r&   owner
Stat.owner   s8    7%k22""3<<:Qxr)   c                    [         (       a  [        S5      eSSKn[        R                  " UR
                  U R                  5      nUS   $ )zReturn group name of file.r   r   N)r   r   grpr   r   getgrgidgid)r%   r   r   s      r&   group
Stat.group   s:     7%k22""3<<:Qxr)   c                @    [        U R                  R                  5      $ r"   )r   r   st_moder0   s    r&   r	   
Stat.isdir       t))1122r)   c                @    [        U R                  R                  5      $ r"   )r   r   r   r0   s    r&   r
   Stat.isfile   r   r)   c                t    U R                   R                  5         [        U R                  R                  5      $ r"   )r$   re   r   r   r   r0   s    r&   r   Stat.islink   s'    		t))1122r)   )r   r$   Nru   intru   float)rZ   rE   ru   r   )rv   rw   rx   ry   r   propertyr   r   r   r'   r   r   r	   r
   r   r{   r|   r)   r&   r`   r`      sb    	" 
"	% 
%9*    333r)   r`   c                `    SS K n[        U [        5      (       d  UR                  U 5      S   n U $ Nr   rI   )r   r   r   getpwnam)userr   s     r&   	getuseridr      s*    dC  ||D!!$Kr)   c                `    SS K n[        U [        5      (       d  UR                  U 5      S   n U $ r   )r   r   r   getgrnam)r   r   s     r&   
getgroupidr     s*    eS!!U#A&Lr)   c                  |   \ rS rSrSr " S S\5      r\R                  rSYS jr	\
R                  S:w  a  SZS	 jrS[S
 jrS rS\S jrS r\r\S 5       r\S 5       r\S 5       r\S 5       rS rS rS]S jrS\S jrS rS rS rS rS rS r S r!S r"S r#S^S jr$S  r%S! r&SS\'SS4S" jr(S# r)S$ r*S% r+S& r,S' r-S( r.S) r/S* r0S_S+ jr1S`S, jr2S- r3SaS. jr4S/ r5SS0.SbS1 jjr6ScS2 jr7S3 r8S4 r9S5 r:\;" S6\R                  -   5      r<SdS7 jr=SeS8 jr>SfS9 jr?SgS: jr@S; rAS\S< jrBS= rCS^S> jrDS^S? jrEShS@ jrFSA rGSB rH\ISiSjSC jj5       rJ\ISkSD j5       rJSlSmSE jjrJSnSF jrKSoSG jrLSH rM\NSI 5       rOSJ rPSK rQSL rRSM rSSZSN jrTSO rUSP rVSpSQ jrWSqSR jrX\YSdSS j5       rZ\YST 5       r[\YSU 5       r\\YSoSV j5       r]\Y SrSW j5       r^SXr_g)s	LocalPathi	  zUObject oriented interface to os.path and other local filesystem
related information.
c                      \ rS rSrSrSrg)LocalPath.ImportMismatchErrori  z9raised on pyimport() if there is a mismatch of __file__'sr|   N)rv   rw   rx   ry   __doc__r{   r|   r)   r&   ImportMismatchErrorr     s    Gr)   r   NFc                *   Uc*  [         R                  " [        R                  5      U l        g [        R
                  " U5      nU(       a  [        R                  R                  U5      n[        U5      U l        g! [         a    [        S5      ef = f)a  Initialize and return a local Path instance.

Path can be relative to the current directory.
If path is None it defaults to the current working directory.
If expanduser is True, tilde-expansion is performed.
Note that Path instances always carry an absolute path.
Note also that passing in a local path object will simply return
the exact same path object. Use new() to get a new copy.
NzDcan only pass None, Path instances or non-empty strings to LocalPath)r   r   r   getcwdstrpathfspathrQ   
ValueErrorr$   
expanduserr   )r%   r$   r   s      r&   r'   LocalPath.__init__  sx     < --bii8DLyy ww))$/"4=DL   8 s   A< <Br   c                T   [        U5      n[        U5      nU(       a\  U R                  S S9 HH  nUR                  SS9(       d  M  [        R
                  " [        R                  [        U5      XE5        MJ     [        R
                  " [        R                  [        U 5      XE5        g)zChange ownership to the given user and group.
user and group may be specified by a number or
by a name.  if rec is True change ownership
recursively.
c                     U R                  SS9$ Nr   r   r   r   s    r&   r   !LocalPath.chown.<locals>.<lambda>6  s    !''q'/r)   r   r   r   N)	r   r   visitr   r   r   r   chownrE   )r%   r   r   r   r   r   r   s          r&   r  LocalPath.chown-  sv     D/CU#C(ABAwwAw**288SVSF C rxxTC=r)   c                `    [         R                  " [        R                  U R                  5      $ )z Return value of a symbolic link.)r   r   r   readlinkr   r0   s    r&   r  LocalPath.readlink;  s     %%bkk4<<@@r)   c                t    [         R                  " [        R                  [	        U5      [	        U 5      5        g)z&Posix style hard link to another name.N)r   r   r   r   rE   )r%   oldnames     r&   mklinktoLocalPath.mklinkto@  s     rwwGc$i@r)   c                   U(       a:  [         R                  " [        R                  [	        U5      U R
                  5        gU R                  U5      nU R                  U5      R                  U5      nU R                  U5      nUR                  U R                  5      nU R                  R                  SU-  U4-   5      n[         R                  " [        R                  XpR
                  5        g)zGCreate a symbolic link with the given value (pointing to another name).)z..N)r   r   r   symlinkrE   r   common	__class__r?   countr   join)r%   r[   absolutebase	relsourcereldestntargets           r&   mksymlinktoLocalPath.mksymlinktoD  s    ""2::s5z4<<H{{5) NN5177=	**T*MM$((+w{i\'AB""2::v||Dr)   c                L    U R                  [        R                  " U5      5      $ r"   )r  r   r   r%   others     r&   __div__LocalPath.__div__Q  s    yy5)**r)   c                *    U R                  S5      S   $ )zBasename part of path.r.   r   
_getbyspecr0   s    r&   r.   LocalPath.basenameV  s     z*1--r)   c                *    U R                  S5      S   $ )zDirname part of path.r   r   r"  r0   s    r&   r   LocalPath.dirname[  s     y)!,,r)   c                *    U R                  S5      S   $ )zPure base name of the path.purebasenamer   r"  r0   s    r&   r(  LocalPath.purebasename`  s     ~.q11r)   c                *    U R                  S5      S   $ )z*Extension of the path (including the '.').r5   r   r"  r0   s    r&   r5   LocalPath.exte  s     u%a((r)   c                z    U R                  S5       nUR                  5       sSSS5        $ ! , (       d  f       g= f)3Read and return a bytestring from reading the path.rbNopenread)r%   fs     r&   read_binaryLocalPath.read_binaryj  "    YYt_668 __   ,
:c                x    U R                  SUS9 nUR                  5       sSSS5        $ ! , (       d  f       g= f)z7Read and return a Unicode string from reading the path.rencodingNr/  )r%   r:  r2  s      r&   	read_textLocalPath.read_texto  s)    YYsXY.!668 /..s   +
9c                z    U R                  U5       nUR                  5       sSSS5        $ ! , (       d  f       g= f)r-  Nr/  )r%   ri   r2  s      r&   r1  LocalPath.readt  r5  r6  c                    SnU(       d"  U R                  U5      nUR                  S5      $ U R                  U5      n UR                  5       UR	                  5         $ ! UR	                  5         f = f)zuRead and return a list of lines from the path. if cr is False, the
newline will be removed from the end of each line.r8  
)r1  splitr0  	readlinesclose)r%   crri   contentr2  s        r&   rB  LocalPath.readlinesy  sV     iioG==&&		$A{{}		s   A A0c                    U R                  S5      n SSKn[        R                  " UR                  U5      UR                  5         $ ! UR                  5         f = f)z5(deprecated) return object unpickled from self.read()r.  r   N)r0  pickler   r   loadrC  )r%   r2  rH  s      r&   rI  LocalPath.load  s>    IIdO	%%fkk15GGIAGGIs   $A Ac                    UR                  U 5      (       a  [        R                  " US5      e U R                  U5        g! [        R                   a$    U R                  U5        U R                  5          gf = f)zMove this path to target.z.cannot move path into a subdirectory of itselfN)r?   r   EINVALrenameEXDEVcopyremover%   r  s     r&   moveLocalPath.move  s\    <<,,v'WXX	KK{{ 	IIfKKM	s   A 5A98A9c                $    [        U5      " U 5      $ )a  Return true if the basename/fullname matches the glob-'pattern'.

valid pattern characters::

    *       matches everything
    ?       matches any single character
    [seq]   matches any character in seq
    [!seq]  matches any char not in seq

If the pattern contains a path-separator then the full path
is used for pattern matching and a '*' is prepended to the
pattern.

if the pattern doesn't contain a path-separator the pattern
is only matched against the basename.
)r   r   s     r&   rB   LocalPath.fnmatch  s    " !$''r)   c                0   [        U[        [        45      (       d  [        U< S35      e[        U5      nU(       a!  US   U R                  :w  a  X R                  -  nU R
                  n[        R                  S:X  d  [        [        SS5      S:X  a`  [        R                  R                  U5      R                  [        R                  R                  U5      5      (       a  U[        U5      S $  gUR                  U5      (       a  U[        U5      S $ g)zOReturn a string which is the relative part of the path
to the given 'relpath'.
z: not a string or path objectr   r   r   Nr    )r   rE   r   rQ   r   r   sysplatformrO   r   r$   normcaser/   len)r%   relpath
strrelpathstrselfs       r&   r?   LocalPath.relto  s     'C#344wk)FGHH\
*R.DHH4(("J ,,<<7"gb'4&@D&Hww(33BGG4D4DZ4PQQs:011 R  
++3z?,--r)   c                &    U R                   " USS06$ )z0Ensure the path joined with args is a directory.r   T)ensure)r%   argss     r&   
ensure_dirLocalPath.ensure_dir  s    {{D+d++r)   c                    X:X  a  [         R                  $ U R                  U5      nU(       d  [        U5      $ U R	                  U5      nUR	                  U5      nU(       a  UR                  U R                  5      S-   nOSn[         R                  /U-  nU(       a  UR                  U5        UR                  R                  U5      nU$ ! [         a    [        U5      s $ f = f)zReturn a string which is a relative path from self
(assumed to be a directory) to dest such that
self.join(bestrelpath) == dest and if not such
path can be determined return dest.
r   r   )r   curdirr  rE   r?   r  r   pardirappendr  rP   )r%   destr  	self2baser  r  lstr  s           r&   bestrelpathLocalPath.bestrelpath  s    	|yy ;;t$D4y 

4(Ijj&GOODHH-199+/C

7#XX]]3'FM 	t9	s   C "C BC C%$C%c                "    U R                  5       $ r"   r  r0   s    r&   r   LocalPath.exists  rp   r)   c                     U R                  SS9$ r   r  r0   s    r&   r	   LocalPath.isdir  s    zzaz  r)   c                     U R                  SS9$ )Nr   r    r  r0   s    r&   r
   LocalPath.isfile  s    zzqz!!r)   c                    U nU /n UnUR                  5       nXB:X  a  OUR                  U5        M+  U(       d  UR                  5         U$ )zKReturn a root-first list of all ancestor directories
plus the path itself.
)dirpathrh  reverse)r%   rw  currentrk  lasts        r&   partsLocalPath.parts  sP     fDoo'GJJw  KKM
r)   c                    Sn[        U R                  5       UR                  5       5       H  u  p4X4:w  a  Us  $ UnM     U$ )zVReturn the common part shared with the other path
or None if there is no common part.
N)ziprz  )r%   r  ry  r   ys        r&   r  LocalPath.common  s>     

ekkm4DAvD 5 r)   c                L    U R                  U R                  [        U5      -   S9$ )z9Return new path object with 'other' added to the basenamer.   )newr.   rE   r  s     r&   __add__LocalPath.__add__  s     xxU!;x<<r)   c              #  X   #    [        XX4U5      R                  U 5       Sh  vN   g N7f)a6  Yields all paths below the current one

fil is a filter (glob pattern or callable), if not matching the
path will not be yielded, defaulting to None (everything is
returned)

rec is a filter (glob pattern or callable) that controls whether
a node is descended, defaulting to None

ignore is an Exception class that is ignoredwhen calling dirlist()
on any of the paths (by default, all exceptions are reported)

bf if True will cause a breadthfirst search instead of the
default depthfirst. Default: False

sort if True will sort entries within each directory level.
N)r   r   r   s         r&   r  LocalPath.visit  s$     $ 3V6::4@@@s    *(*c                    U(       aR  [        US5      (       a0  [        R                  " [        S5      SS9  UR	                  U5        g UR	                  5         g g )Nr   z:listdir(sort=callable) is deprecated and breaks on python3rK   )
stacklevel)r   warningswarnDeprecationWarningr   )r%   resr   s      r&   	_sortlistLocalPath._sortlist  sI    tZ((&T  !	 
 r)   c                    U R                   $ r"   r   r0   s    r&   
__fspath__LocalPath.__fspath__)  s    ||r)   c                f    U R                   n[        (       a  UR                  5       n[        U5      $ r"   )r   r   lowerhash)r%   ss     r&   __hash__LocalPath.__hash__,  s$    LL7	AAwr)   c                   [         R                  " U 5      n [         R                  " U5      n[        (       a%  UR	                  5       n UR	                  5       nX#:H  $ X#:H  $ ! [         a     gf = f! [
         a     gf = fNF)r   r   rQ   r   r  rP   )r%   r  s1s2s       r&   __eq__LocalPath.__eq__2  sz    YYt_	5!B 7BXXZ xrx  		 " s#   A" 
A2 "
A/.A/2
A?>A?c                    X:X  + $ r"   r|   r  s     r&   __ne__LocalPath.__ne__@  s    ""r)   c                \    [         R                  " U 5      [         R                  " U5      :  $ r"   r   r   r  s     r&   __lt__LocalPath.__lt__C      yy5!111r)   c                \    [         R                  " U 5      [         R                  " U5      :  $ r"   r  r  s     r&   __gt__LocalPath.__gt__F  r  r)   c                $   [         R                  " U5      n[        U5      (       d  [        U5      nX:X  a  g[	        [         R
                  S5      (       d  g[        R                  " [         R
                  R                  U R                  U5      $ )z:Return True if 'other' references the same file as 'self'.TsamefileF)
r   r   r   r   r   r$   r   r   r  r   r  s     r&   r  LocalPath.samefileI  sa    		% U||ENE=rww
++!!"''"2"2DLL%HHr)   c                   U R                  SSS9(       a  U(       aJ  [        (       a  U R                  SSS9  SSKn[        R
                  " UR                  U R                  US9  g[        R
                  " [        R                  U R                  5        g[        (       a  U R                  S5        [        R
                  " [        R                  U R                  5        g)zRemove a file or directory (or a directory tree if rec=1).
if ignore_errors is True, errors while removing directories will
be ignored.
r   r   )r   r   i  r  N)ignore_errors)r   r   chmodshutilr   r   rmtreer   r   rmdirrP  )r%   r   r  r  s       r&   rP  LocalPath.removeT  s    
 ::!!:$7JJu!J,""MM4<<} ""288T\\:w

5!ryy$,,7r)   c                     SSK n[        X15      " 5       nU R                  S5      n  UR                  U5      nU(       d   UR                  5       UR                  5         $ UR                  U5        MK  ! [         a    US:X  a  Sn[        U5      n Nf = f! [        [        4 a    [        SU< S35      ef = f! UR                  5         f = f)z,Return hexdigest of hashvalue for this file.r   Nsha1shazDon't know how to compute z hashr.  )hashlibImportError
__import__rO   rP   r   r0  r1  	hexdigestrC  update)r%   hashtype	chunksizemodr  r2  bufs          r&   computehashLocalPath.computehashj  s    		M+%
 3)+D IIdO	ffY'>>+ GGI C 	   +v%$H *+
 , 	M9(UKLL	M GGIs9   A5 B (B< "B< 5BB BB !B9<Cc                N   [         R                  U R                  5      nU(       d  U R                  Ul        U$ U R	                  S5      u  p4pVnSU;   a  SU;   d  SU;   a  [        SU< 35      eOAUR                  SU5      n US   nU(       a  UR                  S5      (       d  SU-   nX-   US'   SU;   a  US   (       d  X1S'   OUR                  SU5        UR                  SU R                  5        [        S	R                  " S
0 UD65      Ul        U$ ! [         a     Nxf = f)aE  Create a modified version of this path.
the following keyword arguments modify various path parts::

  a:/some/path/to/a/file.ext
  xx                           drive
  xxxxxxxxxxxxxxxxx            dirname
                    xxxxxxxx   basename
                    xxxx       purebasename
                         xxx   ext
z'drive,dirname,basename,purebasename,extr.   r(  r5   zinvalid specification r,   r   r   z{dirname}{sep}{basename}r|   )object__new__r  r   r#  r   
setdefaultr/   KeyErrorr   r   format)	r%   rY   objdriver   r.   r(  r5   pbs	            r&   r  LocalPath.new  s     nnT^^,,,CKJ6:oo57
3 #u{ #9"!@AA (3 ~|<B$i s~~c22)CXBzN?2i=!yMMM)W-
eTXX&9@@F2FG
  s   D 
D$#D$c                >   / nU R                   R                  U R                  5      n[        SUR                  S5      5      nU H  nUS:X  a  UR	                  US   5        M  US:X  a/  UR	                  U R                  R                  USS 5      5        MT  US   nUS:X  a  UR	                  U5        Mr  UR                  S5      nUS:X  a  US	pOUSU XgS pUS
:X  a  UR	                  U5        M  US:X  a  UR	                  U	5        M  [        SU< 35      e   U$ )zSee new for what 'spec' can be.N,r  r   r   r   r.   r,   rW  r(  r5   zinvalid part specification )r   rA  r   filterrh  r  rfindr   )
r%   specr  rz  rb  rZ   r.   ir(  r5   s
             r&   r#  LocalPath._getbyspec  s   ""488,dDJJsO,Dw

58$"

488==s45 9:%JJx( s+ABw,4bc,4RaL(2,c~-

<0

3(+Fth)OPP) * 
r)   c                    U(       dQ  [         R                  U R                  5      n[        U R                  5      Ul        U(       a  UR
                  " U6 nU$ U R                  SS9R
                  " U0 UD6$ )z?Return the directory path joined with any given path arguments.rW  r  )r  r  r  r   r   r  r  )r%   rb  kwargsr$   s       r&   rv  LocalPath.dirpath  s^    >>$..1D"4<<0DLyy$'Kxxx$))4:6::r)   absc               F   U R                   nU Vs/ s H  n[        R                  " U5      PM     nnU R                  nU(       a<  / n[	        U5       H+  n[        U5      (       a  UnUn  OUR                  SU5        M-     UR                  U5      (       a  SOUnU HK  nUR                  U5      n[        (       a#  UR                  S5      nUR                  SU5      nXh-   U-   nUnMM     [        R                  U R                  5      n	[        U5      U	l        U	$ s  snf )zReturn a new path by appending all 'args' as path
components.  if abs=1 is used restart from root if any
of the args is an absolute path.
r   rW  /)r   r   r   r   reversedr   insertrF   stripr   r   r  r  r  r   )
r%   r  rb  r   r7   strargsr   newargs
actual_sepr  s
             r&   r  LocalPath.join  s    
 hh-12Tc299S>T2,,!#G(::!G%Gq#& ) #++C00Rc
C))C.Cwiinkk#s+*S0GJ  nnT^^,w'
- 3s    Dc                   U(       a  U R                  5       R                  SS9  U(       a/  [        R                  " [        R
                  U R                  UUS9$ [        R                  " [
        U R                  U5      $ )zdReturn an opened file with the given mode.

If ensure is True, create parent directories if needed.
r   r   r9  )rv  ra  r   r   ior0  r   )r%   ri   ra  r:  s       r&   r0  LocalPath.open  sc    
 LLN!!a!(%%!	  !!$d;;r)   c                    [         R                  U R                  5      nU R                  U R                  -   U-   Ul        U$ r"   )r  r  r  r   r   )r%   rZ   childs      r&   	_fastjoinLocalPath._fastjoin  s2    t~~.txx/$6r)   c                ,    [        U R                  5      $ r"   )r   r   r0   s    r&   r   LocalPath.islink  s    dll##r)   c                :   U(       d  [        U R                  5      $ [        U5      S:X  aL  SU;   a   US   [        U R                  5      -  (       + $ SU;   a   US   [	        U R                  5      -  (       + $ U(       d  SS0n[        U 5      R                  U5      $ )a  Check a path for existence and properties.

Without arguments, return True if the path exists, otherwise False.

valid checkers::

    file = 1  # is a file
    file = 0  # is not a file (may not even exist)
    dir = 1  # is a dir
    link = 1  # is a link
    exists = 1  # exists

You can specify multiple checker definitions, for example::

    path.check(file=1, link=1)  # a link pointing to a file
r   r   r    r   )r   r   r[  r	   r
   r   r^   )r%   rY   s     r&   r   LocalPath.check  s    " $,,''r7a<{e9uT\\'::::|f:t||(<<<<AB~''++r)   z*?[c                z   UcH  UcE  [         R                  " [        R                  U R                  5      n[        U R                  U5      $ [        U[        5      (       a[  U R                  R                  U5      (       d0  U R                  U5      n[        UR                  5      (       a  U/$ / $ [        U5      n[         R                  " [        R                  U R                  5      n/ nU H7  nU R                  U5      nUb  U" U5      (       d  M&  UR                  U5        M9     U R                  XR5        U$ )zTList directory contents, possibly filter by the given fil func
and possibly sorted.
)r   r   r   r   r   r   r  r   rE   _patterncharsintersectionr   r   rh  r  )r%   r   r   namesr  r  rZ   s          r&   r   LocalPath.listdir#  s     ;4<&&rzz4<<@Et~~u55c3%%22377s+%--((!7N	C.C""2::t||<DNN4(E{c%jj

5!  	s!
r)   c                6    U R                  5       R                  $ )z)Return size of the underlying file object)rc   r   r0   s    r&   r   LocalPath.size:  s    yy{r)   c                6    U R                  5       R                  $ )z*Return last modification time of the path.)rc   r   r0   s    r&   r   LocalPath.mtime>      yy{   r)   c                :   U R                  SS9(       a|  UR                  SS9(       a  UR                  U R                  5      nX:w  d   e[        X5        U(       a   [	        U R
                  UR
                  5        U(       a  [        X5        ggS nU R                  US9 H  nUR                  U 5      nUR                  U5      nUR                  5       R                  SS9  UR                  SS9(       a!  UR                  UR                  5       5        Mw  UR                  SS9(       a  [        XW5        O#UR                  SS9(       a  UR                  SS9  U(       a   [	        UR
                  UR
                  5        U(       d  M  [        XW5        M     g)zCopy path to target.

If mode is True, will copy permission from path to target.
If stat is True, copy permission, last modification
time, last access time, and flags from path to target.
r   rs  r   c                     U R                  SS9$ r   r  )r   s    r&   r   LocalPath.copy.<locals>.recT  s    wwAw&r)   r  r   N)r   r  r.   copychunkedcopymoder   copystatr  r?   rv  ra  r  r  )r%   r  ri   rc   r   r   r\  newxs           r&   rO  LocalPath.copyB  s-    ::1:|||"T]]3>!>%v~~6& ' ZZCZ(''$-{{7+%%!%,777?$$QZZ\2WW!W_(WWW^KKAK&QYY54Q% )r)   c                    [         R                  " U5      n[        R                  " [         R                  U R
                  U5      $ )zRename this path to target.)r   r   r   r   rM  r   rQ  s     r&   rM  LocalPath.renameg  s-    6"!!"))T\\6BBr)   c                    U R                  S5      nSSKn [        R                  " UR                  XU5        UR                  5         g! UR                  5         f = f)z Pickle object into path locationwbr   N)r0  rH  r   r   dumprC  )r%   r  binr2  rH  s        r&   r  LocalPath.dumpl  s@    IIdO	v{{CC8GGIAGGIs   "A
 
Ac                    U R                   " U6 n[        R                  " [        R                  [        R
                  " U5      5        U$ )z/Create & return the directory joined with args.)r  r   r   r   mkdirr   )r%   rb  r   s      r&   r  LocalPath.mkdirv  s1    IIt288RYYq\2r)   c                    U(       a  U R                  5       R                  SS9  U R                  S5       nUR                  U5        SSS5        g! , (       d  f       g= f)zTWrite binary data into path.   If ensure is True create
missing parent directories.
r   r   r  Nrv  ra  r0  write)r%   datara  r2  s       r&   write_binaryLocalPath.write_binary|  s@     LLN!!a!(YYt_GGDM __s   A
Ac                    U(       a  U R                  5       R                  SS9  U R                  SUS9 nUR                  U5        SSS5        g! , (       d  f       g= f)zmWrite text data into path using the specified encoding.
If ensure is True create missing parent directories.
r   r   wr9  Nr	  )r%   r  r:  ra  r2  s        r&   
write_textLocalPath.write_text  sG     LLN!!a!(YYsXY.!GGDM /..s   A
Ac                   U(       a  U R                  5       R                  SS9  SU;   a!  [        U[        5      (       d  [	        S5      eOZ[        U[
        5      (       dE  [        U[        5      (       d  [        U5      nO$UR                  [        R                  " 5       5      nU R                  U5      n UR                  U5        UR                  5         g! UR                  5         f = f)zMWrite data into path.   If ensure is True create
missing parent directories.
r   r   bzcan only process bytesN)rv  ra  r   bytesr   rE   decoderX  getdefaultencodingr0  r
  rC  )r%   r  ri   ra  r2  s        r&   r
  LocalPath.write  s     LLN!!a!($;dE** !9:: + dC((!$..t9D;;s'='='?@DIIdO	GGDMGGIAGGIs   8C C,c                *   U R                  5       nX:X  a  U $ UR                  SS9(       a  UR                  5         U R                  SS9(       a   U R                  5         U $ U $ ! [        R
                   a    U R                  SS9(       a  e  U $ f = f)Nr   r   )rv  r   _ensuredirsr  r   EEXIST)r%   parents     r&   r  LocalPath._ensuredirs  s    >K<<A< ::!:

 t <<  ::!:$ %s   A% %)BBc                   U R                   " U6 nUR                  SS5      (       a  UR                  5       $ UR                  5       R                  5         UR	                  SS9(       d  UR                  S5      R                  5         U$ )zEnsure that an args-joined path exists (by default as
a file). if you specify a keyword argument 'dir=True'
then the path is forced to be a directory path.
r   r   r   rs  r  )r  rX   r  rv  r   r0  rC  )r%   rb  r  r   s       r&   ra  LocalPath.ensure  sg    
 IIt::eQ==?"IIK##%777?t""$Hr)   c                    g r"   r|   r%   raisings     r&   rc   LocalPath.stat  s    :=r)   c                    g r"   r|   r   s     r&   rc   r"    s    <?r)   c                   U(       a9  [        U [        R                  " [        R                  U R
                  5      5      $  [        U [        R                  " U R
                  5      5      $ ! [         a    e [         a     gf = f)zReturn an os.stat() tuple.N)r`   r   r   r   rc   r   KeyboardInterrupt	Exceptionr   s     r&   rc   r"    sc    e00$,,GHH	bggdll344  	 		s   )A, ,BBc                t    [        U [        R                  " [        R                  U R
                  5      5      $ )zReturn an os.lstat() tuple.)r`   r   r   r   re   r   r0   s    r&   re   LocalPath.lstat  s$    D%,,RXXt||DEEr)   c                   Uc0  [         R                  " [        R                  U R                  U5      $  [         R                  " [        R                  U R                  SU45      $ ! [         R
                   aC    [         R                  " [        R                  U R                  U R                  5       U45      s $ f = f)zSet modification time for the given path.  if 'mtime' is None
(the default) then the file's mtime is set to current time.

Note that the resolution for 'mtime' is platform dependent.
r   )r   r   r   utimer   rL  atime)r%   r   s     r&   setmtimeLocalPath.setmtime  s     =%%bhheDD	U%%bhhr5kJJ|| 	U%%bhhtzz|U>STT	Us   1A' 'AB>=B>c                     U R                  5       n[        R                  " [        R
                  U R                  5        U$ ! [        R                   a    Sn NIf = f)z9Change directory to self and return old current directoryN)r  r   rT   r   r   chdirr   r%   olds     r&   r/  LocalPath.chdir  sL    	.."C 	288T\\2
 || 	C	s   A AAc              #     #    U R                  5       n Uv   Ub  UR                  5         gg! Ub  UR                  5         f f = f7f)z
Return a context manager, which changes to the path's dir during the
managed "with" context.
On __enter__ it returns the old dir, which might be ``None``.
N)r/  r0  s     r&   as_cwdLocalPath.as_cwd  sB      jjl	I		 s		 s   A- AAAc                r    U R                  [        R                  R                  U R                  5      5      $ )z3Return a new path which contains no symbolic links.)r  r   r$   realpathr   r0   s    r&   r7  LocalPath.realpath  s$    ~~bgg..t||<==r)   c                6    U R                  5       R                  $ )z$Return last access time of the path.)rc   r+  r0   s    r&   r+  LocalPath.atime  r  r)   c                $    SU R                   < S3$ )Nzlocal()r  r0   s    r&   __repr__LocalPath.__repr__  s    'q))r)   c                    U R                   $ )z)Return string representation of the Path.r  r0   s    r&   __str__LocalPath.__str__  s    ||r)   c                F   [        U[        5      (       d  [        SU< S35      eU(       aE  U R                  US9 H2  n[        R
                  " [        R                  [        U5      U5        M4     [        R
                  " [        R                  U R                  U5        g)zChange permissions to the given mode. If mode is an
integer it directly encodes the os-specific modes.
if rec is True perform recursively.
zmode z must be an integerr  N)
r   r   rQ   r  r   r   r   r  rE   r   )r%   ri   r   r   s       r&   r  LocalPath.chmod	  sr    
 $$$eD8+>?@@ZZCZ(""288SVT: )288T\\48r)   c                    SnU R                  SS9 H`  nUR                  5       (       d  M  UR                  S5      R                  5       (       d    U$ [	        UR
                  5      (       d    U$ UnMb     U$ )zReturn the Python package path by looking for the last
directory upwards which still contains an __init__.py.
Return None if a pkgpath cannot be determined.
NT)rw  __init__.py)rz  r	   r  r   isimportabler.   )r%   pkgpathr  s      r&   	pypkgpathLocalPath.pypkgpath  sr    
 jjj.F||~~{{=188::  $FOO44 ! / r)   c                   U(       a  [        U5      nUS:X  a5  U[        R                  ;  a   [        R                  R                  U5        g g U[        R                  S   :w  a!  [        R                  R	                  SU5        g g g )Nrh  r   )rE   rX  r$   rh  r  )r%   
ensuremoder$   r  s       r&   _ensuresyspathLocalPath._ensuresyspath$  se    D	AX%CHH$HHOOA& % #HHOOAq) $ r)   c                   U R                  5       (       d  [        R                  " U 5      eUS:X  a  Uc  U R                  n[        R
                  R                  U[        U 5      5      nUb  UR                  c  [        SU SU < 35      e[        R
                  R                  U5      nUR                  R                  U5        U$ SnUGc  U R                  5       nUbr  UR                  5       nU R                  SS9R                  U5      R!                  U R"                  5      nUS   S:X  a  UR%                  5         S	R'                  U5      nOU R                  5       nU R                  nU R)                  X&5        [+        U5        [,        R.                  U   nU R0                  S
:X  a  U$ UR2                  nUc   eUSS S;   a  USS nOUR5                  S5      (       a  USS S-   nUR5                  [6        R"                  S
-   5      (       a  U R0                  S
:w  a  USS n U R9                  U5      n	U	(       d.  [6        R:                  " S5      n
U
S:w  a  U R=                  XU 5      eU$  [,        R.                  U   $ ! [        R                   a    Sn	 Ncf = f! [>         a    SSK nURC                  U5      n[        U 5      Ul        U[,        R.                  U'    [E        [        U 5      S5       n[G        URI                  5       URJ                  5        SSS5        O1! , (       d  f       O#= f! [L         a    [,        R.                  U	 e f = fUs $ f = f)ap  Return path as an imported python module.

If modname is None, look for the containing package
and construct an according module name.
The module will be put/looked up in sys.modules.
if ensuresyspath is True then the root dir for importing
the file (taking __init__.py files into account) will
be prepended to sys.path if it isn't there already.
If ensuresyspath=="append" the root dir will be appended
if it isn't already contained in sys.path.
if ensuresyspath is False no modification of syspath happens.

Special value of ensuresyspath=="importlib" is intended
purely for using in pytest, it is capable only of importing
separate .py files outside packages, e.g. for test suite
without any __init__.py file. It effectively allows having
same-named test modules in different places and offers
mild opt-in via this option. Note that it works only in
recent versions of python.
	importlibNzCan't find module z at location rW  )r5   r   r'   r,   rE  )z.pycz.pyoz	$py.classiz.pyiFPY_IGNORE_IMPORTMISMATCH1r   r.  )'r   r   rT   r(  rO  utilspec_from_file_locationrE   loaderr  module_from_specexec_modulerH  rv  r  r?   rA  r   popr  rL  r  rX  modulesr.   __file__rF   r   r  getenvr   r  types
ModuleTyper0  execr1  __dict__BaseException)r%   modnameensuresyspathr  r  rG  pkgrootr  modfileissamer   r\  r2  s                r&   pyimportLocalPath.pyimport.  s   * zz||,,t$$K'++>>99'3t9MD|t{{2!$6wi}TH"UVV..11$7CKK##C(J?nn&G"!//+R(..w7==dhhG9
*IIK((5/,,.++7w++g&C}}-
llG&&&rs|//!#2,!!+..!#2,. 677==M1%dsmGw/ #=>S=227TJJJ{{7++ <<   &&w/"4y'*G$c$i.!QVVXs||4 /..$ G, 
sa   +J 4J# J J #AM&L:;%L) L:(M)
L7	3L:6M7L::MMMc           	     >   SSK Jn  SSK Jn  UR                  SS5        UR                  SS5        U" [	        U 5      /U Vs/ s H  n[	        U5      PM     sn-   40 UDUUS.D6nUR                  5       u  pxUR                  5       n	[        U[        5      (       a$  UR                  [        R                  " 5       5      nU	S:w  aQ  [        U[        5      (       a$  UR                  [        R                  " 5       5      n[        U	U	[	        U 5      UU5      eU$ s  snf )zReturn stdout text from executing a system child process,
where the 'self' path points to executable.
The process is directly invoked and not through a system shell.
r   )PIPE)PopenstdoutNstderr)rk  rl  )
subprocessri  rj  rX  rE   communicatewaitr   r  r  rX  r  RuntimeError)
r%   argv
popen_optsri  rj  r7   procrk  rl  rets
             r&   sysexecLocalPath.sysexec  s    
 	$$x&x&YKt4t3s8t44

 	
 ))+iikfe$$]]3#9#9#;<F!8&%((s'='='?@D	  ) 5s   D
c                t   [        U5      (       a#  [        U5      nUR                  SS9(       a  U$  gUc  [        (       au  [        R
                  S   R                  S5      nSU;  a  SU;  a  UR                  S5         [        R
                  S   nU Vs/ s H  ofR                  S	U5      PM     nnO"[        R
                  S
   R                  S5      n/ n[        (       a3  U[        R
                  S   R                  [        R                  5      -  nUR                  S5        U HY  nU HP  n	[        U5      R                  USS9U	-   n UR                  SS9(       a  U(       a  U" U5      (       d  MJ  Us  s  $ MR     M[     gs  snf ! [         a     Nf = f! [        R                   a     M  f = f)a  Return a path object found by looking at the systems
underlying PATH specification. If the checker is not None
it will be invoked to filter matching paths.  If a binary
cannot be found, None is returned
Note: This is probably not working on plain win32 systems
but may work on cygwin.
r   rs  NPath;rW  r,   
SYSTEMROOTz%SystemRoot%PATH:PATHEXTTr  )r   localr   r   r   environrA  rh  r   r  pathsepr  r   EACCES)
clsrZ   checkerpathsr   
systemrootr$   tryaddr   addexts
             r&   sysfindLocalPath.sysfind  s    ;;dAwwAw D ? }7JJv.44S9E3e+;S)%'ZZ%=

 RW!QVLLDQV  ! JJv.44S9EFw"**Y/55bjjAAMM"$Fad5>A777?&'.qzz$,#$H	 + %  +! $ , !<< s0   F F
(F;F
FFF76F7c                     [         R                  S   nU " U5      $ ! [         a<     [         R                  S   [         R                  S   -   n N<! [         a      g f = ff = f)NHOME	HOMEDRIVEHOMEPATH)r   r  r  )r  r   s     r&   _gethomedirLocalPath._gethomedir  sd    	

6"A 1v  	JJ{+bjj.DD 	s&    
A#'A
AA#AA#c                <    SSK n[        UR                  5       5      $ )zQReturn the system's temporary directory
(where tempfiles are usually created in)
r   N)tempfiler~  
gettempdir)r  r  s     r&   get_temprootLocalPath.get_temproot  s    
 	X((*++r)   c                    SSK nUc  U R                  5       n[        R                  " UR                  [        U5      S9nU " U5      $ )z_Return a Path object pointing to a fresh new temporary directory
(which we created ourselves).
r   Nr   )r  r  r   r   mkdtemprE   )r  rootdirr  r$   s       r&   r  LocalPath.mkdtemp  s@    
 	?&&(G!!("2"2GE4yr)   c                4  ^^ Uc  U R                  5       nUR                  5       mU4S jnS nS nSn Sn	UR                  5        H  n
U" U
5      nUc  M  [        X5      n	M      UR	                  U[        U	S-   5      -   5      nU(       a  U" U5      nU" U5         S nUS-   mU4S	 jnU" U5      nU(       a  U(       a  UR                  5        H  n
U" U
5      nUbi  XU-
  ::  aa   U(       a  U" U
5        UR                  T[        [        R                  " 5       5      -   5      n U
R                  U5        UR                  SS
9  U" U
5      (       d  M   U
R                  SS
9  M      [$        R&                  S   n[        U5      nUSUR+                  S5       S-   U-   n [$        R,                  " U5         [$        R0                  " UU5        U$ ! [        R                  [        R                  [        R                  4 a    X:X  a  e U	n GM  f = f! [        R                  [        R                  [        R                  4 a-    U" U
5      nU(       d   GM  [        UU-
  5      U:  a   GM   GNf = f! [          a    e ["         a     GNJf = f! [          a    e ["         a     GM  f = f! [(         a,     [$        R&                  S   n GNT! [(         a    Sn  GNdf = ff = f! [.         a     GN=f = f! [.        [2        [4        4 a     U$ f = f)a(  Return unique directory with a number greater than the current
maximum one.  The number is assumed to start directly after prefix.
if keep is true directories with a number less than (maxnum-keep)
will be removed. If .lock files are used (lock_timeout non-zero),
algorithm is multi-process safe.
Nc                   > U R                   R                  5       nUR                  T5      (       a   [        U[	        T5      S 5      $ g! [
         a     gf = f)z9Parse the number out of a path (if it matches the prefix)N)r.   r  r/   r   r[  r   )r$   	nbasenamenprefixs     r&   	parse_num.LocalPath.make_numbered_dir.<locals>.parse_num	  sZ    ++-I##G,,yW899 - " s   A 
AAc                   [         R                  " 5       nU R                  S5      n[        US5      (       a  UR	                  [        U5      5        U$ [        R                  " [         R                  [        U5      [         R                  [         R                  -  [         R                  -  S5      n[         R                  " US5       nUR                  [        U5      5        SSS5        U$ ! , (       d  f       U$ = f)z/Exclusively create lockfile. Throws when failedz.lockr  i  r  N)r   getpidr  r   r  rE   r   r   r0  O_WRONLYO_CREATO_EXCLfdopenr
  )r$   mypidlockfilefdr2  s        r&   create_lockfile4LocalPath.make_numbered_dir.<locals>.create_lockfile  s    IIKEyy)Hx//$$SZ0 O ''GGS]BKK"**,Dryy,PRW YYr3'1GGCJ' (O ('Os   C00
C?c                l   ^ ^ [         R                  " 5       mU U4S jn[        R                  " U5        g)z*Ensure lockfile is removed at process exitc                    > [         R                  " 5       T:w  a  g  T R                  5         g ! [        R                   a     g f = fr"   )r   r  rP  r   Error)r  r  s   r&   try_remove_lockfileXLocalPath.make_numbered_dir.<locals>.atexit_remove_lockfile.<locals>.try_remove_lockfile$  s;     99;%'OO%{{ s   . AAN)r   r  atexitregister)r  r  r  s   ` @r&   atexit_remove_lockfile;LocalPath.make_numbered_dir.<locals>.atexit_remove_lockfile   s"    IIKE OO/0r)   r   r   c                l     U R                  5       R                  $ ! [        R                   a     gf = f)zRead file modification timeN)re   r   r   r  r#   s    r&   	get_mtime.LocalPath.make_numbered_dir.<locals>.get_mtimeQ  s/    zz|)));; s    33zgarbage-c                >   > U R                   nUR                  T5      $ )z5Check if path denotes directory scheduled for removal)r.   r/   )r$   bngarbage_prefixs     r&   
is_garbage/LocalPath.make_numbered_dir.<locals>.is_garbageZ  s    B==00r)   r  USERUSERNAMErx  -)r  r  r   maxr  rE   r   r  rT   rV   r  r  uuiduuid4rM  rP  r%  r&  r   r  r  r  unlinkOSErrorr  rP   r   )r  prefixr  keeplock_timeoutr  r  r  lastmaxmaxnumr$   numudirr  r  r  	udir_time	path_timegarbage_pathusernamesrcri  r  r  s                         @@r&   make_numbered_dirLocalPath.make_numbered_dir  s    ?&&(G,,.			1( F)o? -F *}}Vc&1*o%=>.t4H*84 	  *,	1 dO	I)o?s}'=%'+D1 $+<<TZZ\AR0R#SLL1$+++2
 d##*= *J	%zz&)H $i#SYYs^$s*X5	IIdO	JJsD! q LL%,,<  $ N "LL%,,D %$-dO	($y945D % E%" - $ 
 - $   	%%::j1 %$%	%  		 )<= 		s   '7G *H* I=J.J4 'K- >K> ;HHAI: I:9I:=JJJ10J14
K*?KK&!K*%K&&K*-
K;:K;>LLr  r  )r   )ru   rE   )r   )r8  )F)r   F)md5   )r  rE   ru   z	list[str])rb  os.PathLike[str]r  rS   ru   r   )r8  FN)NNr   r   )FF)r  F).)r!  zLiteral[True]ru   r`   )r!  zLiteral[False]ru   Stat | None)T)r!  rS   ru   r  rt   r"   r   )rq  r  rr  r   ru   rE   )zsession-NrK   i  )`rv   rw   rx   ry   r   r  r   r   r   r'   rX  rY  r  r  r  r  r  __truediv__r   r.   r   r(  r5   r3  r;  r1  rB  rI  rR  rB   r?   rc  rl  r   r	   r
   rz  r  r  r~   r  r  r  r  r  r  r  r  r  rP  r  r  r#  rv  r  r0  r  r   r   setr  r   r   r   rO  rM  r  r  r  r  r
  r  ra  r   rc   re   r,  r/  r   r4  r7  r+  r=  r@  r  rH  rL  rf  ru  classmethodr  r  r  r  r  r{   r|   r)   r&   r   r   	  s   Hk H &&C)0 ||w	>	A
	A	E+ K. . - - 2 2 ) )


(&&,4!" 	= ${u5 A(#22	I8,,&P:; 9> << 
$,8 'M. !#&JC
*  = =? ?	FU  >!*
9*WrB , ,\   , , 	 	 CI_ _r)   r   c                .    SSK nUR                  X5        g)z Copy permission from src to dst.r   N)r  r  r  ri  r  s      r&   r  r    s    
OOCr)   c                T    SSK nUR                  [        U 5      [        U5      5        g)zVCopy permission,  last modification time,
last access time, and flags from src to dst.r   N)r  r  rE   r  s      r&   r  r    s     
OOCHc$i(r)   c                @   SnU R                  S5      n UR                  S5      n  UR                  U5      nU(       d  OUR                  U5        M,  UR                  5          UR                  5         g ! UR                  5         f = f! UR                  5         f = f)Nr  r.  r  )r0  r1  r
  rC  )r  ri  r  fsrcfdestr  s         r&   r  r    s~    I88D>D		$	ii	*C 	  KKM

 KKM

s"   B -A6 B 6BB Bc                    U (       aR  U S   R                  5       (       d	  U S   S:X  a0  U R                  SS5      n U (       + =(       d    U R                  5       $ g g )Nr   _rW  )isalphar   isalnum)rZ   s    r&   rF  rF    sI    a""d1gn||C$x)4<<>) '5tr)   )7r   
__future__r   r  
contextlibr   rB   importlib.utilrO  r  r   os.pathr   r   r   r   r	   r
   r   r   r   rc   r   r   r   rX  typingr   r   r   r   r   r   r  r  rW  r   rY  rO   r   r   r&  r~   r   r   r   r`   r   r   r   r  r  r  rF  r~  r|   r)   r&   <module>r     s      "  %   	 	             
           ,,'
!
Jgb'5&AT&IZ  Z z	) 	 ,  ,F. .4!+3 +3\Q Qh$)"* 	r)   