j7iD$dZddlmZddlZddlmZddlmZddlZddl Z ddl Z ddl Z ddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlZddlmZddlmZddlmZddlZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"Z"ddl#Z#ddl$m%Z%ejLdk(xs e'e dddk(Z(GddZ)Gdde*Z+Gd d!Z,Gd"d#Z-d$Z.Gd%d&Z/d'Z0d(Z1Gd)d*Z2d+Z3d,Z4d-Z5d.Z6e2Z7y)/zlocal path implementation.) annotationsN)Callable)contextmanager)abspath)dirname)exists)isabs)isdir)isfile)islink)normpath)S_ISDIR)S_ISLNK)S_ISREG)Any)cast)Literal)overload) TYPE_CHECKING)errorwin32_nameFntcreZdZUdZdZdZdZdZdZdZ dZ d Z d Z d e d <dd ZdZdZdZdZy)Checkers)rlinkdirfilec||_yNpath)selfr#s Y/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/_pytest/_py/path.py__init__zCheckers.__init__,s  cL|jjjdSN.r#basename startswithr$s r%dotfilezCheckers.dotfile/yy!!,,S11r'c`|jdsd|z}|jj|k(Sr))r-r#extr$args r%r2z Checkers.ext2s*~~c")Cyy}}##r'c4|jj|k(Sr!)r#r,r3s r%r,zCheckers.basename7syy!!S((r'cL|jjj|Sr!r+r3s r% basestartszCheckers.basestarts:r0r'c8|jj|Sr!)r#reltor3s r%r9zCheckers.relto=syys##r'c8|jj|Sr!)r#fnmatchr3s r%r;zCheckers.fnmatch@syy  %%r'cJt|jj|Sr!)strr#endswithr3s r%r>zCheckers.endswithCs499~&&s++r'cddlm}|jD]x\}}d}d} t||}|t d|d|j  ||jd kDr|| |z r#yt|t|z |z ryzy#t$r-|dddk(r"d} t||dd}n#t$rYnwxYwYwxYw#tjtjtjf$rM|jD]:}||vr|j|rYyd|z}||vs&|j|r8YyY3wxYw) N) getrawcodeFnotTzno z checker available for r) _code.sourcerAitemsgetattrAttributeError TypeErrorr# co_argcountboolrENOENTENOTDIREBUSY_depend_on_existenceget)r$kwrAnamevalueinvertmeths r% _evaluatezCheckers._evaluateFsa-88: )KD%FD tT*|#dX-DTYYM RSS )d#//!3 K61$E{T$&\1F:$) )B9" 8u$!F&tT!"X6)   LL%--= )!55)Drz66$<#( 4A?cHt|jjSr!)rr\moder.s r%rz Checkers.dirxtzz|(())r'cHt|jjSr!)rr\r^r.s r%rz Checkers.file{r_r'c"|jSr!)r\r.s r%rzCheckers.exists~zz|r'c`|jj}t|jSr!)r#r[rr^)r$sts r%rz Checkers.links! YY__ rwwr'NreturnrV)__name__ __module__ __qualname__rNr&r/r2r,r7r9r;r>rU__annotations__r\rrrrr'r%rr)sW:2$ )2$&,$L#** r'rc eZdZy) NeverRaisedN)rgrhrirkr'r%rmrmsr'rmceZdZdZdZy)VisitorcFt|tr t|}t|trt||_nt |ds |r d|_n||_||_||_||_|r(tttgtft|_ yd|_ y)N__call__cyNTrkr"s r%z"Visitor.__init__..sr'c|Sr!rkxs r%rtz"Visitor.__init__..sRSr') isinstancer= FNMatcherrechasattrfilignore breadthfirstrrrsortedoptsortr$r|rzr}bfsorts r%r&zVisitor.__init__s{ c3 C.C c3 4=cNDHj)c(DHDH =AtHcUCZ0&9  r'c#K |j}|j}|j|Dcgc]"}|j ds| ||s!|$c}}|j s |D]}|j |Ed{|j|D]$}|j|j|s!|&|j r!|D]}|j |Ed{yy#|j$rYywxYwcc}w77$wNrr)listdirr}rzrcheckr~genr|)r$r#entriesrzpdirssubdirs r%rz Visitor.gens  llnGhh|| N1177q7>s{c!fQ N    ,88F+++ ,g& Axx488A;     ,88F+++ , {{    O, ,sbD C/D D DD,D D 7D ;+D &D 'D /D>D D D  D N)rgrhrir&rrkr'r%roros  U,r'roceZdZdZdZy)ryc||_yr!)patternr$rs r%r&zFNMatcher.__init__s  r'c|j}|j|jdk(rRtrL|jtjdk7r*|j tj|j}|j|jdk(r |j }nG << !R '==Dt9D77==).72tW--r'N)rgrhrir&rqrkr'r%ryrys .r'ryc,tt||Sr!)listmap)funciters r% map_as_listrs D$  r'cteZdZered dZed dZd dZdZedZ edZ dZ dZ d Z y )rVcyr!rkr.s r%sizez Stat.sizes"r'cyr!rkr.s r%mtimez Stat.mtimes"%r'c4t|jd|zS)Nst_)rF _osstatresult)r$rQs r% __getattr__zStat.__getattr__st))54<88r'c ||_||_yr!)r#r)r$r# osstatresults r%r&z Stat.__init__s )r'ctr tdddl}tj|j |j }|dS)N XXX win32r)rNotImplementedErrorpwdr checked_callgetpwuiduid)r$rentrys r%ownerz Stat.owners6 %k2 2""3<<:Qxr'ctr tdddl}tj|j |j }|dS)zReturn group name of file.rrN)rrgrprrgetgrgidgid)r$rrs r%groupz Stat.groups8 %k2 2""3<<:Qxr'c@t|jjSr!)rrst_moder.s r%r z Stat.isdirt))1122r'c@t|jjSr!)rrrr.s r%r z Stat.isfilerr'ct|jjt|jjSr!)r#r[rrrr.s r%r z Stat.islinks' t))1122r'Nrfintrffloat)rQr=rfr)rgrhrirpropertyrrrr&rrr r r rkr'r%rVrVsb " " % %9*333r'rVcVddl}t|ts|j|d}|SNrr@)rrxrgetpwnam)userrs r% getuseridrs' dC ||D!!$ Kr'cVddl}t|ts|j|d}|Sr)rrxrgetgrnam)rrs r% getgroupidrs' eS ! U#A& Lr'c,eZdZdZGddeZejZdWdZe jdk7rdXdZ dYd Z d Z dZd Zd ZeZed ZedZedZedZdZdZd[dZdZdZdZdZdZdZdZdZdZ dZ!dZ"d\dZ#dZ$d Z%dde&ddfd!Z'd"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z.d)Z/d]d*Z0d^d+Z1d,Z2d_d-Z3d.Z4dd/d`d0Z5dad1Z6d2Z7d3Z8d4Z9e:d5ejzZ;dbd6Zded9Z?d:Z@dZd;ZAd<ZBd\d=ZCd\d>ZDdfd?ZEd@ZFdAZGeHdgdhdBZIeHdidCZIdjdkdDZIdldEZJdmdFZKdGZLeMdHZNdIZOdJZPdKZQdLZRdXdMZSdNZTdOZUdndPZVdodQZWeXdbdRZYeXdSZZeXdTZ[eXdmdUZ\eX dpdVZ]y)q LocalPathz]Object oriented interface to os.path and other local filesystem related information. ceZdZdZy)LocalPath.ImportMismatchErrorz9raised on pyimport() if there is a mismatch of __file__'sN)rgrhri__doc__rkr'r%ImportMismatchErrorrsGr'rNFc|)tjtj|_y tj |}|rtjj|}t||_y#t $r tdwxYw)aInitialize 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) rrrgetcwdstrpathfspathrH ValueErrorr# expanduserr)r$r#rs r%r&zLocalPath.__init__sx < --bii8DL yy ww))$/"4=DL  8 s A44B rcFt|}t|}|rZ|jdD]D}|jdst j t jt|||Ft j t jt|||y)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&|jdSNrrrrvs r%rtz!LocalPath.chown..6s!''q'/r'rzrrN) rrvisitrrrrchownr=)r$rrrzrrrws r%rzLocalPath.chown-s~ D/CU#C(ABGAwwAw**288SVS#FG   rxxTC =r'c^tjtj|jS)z Return value of a symbolic link.)rrrreadlinkrr.s r%rzLocalPath.readlink;s%%bkk4<<@ @r'crtjtjt |t |y)z&Posix style hard link to another name.N)rrrrr=)r$oldnames r%mklinktozLocalPath.mklinkto@s   rwwG c$i @r'c|r9tjtjt ||j y|j |}|j|j|}|j|}|j|j}|jjd|z|fz}tjtj||j y)zGCreate a symbolic link with the given value (pointing to another name).)z..N) rrrsymlinkr=rcommon __class__r9countrjoin)r$rRabsolutebase relsourcereldestntargets r% mksymlinktozLocalPath.mksymlinktoDs""2::s5z4<<H{{5) NN5177= **T*MM$((+w{i\'AB""2::vt||Dr'cJ|jtj|Sr!)rrrr$others r%__div__zLocalPath.__div__Qsyy5)**r'c*|jddS)zBasename part of path.r,r _getbyspecr.s r%r,zLocalPath.basenameVsz*1--r'c*|jddS)zDirname part of path.rrrr.s r%rzLocalPath.dirname[sy)!,,r'c*|jddS)zPure base name of the path. purebasenamerrr.s r%rzLocalPath.purebasename`s~.q11r'c*|jddS)z*Extension of the path (including the '.').r2rrr.s r%r2z LocalPath.extesu%a((r'cp|jd5}|jcdddS#1swYyxYw)3Read and return a bytestring from reading the path.rbNopenread)r$fs r% read_binaryzLocalPath.read_binaryj- YYt_ 668   ,5ct|jd|5}|jcdddS#1swYyxYw)z7Read and return a Unicode string from reading the path.rencodingNr)r$r rs r% read_textzLocalPath.read_textos2 YYsXY . !668   s.7cp|j|5}|jcdddS#1swYyxYw)rNr)r$r^rs r%rzLocalPath.readtrrcd}|s"|j|}|jdS|j|} |j|j S#|j wxYw)z}Read and return a list of lines from the path. if cr is False, the newline will be removed from the end of each line.r )rsplitr readlinesclose)r$crr^contentrs r%rzLocalPath.readlinesysViioG==& & $A {{}  s AA+c|jd} ddl}tj|j||j S#|j wxYw)z5(deprecated) return object unpickled from self.read()rrN)rpicklerrloadr)r$rrs r%rzLocalPath.loads> IIdO  %%fkk15 GGIAGGIs #AAc|j|rtj|d |j|y#tj$r$|j ||j YywxYw)zMove this path to target.z.cannot move path into a subdirectory of itselfN)r9rEINVALrenameEXDEVcopyremover$rs r%movezLocalPath.movesY << ,,v'WX X  KK {{  IIf  KKM s;4A21A2c$t||S)a3Return 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. )ryrs r%r;zLocalPath.fnmatchs""y!$''r'ct|ttzst|dt|}|r!|d|jk7r||jz }|j }t jdk(sttdddk(rZtjj|jtjj|r|t|dSy|j|r|t|dSy)z_Return a string which is the relative part of the path to the given 'relpath'. z: not a string or path objectrrrNr)rxr=rrHrrsysplatformrFrr#normcaser-len)r$relpath strrelpathstrselfs r%r9zLocalPath.reltos'3?3wk)FGH H\ *R.DHH4 $(( "J,, <<7 "gb'4&@D&Hww(33BGG4D4DZ4PQs:011   +3z?,- -r'c&|j|ddiS)z0Ensure the path joined with args is a directory.rT)ensure)r$argss r% ensure_dirzLocalPath.ensure_dirst{{D+d++r'c ||k(rtjS|j|}|s t|S|j |}|j |}|r|j |j dz}nd}tjg|z}|r|j||j j|}|S#t$rt|cYSwxYw)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. rr) rcurdirrr=r9rrpardirappendrrG)r$destr self2baserrlstrs r% bestrelpathzLocalPath.bestrelpaths  t|yy ;;t$D4y  4(Ijj&GOODHH-199+/C 7#XX]]3'FM t9  sB>B>BB>>CCc"|jSr!rr.s r%rzLocalPath.existsrbr'c&|jdSrrr.s r%r zLocalPath.isdirszzaz  r'c&|jdS)Nrrrr.s r%r zLocalPath.isfileszzqz!!r'c|}|g} |}|j}||k(rn|j|*|s|j|S)z[Return a root-first list of all ancestor directories plus the path itself. )dirpathr0reverse)r$r;currentr3lasts r%partszLocalPath.partssRfDoo'Gw JJw    KKM r'cd}t|j|jD]\}}||k7r|cS|}|S)zfReturn the common part shared with the other path or None if there is no common part. N)zipr>)r$rr=rwys r%rzLocalPath.commonsG ekkm4 DAqAv D  r'cR|j|jt|zS)z9Return new path object with 'other' added to the basenamer,)newr,r=rs r%__add__zLocalPath.__add__s xxU!;x<>+ GGI C  +v%$H * +  , M9(UKL L M GGIs9A0B#B3B30B B BBB03Cc tj|j}|s|j|_|S|j d\}}}}}d|vrd|vsd|vrGt d||j d|} |d}|r|jdsd|z} ||z|d<d|vr |ds||d<n|j d||j d|jtd jd i||_|S#t$rYrwxYw) aCreate 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,rr2zinvalid specification r*rrz{dirname}{sep}{basename}rk) object__new__rrrr setdefaultr-KeyErrorrr format) r$rPobjdriver _basenamerr2pbs r%rDz LocalPath.news!nnT^^,,,CKJ7; 58 4w <  #u{ #9"!@AA~|> D  D c*g}|jj|j}td|jd}|D]}|dk(r|j |d|dk(r.|j |jj |ddP|d}|dk(r|j |l|j d}|dk(r|d } }n |d|||d} }|d k(r|j ||d k(r|j | td ||S) zSee new for what 'spec' can be.N,rrrrr,r*r!rr2zinvalid part specification )rrrfilterr0rrfindr) r$specrLr>r+rQr,irr2s r%rzLocalPath._getbyspecs ""488,dDJJsO, QDw 58$" 488==s45 9:%JJx( s+ABw,4bc ,4RaL(12,c ~- <0 3(+Fth)OPP) Q* r'c|sLtj|j}t|j|_|r|j |}|S|j dj |i|S)z?Return the directory path joined with any given path arguments.r!rC)ryrzrrrrrD)r$r+kwargsr#s r%r:zLocalPath.dirpathsb>>$..1D"4<<0DL tyy$'K)txxx$))4:6::r'absc|j}|Dcgc]}tj|}}|j}|r5g}t |D]%}t |r|}|}n|j d|'|j|rdn|}|D]F}|j|}tr#|jd}|jd|}||z|z}|}Htj|j} t|| _| Scc}w)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. rr!/)rrrrreversedr insertr>striprrryrzrr ) r$rr+rr4strargsrnewargs actual_sepr~s r%rzLocalPath.joins hh-12c299S>22,, !#G( ':!G%Gq#&  '#++C0Rc  C))C.Ciinkk#s+ *S0GJ nnT^^,w'  -3sDc|r |jjd|r1tjtj |j ||Stjt |j |S)ztReturn an opened file with the given mode. If ensure is True, create parent directories if needed. rrr )r:r*rriorr)r$r^r*r s r%rzLocalPath.opensc  LLN ! !a ! ( %% !   !!$ d;;r'ctj|j}|j|jz|z|_|Sr!)ryrzrrr)r$rQchilds r% _fastjoinzLocalPath._fastjoins2t~~. txx/$6  r'c,t|jSr!)r rr.s r%r zLocalPath.islinksdll##r'c  |st|jSt|dk(r@d|vr|dt|jz Sd|vr|dt |jz S|sddi}t |j |S)aCheck 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 rrrr)rrr%r r rrU)r$rPs r%rzLocalPath.checks"$,,' ' r7a<{e9uT\\'::::|f:t||(<<<<AB~''++r'z*?[cD|F|Dtjtj|j}t |j |St|trQ|jj|s+|j |}t|jr|gSgSt|}tjtj|j}g}|D]/}|j |}| ||s|j|1|j|||S)zdList directory contents, possibly filter by the given fil func and possibly sorted. )rrrrrrrrxr= _patternchars intersectionrryr0rM)r$r|rnamesrrLrQs r%rzLocalPath.listdir#s ;4<&&rzz4<<@Et~~u5 5 c3 %%2237s+%--(!7N C.C""2::t||< "DNN4(E{c%j 5! " sD! r'c6|jjS)z)Return size of the underlying file object)rYrr.s r%rzLocalPath.size:syy{r'c6|jjS)z*Return last modification time of the path.)rYrr.s r%rzLocalPath.mtime>yy{   r'c|jdrr|jdr|j|j}||k7sJt|||r t |j |j |r t ||yyd}|j|D]}|j|}|j|}|jjd|jdr |j|jw|jdr t||n$|jdr|jd|r t |j |j |st ||y)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. rr8rc&|jdSrr)rs r%rzzLocalPath.copy..recTswwAw&r'rrN) rrr, copychunkedcopymodercopystatrr9r:r*rr)r$rr^rYrzrwr&newxs r%rzLocalPath.copyBs: ::1: |||"T]]36> !> f %v~~6v& 'ZZCZ( &''$-{{7+ %%!%,777?$$QZZ\2WW!W_4(WWW^KKAK&QYY 5Q% &r'ctj|}tjtj|j |S)zRename this path to target.)rrrrrrrs r%rzLocalPath.renamegs-6"!!"))T\\6BBr'c|jd}ddl} tj|j||||j y#|j wxYw)z Pickle object into path locationwbrN)rrrrdumpr)r$r~binrrs r%rzLocalPath.dumplsB IIdO    v{{CC 8 GGIAGGIs "A Ac|j|}tjtjtj ||S)z/Create & return the directory joined with args.)rrrrmkdirr)r$r+rs r%rzLocalPath.mkdirvs3 DIIt  288RYYq\2r'c|r |jjd|jd5}|j|dddy#1swYyxYw)zdWrite binary data into path. If ensure is True create missing parent directories. rrrNr:r*rwrite)r$datar*rs r% write_binaryzLocalPath.write_binary|sK  LLN ! !a ! ( YYt_  GGDM   s AAc|r |jjd|jd|5}|j|dddy#1swYyxYw)z}Write text data into path using the specified encoding. If ensure is True create missing parent directories. rrwr Nr)r$rr r*rs r% write_textzLocalPath.write_textsP  LLN ! !a ! ( YYsXY . ! GGDM   s AAc|r |jjdd|vrt|tsZt dt|t s?t|ts t |}n#|j tj}|j|} |j||jy#|jwxYw)z]Write data into path. If ensure is True create missing parent directories. rrbzcan only process bytesN) r:r*rxbytesrr=decoder"getdefaultencodingrrr)r$rr^r*rs r%rzLocalPath.writes  LLN ! !a ! ( $;dE* !9::dC(!$.t9D;;s'='='?@D IIdO  GGDM GGIAGGIs #CCc|j}||k(r|S|jdr|j|jdr |j|S|S#tj $r|jdrY|SwxYw)Nrr)r:r _ensuredirsrrEEXIST)r$parents r%rzLocalPath._ensuredirss T>K <ST T Us0A$$AB98B9c |j}tjtj |j |S#tj$rd}YGwxYw)z9Change directory to self and return old current directoryN)rrrKrrchdirrr$olds r%rzLocalPath.chdirsL .."C 288T\\2 || C sAAAc#K|j} |||jyy#||jwwxYww)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)rrs r%as_cwdzLocalPath.as_cwdsCjjl I s sA,AAAcr|jtjj|jS)z3Return a new path which contains no symbolic links.)rrr#realpathrr.s r%rzLocalPath.realpaths$~~bgg..t||<==r'c6|jjS)z$Return last access time of the path.)rYrr.s r%rzLocalPath.atimerr'c"d|jdS)Nzlocal()rOr.s r%__repr__zLocalPath.__repr__s 'q))r'c|jS)z)Return string representation of the Path.rOr.s r%__str__zLocalPath.__str__s ||r'c.t|tstd|d|rE|j|D]0}t j t jt||2t j t j|j|y)zChange permissions to the given mode. If mode is an integer it directly encodes the os-specific modes. if rec is True perform recursively. zmode z must be an integerrN) rxrrHrrrrrgr=r)r$r^rzrws r%rgzLocalPath.chmod st $$eD8+>?@ @ ZZCZ( ;""288SVT: ; 288T\\48r'cd}|jdD]O}|js|jdjs|St |j s|S|}Q|S)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)r; __init__.py)r>r rr isimportabler,)r$pkgpathrs r% pypkgpathzLocalPath.pypkgpathso jjj. !F||~{{=188:$FOO4!  !r'c|r{t|}|dk(r3|tjvr tjj|yy|tjdk7r!tjj d|yyy)Nr0r)r=r"r#r0r)r$ ensuremoder#rTs r%_ensuresyspathzLocalPath._ensuresyspath$se D AX%CHH$HHOOA&% #HHOOAq)$ r'cx|jstj||dk(r| |j}tj j |t|}| |jtd|d|tj j|}|jj||Sd}||j}|t|j}|jdj|j!|j"}|ddk(r|j%d j'|}n|j}|j}|j)||t+|t,j.|}|j0d k(r|S|j2}|J|d dd vr|dd}n|j5d r|dddz}|j5t6j"d zr|j0d k7r|dd} |j9|} | s-t7j:d} | dk7r|j=||||S t,j.|S#tj$rd} Y\wxYw#t>$rddl } | jC|}t||_|t,j.|< tEt|d5} tG| jI|jJdddn #1swYnxYwn#tL$rt,j.|=wxYw|cYSwxYw)aReturn 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. importlibNzCan't find module z at location r!)r2rr&r*r)z.pycz.pyoz $py.classiz.pyiFPY_IGNORE_IMPORTMISMATCH1rr)'rrrKrrutilspec_from_file_locationr=loaderromodule_from_spec exec_modulerr:rDr9rrpoprrrpr"modulesr,__file__r>rrdgetenvrr|types ModuleTyperexecr__dict__ BaseException) r$modname ensuresyspathrrurpkgrootrmodfileissamer}rrs r%pyimportzLocalPath.pyimport.s*zz|,,t$ $ K '++>>99'3t9MD|t{{2!$6wi}TH"UVV..11$7C KK # #C (J ?nn&G"!//+R(..w7==dhhG9 *IIK((5/,,.++    w 7 w ++g&C}} - llG& &&rs|//!#2,!!+.!#2,. 67==M1%dsmG w/#=>S=227GTJJJ {{7++<<   &&w/"4y '* G$c$i.5!QVVXs||4555$ G,  sUI(J(J?JAL9L%L? LL LL9L11L98L9c  ddlm}ddlm}|jdd|jdd|t |g|Dcgc] }t |c}zfi|||d}|j \}}|j } t|tr#|jtj}| dk7rKt|tr#|jtj}t| | t ||||Scc}w)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)PopenstdoutNstderr)rr) subprocessrrrr= communicatewaitrxrrr"r RuntimeError) r$argv popen_optsrrr4procrrrets r%sysexeczLocalPath.sysexecs $$x&x& YKt43s84 4    ))+iik fe $]]3#9#9#;A777?&'.qz$,#$H +  +!$,!<<s00E(E#;E7E7( E43E47F  F c tjd}||S#t$r< tjdtjdz}n#t$rYYywxYwYLwxYw)NHOME HOMEDRIVEHOMEPATH)rrr|)rrws r% _gethomedirzLocalPath._gethomedirsi  6"A 1v   JJ{+bjj.DD   s2 A"'AA" AA"AA"!A"c<ddl}t|jS)zaReturn the system's temporary directory (where tempfiles are usually created in) rN)tempfiler gettempdir)rr#s r% get_temprootzLocalPath.get_temproots X((*++r'cddl}||j}tj|jt |}||S)zoReturn a Path object pointing to a fresh new temporary directory (which we created ourselves). rNr)r#r%rrmkdtempr=)rrootdirr#r#s r%r'zLocalPath.mkdtemps@  ?&&(G!!("2"2G E4yr'c||j}|jfd}d}d}d} d} |jD]} || } | t| | }  |j |t | dzz} |r|| } ||  d}|dzfd }|| }|r|r|jD]} || } | f| | |z kr^ |r|| |jt tjz} | j||jd || s| | jd  t$j&d }t | }|d|j+ddz|z} t%j,| t%j0||| S#t jt jt jf$r || k(r| }YwxYw#t jt jt jf$r%|| }|sYyt||z |krYYpwxYw#t $rt"$rY6wxYw#t $rt"$rYwxYw#t($r* t$j&d }n#t($rd }YnwxYwYSwxYw#t.$rY(wxYw#t.t2t4f$rY| SwxYw)aPReturn 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|jj}|jr t|t dSy#t $rYywxYw)z9Parse the number out of a path (if it matches the prefix)N)r,rRr-rr%r)r# nbasenamenprefixs r% parse_numz.LocalPath.make_numbered_dir..parse_num sW ++-I##G,yW899-"sA AActj}|jd}t|dr|j t ||St jtjt |tjtjztjzd}tj|d5}|jt |ddd|S#1swY|SxYw)z/Exclusively create lockfile. Throws when failedz.lockrirN)rgetpidrr{rr=rrrO_WRONLYO_CREATO_EXCLfdopenr)r#mypidlockfilefdrs r%create_lockfilez4LocalPath.make_numbered_dir..create_lockfilesIIKEyy)Hx/$$SZ0O ''GGS]BKK"**,Dryy,PRWYYr3'(1GGCJ'(O(Os C((C2cftjfd}tj|y)z*Ensure lockfile is removed at process exitctjk7ry jy#tj$rYywxYwr!)rr/rrError)r5r4sr%try_remove_lockfilezXLocalPath.make_numbered_dir..atexit_remove_lockfile..try_remove_lockfile$s; 99;%'OO%{{s,AAN)rr/atexitregister)r5r;r4s` @r%atexit_remove_lockfilez;LocalPath.make_numbered_dir..atexit_remove_lockfile s"IIKE  OO/ 0r'rrcj |jjS#tj$rYywxYw)zRead file modification timeN)r[rrr:r"s r% get_mtimez.LocalPath.make_numbered_dir..get_mtimeQs/ zz|)));;  s 22zgarbage-c>|j}|jS)z5Check if path denotes directory scheduled for removal)r,r-)r#bngarbage_prefixs r% is_garbagez/LocalPath.make_numbered_dir..is_garbageZsB==0 0r'rUSERUSERNAMEr<-)r%rRrmaxrr=rrrKrMrruuiduuid4rrrrrrr|runlinkOSErrorrrGr)rprefixr(keep lock_timeoutr-r7r>lastmaxmaxnumr#numudirr5r@rD udir_time path_time garbage_pathusernamesrcr1rCr,s @@r%make_numbered_dirzLocalPath.make_numbered_dirs ?&&(G,,.   1(F) .o? -F .  }}Vc&1*o%=>.t4H*84   *, 1 dO I)" o?sv}'= %'+D1$+<<TZZ\AR0R#SL L1$+++2 d#  *=" J %zz&)H$i#SYYs^$s*X5  IIdO  JJsD ! qLL%,, < f$  N"LL%,, D%$-dO ($y945 D%E %"-$ -$  % %::j1 %$ % %   )<=    s"2F7 G8#I;I+J J:K 7:G54G58rrErmrrMrPrUrZr\r_rbrdrrwrDrr:rrrr rsetrrrrrrrrrrrrr*rrYr[rrrrrrrrrgrrrr  classmethodrr!r%r'rYrkr'r%rr sHkH &&C)0 ||w > A  A E+K ..--22))   (&&,4!" =${u5A(  #22 I8,,&P:;9><<  $,8'M. !#&JC  * == ?? F U  >!* 9 *WrB,,\,,  CI__r'rc0ddl}|j||y)z Copy permission from src to dst.rN)rhrrXr1rhs r%rrs OOCr'cTddl}|jt|t|y)zZCopy permission, last modification time, last access time, and flags from src to dst.rN)rhrr=rbs r%rrs OOCHc$i(r'c6d}|jd} |jd} |j|}|sn|j|& |j |jy#|jwxYw#|jwxYw)Nr[rr)rrrr)rXr1rtfsrcfdestrvs r%rrsI 88D>D  $ ii * C  KKM  KKM s"B'A1B1BBBc|rC|djs|ddk(r'|jdd}| xs|jSyy)Nr_r!)isalpharisalnum)rQs r%rrsF a"d1gn||C$x)4<<>)'5tr')8r __future__rr<collections.abcr contextlibrr;importlib.utilrrros.pathrrrr r r r r rrYrrrr"typingrrrrrrIrIr!rr#rFrrrrmroryrrVrrrrrrrrrkr'r%rqs " $%    ,,' ! Jgb'5&AT&IZ Z z )  , ,F..4!+3+3\QQh$)"* r'