g} gdZddlZddlZddlZddlZddl Z ddl Z ddl mZddlZddlZddlZddlZej.Zej2ej4zej6zZeedreej<zZeZeedreej@zZeedr ejBZ!ndZ!dZ"eZ#d Z$d Z%d Z&Gd d Z'dZ(dZ)da*dZ+dZ,dZ-dZ.dZ/dZ0da1dZ2dZ3dZ4d-dZ5d.dZ6de"dfdZ7GddZ8Gdd Z9 d/dd!d"d#Z:ejvd$k7sejxd%k(re:Z=need&a> d0dd'd(Z=Gd)d*ej~Z@Gd+d,ZAy)1) NamedTemporaryFile TemporaryFileSpooledTemporaryFileTemporaryDirectorymkstempmkdtempmktempTMP_MAX gettempprefixtempdir gettempdirgettempprefixb gettempdirbN)Random O_NOFOLLOWO_BINARYr i'tmpcN tj|y#t$rYywxYw)NTF)_oslstatOSError)fns //opt/alt/python312/lib64/python3.12/tempfile.py_existsrLs+ "    $$cT d}|D]w}|t|tjrtj|}t|tr|t ur t dt}_|tur t dt }y|&tttt rt StS|S)Nz1Can't mix bytes and non-bytes in path components.) isinstancerPathLikefspathbytesstr TypeErrorr )args return_typeargs r_infer_return_typer&UsLK ;  c3<< (**S/C c5 !c!!344Ke#!344K!" ?j#6JL c t|||}||}|(|turt}ntjt}||tur t }n t }||||fSN)r&r!templaterfsencoder r)prefixsuffixdir output_types r_sanitize_paramsr0rsiC$VVS9K ~ ~ # F\\(+F { # ,C-C 63 ++r'c.eZdZ dZedZdZdZy)_RandomNameSequence%abcdefghijklmnopqrstuvwxyz0123456789_ctj}|t|ddk7rt|_||_|jS)N_rng_pid)rgetpidgetattr_Random_rngr5)selfcur_pids rrngz_RandomNameSequence.rngs8**, gdJ5 5 DI#DMyyr'c|Sr)r:s r__iter__z_RandomNameSequence.__iter__s r'cndj|jj|jdS)N)k)joinr<choices charactersr?s r__next__z_RandomNameSequence.__next__s)wwtxx''1'=>>r'N)__name__ __module__ __qualname__rGpropertyr<r@rHr>r'rr2r2s*+9J ?r'r2c g}dD]+}tj|}|s|j|-tjdk(rR|j tj j dtj jdddddgn|j gd  |jtj|S#ttf$r#|jtjY|SwxYw) N)TMPDIRTEMPTMPntz~\AppData\Local\Tempz%SYSTEMROOT%\Tempzc:\tempzc:\tmpz\tempz\tmp)z/tmpz/var/tmpz/usr/tmp) rgetenvappendnameextendpath expanduser expandvarsgetcwdAttributeErrorrcurdir)dirlistenvnamedirnames r_candidate_tempdir_listr_s&G+**W% GNN7++  xx4,,-DE,,-AB#Y'D E 9:#szz|$ N G $#szz" N#s-#C.DDc~ t}t}|D]}|tjk7rtjj |}t dD]}t|}tjj||} tj|td} tj|dtj| tj||ccSt+t,j.d|z#tj|wxYw#tj|wxYw#t$rYt$r^tj dk(rFtjj#|r'tj$|tj&rYSYt($rYwxYw)NdsblatrQz)No usable temporary directory found in %s)r2r_rr[rVabspathrangenextrEopen_bin_openflagswritecloseunlinkFileExistsErrorPermissionErrorrTisdiraccessW_OKrFileNotFoundError_errnoENOENT)namerr\r.seqrTfilenamefds r_get_default_tempdirrwsN> !E%'G #** ((""3'C:C;Dxx}}S$/H XXh>)& "g. " JJx(  8 FMMG#$ %% " JJx(" " HH$)<JJsCHH-  sID?$D :D%D? D""D%%D<<D?? F< AF</F<;F<c t?tj t tatj tStS#tj wxYwr))_name_sequence _once_lockacquirer2releaser>r'r_get_candidate_namesr}sSA !%!4!6    >    A A#c tjj|}t}|turt tj |}ttD]f}t|}tjj|||z|z}tjd| tj||d} | |fcStt(j*d#t$rYt$rZtj dk(rEtjj#|r&tj$|tj&rYwxYw)Nztempfile.mkstemprbrQz#No usable temporary file name found)rrVrcr}r mapr+rdr rerE_sysauditrfrkrlrTrmrnrorqEEXIST) r.presufflagsr/namesrtrTfilervs r_mkstemp_innerrs H ((  3 C "EeCLL%(W~E{xx}}S#*s"23 %t, $u-B4x!$ &--? AA   D SXX^^C%8 3) s'C E *AE  E c|tjvr ||g|ddiytjdk(stjj |s ||g|yy)Nfollow_symlinksFrQ)rsupports_follow_symlinksrTrVislink)funcrVr#s r_dont_follow_symlinksrsO s+++ T0D0%0 T !6 TD"7r'c tj}t||dttj|dy#t$rY'wxYw)Nr)rchflagsrrZchmod)rVrs r _resetpermsrsB0++ gtQ/#))T51    s; AAc6 tjtSr))rfsdecoder*r>r'rr r #sA << !!r'c6 tjtSr))rr+r*r>r'rr r 's@ << !!r'c t?tj t tatj tStS#tj wxYwr))r rzr{rwr|r>r'r _gettempdirr-sM0 !.0    N7N    r~c> tjtSr))rrrr>r'rr r 9s* << &&r'c> tjtSr))rr+rr>r'rrr=s, << &&r'cd t|||\}}}}|rt}nt}t|||||Sr))r0_text_openflagsrgr)r-r,r.textr/rs rrrAs@8(8'L$FFC  #vvuk BBr'c t|||\}}}}t}|turttj |}t tD]}t|}tjj|||z|z}tjd| t j|dtjj)|cStt*j,d#t$rYt$r[tj dk(rFtjj#|r't j$|tj&rY wxYw)Nztempfile.mkdtemprrQz(No usable temporary directory name found)r0r}r rrr+rdr rerVrErrmkdirrkrlrTrmrnrorcrqr)r-r,r.r/rrtrTrs rrrhs (8'L$FFC "EeCLL%(W~E{xx}}S&4-&"89 %t,  IIdE "xx%%!$ &--D FF   D SXX^^C%8 3) sC,, E7AEErBc  | t}t}ttD]B}t |}t j j|||z|z}t|r@|cSttjd)Nz"No usable temporary filename found) r r}rdr rerrVrErrkrqr)r-r,r.rrtrTrs rrrsw " {l "EW~E{xx}}S&4-&"89t}K  &--> @@r'cdeZdZ dZdZddZejdk(ejfdZ dZ dZ y) _TemporaryFileCloserFc<||_||_||_||_yr))rrTdeletedelete_on_closer:rrTrrs r__init__z_TemporaryFileCloser.__init__s   .r'rQc|jsed|_ |js!d|_|jj|jr#|r |j s ||j yyyy#t$rYywxYw#|jr2|r |j s# ||j w#t$rYwwxYwwwxYwNT)cleanup_called close_calledrrirrrTrp)r:windowsrjs rcleanupz_TemporaryFileCloser.cleanups"""&D  (((,D%IIOO%;;D4H4Htyy)5I;#-;;D4H4Htyy),5I;sA-BA33 A?>A?CB10C1 B=:C<B==Cc|jsMd|_ |jj|jr|jr|j yyyy#|jr|jr|j wwwxYwr)rrrirrrr?s rriz_TemporaryFileCloser.closesm  $D  # !;;4#7#7LLN$8; ! ;;4#7#7LLN$8;s A,Bc$|jyr))rr?s r__del__z_TemporaryFileCloser.__del__s  r'NTT) rIrJrKrrrrrTrjrrirr>r'rrrs;NL/ #xx4/ #r'rc4eZdZ ddZdZdZdZdZdZy) _TemporaryFileWrappercF||_||_t|||||_yr))rrTr_closerrs rrz_TemporaryFileWrapper.__init__s%  +D$,;= r'c|jd}t||}t|dr2|tjfd}|j |_|}t |ts t||||S)Nr__call__c|i|Sr)r>)r#kwargsrs r func_wrapperz7_TemporaryFileWrapper.__getattr__..func_wrappersT,V,,r') __dict__r7hasattr _functoolswrapsrrintsetattr)r:rTrarrs @r __getattr__z!_TemporaryFileWrapper.__getattr__sy}}V$ D$  1j !D   d # -$ -$(<r'rrrs%= *  r'rT)errorsrc    t\t tjdk(r|r| r tjz d|vrt j |}d fd} t j|||||| } t| d| } t| d| } | _t| || S#| jxYw#,tjdk(r|r| stjxYw)NrQbc,t\}|Sr))r)r#rvr.rrTr/r,r-s ropenerz"NamedTemporaryFile..openerAs!#vvukJD r' bufferingnewlineencodingrrbufferraw) r0rgrrT O_TEMPORARY_io text_encodingrfr7rrirj)moderrrr-r,r.rrrrrrrrTr/s ``` @@@rrrs.(8'L$FFC E xx4F   $$$X. DxxTY '(6%' $$/C#uc*CCH(tV_M M  JJL    HH O JJt  s0C .B<<CC1Dposixcygwin O_TMPFILErc  d|vrtj|}t\ t trId  fd} tj ||||||} t | d| } t | d| } | _| Sd  fd}tj ||||||} t | d| } t | d| } | _| S#t$rdaYXt$rYbwxYw)Nrctjztjz}tj|dS)Nrb)rrO_CREATrf)r#flags2r.rvrs rrzTemporaryFile..opener|s3#--/CKK<?XXc651 r'rrrFct\} tj|S#t$r}tjd}~wwxYwr))rrrj BaseExceptionri) r#rTer.rvrr/r,r-s rrzTemporaryFile..openersQ%c665+NHB  4 I!  "  s, AA  A) rrr0rg_O_TMPFILE_WORKSrfr7rTIsADirectoryErrorr)rrrrr-r,r.rrrrrvrr/s ``` @@@rrrbs  d?((2H+;FFC+P([ B   xxTY(/('-f>dHd3c5#. &  xxTY '(6%'dHd+c5#& E% ) $)   s >C C+ C+*C+cBeZdZ dZ d$dddZeejZdZ dZ dZ dZ d Z d Zd Zed Zed ZedZdZdZdZedZedZedZdZdZdZdZdZdZdZ dZ!dZ"dZ#d%dZ$d Z%d!Z&d"Z'd#Z(y)&rFNrc  d|vrtj|_nEtj|}tjtj|| ||_||_d|_|||||||| d|_y)Nr)rrrF)rrr-r,rrr.r)rBytesIO_filer TextIOWrapper _max_size_rolled_TemporaryFileArgs) r:max_sizerrrrr-r,r.rs rrzSpooledTemporaryFile.__init__sy $;DJ((2H**3;;=%-f$+-DJ" +/i-3v/7G*-#Ar'c|jry|j}|r%|j|kDr|jyyyr))rrtellrollover)r:rrs r_checkzSpooledTemporaryFile._checks4 <<>>  h. MMO/8r'c|jry|j}tdi|jx}|_|`|j }t |dr8|j j|jjn|j|j|j|dd|_y)NrrTr>) rrrrrrrrhdetachgetvalueseek)r:rnewfileposs rrzSpooledTemporaryFile.rollovers <<zz,Gt/F/FGG$*  #iik 7H % NN !7!7!9 : MM$--/ * S! r'cH|jjr td|S)Nz%Cannot enter context with closed file)rclosed ValueErrorr?s rrzSpooledTemporaryFile.__enter__s ::  DE E r'c8|jjyr)rrir:rrrs rrzSpooledTemporaryFile.__exit__ r'c6|jjSr))rr@r?s rr@zSpooledTemporaryFile.__iter__zz""$$r'c|js=tjdj|td||j yy)NzUnclosed file {!r}) stacklevelsource)r _warningswarnformatResourceWarningrir?s rrzSpooledTemporaryFile.__del__s<{{ NN$++D1   JJLr'c8|jjyr)rr?s rrizSpooledTemporaryFile.closerr'c.|jjSr))rrr?s rrzSpooledTemporaryFile.closedzz   r'c.|jjSr))rrr?s rrzSpooledTemporaryFile.encodingzz"""r'c.|jjSr))rrr?s rrzSpooledTemporaryFile.errorsrr'cV|j|jjSr))rrfilenor?s rrzSpooledTemporaryFile.filenos zz  ""r'c8|jjyr))rflushr?s rrzSpooledTemporaryFile.flush rr'c6|jjSr))risattyr?s rrzSpooledTemporaryFile.isattyzz  ""r'cl |jjS#t$r|jdcYSwxYw)Nr)rrrZrr?s rrzSpooledTemporaryFile.modes5 3::?? " 3**62 2 3s 33cN |jjS#t$rYywxYwr))rrTrZr?s rrTzSpooledTemporaryFile.names' ::?? "  rc.|jjSr))rnewlinesr?s rrzSpooledTemporaryFile.newlinesrr'c6|jjSr))rreadabler?s rr!zSpooledTemporaryFile.readable#rr'c4|jj|Sr))rreadr:r#s rr#zSpooledTemporaryFile.read&tzz%%r'c4|jj|Sr))rread1r$s rr'zSpooledTemporaryFile.read1)stzz&&r'c8|jj|Sr))rreadintor:rs rr)zSpooledTemporaryFile.readinto,szz""1%%r'c8|jj|Sr))r readinto1r*s rr,zSpooledTemporaryFile.readinto1/szz##A&&r'c4|jj|Sr))rreadliner$s rr.zSpooledTemporaryFile.readline2s"tzz""D))r'c4|jj|Sr))r readlinesr$s rr0zSpooledTemporaryFile.readlines5s#tzz##T**r'c6|jjSr))rseekabler?s rr2zSpooledTemporaryFile.seekable8rr'c4|jj|Sr))rrr$s rrzSpooledTemporaryFile.seek;r%r'c6|jjSr))rrr?s rrzSpooledTemporaryFile.tell>szz  r'c||jjS||jkDr|j|jj|Sr))rtruncaterr)r:sizes rr6zSpooledTemporaryFile.truncateAsD <::&&( (dnn$ ::&&t, ,r'c6|jjSr))rwritabler?s rr9zSpooledTemporaryFile.writableIrr'cb|j}|j|}|j||Sr))rrhr)r:srrvs rrhzSpooledTemporaryFile.writeLs)zz ZZ] D r'cb|j}|j|}|j||Sr))r writelinesr)r:iterablerr<s rr>zSpooledTemporaryFile.writelinesRs*zz __X & D r'c6|jjSr))rrr?s rrzSpooledTemporaryFile.detachXrr')rw+bNNNNNr)))rIrJrKrr classmethod_types GenericAlias__class_getitem__rrrrr@rrirLrrrrrrrrTrr!r#r'r)r,r.r0r2rrr6r9rhr>rr>r'rrrs.G9;(,/3A?CA"$F$7$78 * %!!##!!##33  ##%&'&'*+%&!-%  #r'rceZdZ d dddZed dZed dZdZdZd Z d Z ee jZ y)rNT)rct||||_||_||_t j ||j |jdj||j|j|_y)NzImplicitly cleaning up {!r}) warn_message ignore_errorsr) rrT_ignore_cleanup_errors_delete_weakreffinalize_cleanupr  _finalizer)r:r-r,r.ignore_cleanup_errorsrs rrzTemporaryDirectory.__init__ps`FFC0 &;# "++ $--6==dC55dllLr'cJfd}tj|y)Nc2t|tr]r |k(rry |k7r(ttjj |t| tj |yyyt|trysy#t$rj|Y4t$r]tjj|rtjj|rrYyj||k(YwxYw#t$rYywxYw)NrJ)rJrepeated) rrlrrrVr^rjr_rmtreerm isjunctionrp)rrVrclsrJrTrUs ronexcz)TemporaryDirectory._rmtree..onexc|s#/ $t|#CHH$4$4T$:;%= 4(=G"C!23$%+-G D F* = #xx~~d3sxx7J7J47P, &! D .2dl$= =)sH8D BD D "AD*D ,DD DD DD)rY)_shutilrmtree)rXrTrJrUrYs```` rrVzTemporaryDirectory._rmtreezs$ L t5)r'cd|r.|j||tj|tyyNrT)rVr r r)rXrTrIrJrs rrOzTemporaryDirectory._cleanups(  KKMK : NN< 9 r'cbdj|jj|jS)Nz <{} {!r}>)r  __class__rIrTr?s r__repr__zTemporaryDirectory.__repr__s#!!$.."9"9499EEr'c|jSr))rTr?s rrzTemporaryDirectory.__enter__s yyr'c>|jr|jyyr))rLrrs rrzTemporaryDirectory.__exit__s << LLN r'c|jjs)tjj |j r(|j |j |jyyr])rPrrrVexistsrTrVrKr?s rrzTemporaryDirectory.cleanupsE ?? ! ! #sxxtyy'A LL$2M2ML N(Br'NNNF)FF)FT)rIrJrKrrCrVrOr`rrrrDrErFr>r'rrr\sp&6:',L8<L'*'*R:: FO$F$7$78r'rre)NNN)rArBNNNNNT)rArBNNNNN)B__all__ functoolsrwarningsr iorosrshutilrZerrnorqrandomrr8sysrtypesrDweakrefrM_thread allocate_lock_allocate_lockO_RDWRrO_EXCLrrrrgrr r*rzrr&r0r2r_rwryr}rrrr r r rr rrrrrrrrTplatformrrIOBaserrr>r'rrxs2 $&&**s{{*SZZ7 3 s~~%O  3 cll"N 3 kkGG   :,$??06*%X A:2""  ''$CN&FPX4@@((V<<|;?9=(,<8<'+<|88w$--83'M sK09=8<I*.IVl#3::l#^\9\9r'