grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026U iÛf®lã @sdZddddddddd d d d d g ZddlZddlZddlZddlZ ddl Z ddl Z ddlmZddlZddlZddlZejZe je jBe jBZee dƒr¢ee jOZeZee dƒrºee jOZee dƒrÌe j Z ndZ dZ!eƒZ"dd„Z#dd„Z$dd„Z%Gdd„dƒZ&dd„Z'dd „Z(da)d!d"„Z*d#d$„Z+d%d&„Z,d'd(„Z-d)d „Z.d*d „Z/da0d+d „Z1d,d „Z2dAd.d„Z3dBd/d„Z4d0e!dfd1d„Z5Gd2d3„d3ƒZ6Gd4d5„d5ƒZ7dCdd9œd:d„Z8e j9d;k�sÀej:dd„Z;Gd?d„dƒZ=Gd@d„de>ƒZ?dS)Ea�Temporary files. This module provides generic, low- and high-level interfaces for creating temporary files and directories. All of the interfaces provided by this module can be used without fear of race conditions except for 'mktemp'. 'mktemp' is subject to race conditions and should not be used; it is provided for backward compatibility only. The default path names are returned as str. If you supply bytes as input, all return values will be in bytes. Ex: >>> tempfile.mkstemp() (4, '/tmp/tmptpu9nin8') >>> tempfile.mkdtemp(suffix=b'') b'/tmp/tmppbi8f0hy' This module also provides some data items to the user: TMP_MAX - maximum number of names that will be tried before giving up. tempdir - If this is set to a string before the first use of any routine from this module, it will be considered as another candidate location to store temporary files. ÚNamedTemporaryFileÚ TemporaryFileÚSpooledTemporaryFileÚTemporaryDirectoryÚmkstempÚmkdtempÚmktempÚTMP_MAXÚ gettempprefixÚtempdirÚ gettempdirÚgettempprefixbÚ gettempdirbéN)ÚRandomÚ O_NOFOLLOWÚO_BINARYi'ZtmpcCs.zt |¡Wntk r$YdSXdSdS)NFT)Ú_osÚlstatÚOSError)Úfn©rú-/opt/alt/python38/lib64/python3.8/tempfile.pyÚ_existsKs rcGs\d}|D]B}|dkrqt|tƒr6|tkr0tdƒ‚t}q|tkrFtdƒ‚t}q|dkrXtS|S)zBLook at the type of all args and divine their implied return type.Nz1Can't mix bytes and non-bytes in path components.)Ú isinstanceÚbytesÚstrÚ TypeError)ÚargsZ return_typeÚargrrrÚ_infer_return_typeTs rcCsdt|||ƒ}|dkr|ƒ}|dkr:|tkr0t}n t t¡}|dkrX|tkrRtƒ}ntƒ}||||fS)z9Common parameter processing for most APIs in this module.N)rrÚtemplaterÚfsencoder r )ÚprefixÚsuffixÚdirÚ output_typerrrÚ_sanitize_paramsis  r&c@s0eZdZdZdZedd„ƒZdd„Zdd„Zd S) Ú_RandomNameSequencea,An instance of _RandomNameSequence generates an endless sequence of unpredictable strings which can safely be incorporated into file names. Each string is eight characters long. Multiple threads can safely use the same instance at the same time. _RandomNameSequence is an iterator.Z%abcdefghijklmnopqrstuvwxyz0123456789_cCs,t ¡}|t|ddƒkr&tƒ|_||_|jS)NÚ_rng_pid)rÚgetpidÚgetattrÚ_RandomZ_rngr()ÚselfZcur_pidrrrÚrng…s z_RandomNameSequence.rngcCs|S©Nr©r,rrrÚ__iter__�sz_RandomNameSequence.__iter__cs0|j‰|jj‰‡‡fdd„tdƒDƒ}d |¡S)Ncsg|] }ˆˆƒ‘qSrr)Ú.0Zdummy©ÚcZchooserrÚ “sz0_RandomNameSequence.__next__..éÚ)Ú charactersr-ZchoiceÚrangeÚjoin)r,Zlettersrr2rÚ__next__�sz_RandomNameSequence.__next__N) Ú__name__Ú __module__Ú __qualname__Ú__doc__r7Úpropertyr-r0r:rrrrr'{s  r'c Cs¤g}dD]}t |¡}|r| |¡qtjdkrX| tj d¡tj d¡ddddg¡n| d d d g¡z| t ¡¡Wn$t t fk rž| tj ¡YnX|S) z[Generate a list of candidate temporary directories which _get_default_tempdir will try.)ZTMPDIRZTEMPZTMPÚntz~\AppData\Local\Tempz%SYSTEMROOT%\Tempzc:\tempzc:\tmpz\tempz\tmpz/tmpz/var/tmpz/usr/tmp) rÚgetenvÚappendÚnameÚextendÚpathÚ expanduserÚ expandvarsÚgetcwdÚAttributeErrorrÚcurdir)ÚdirlistZenvnameÚdirnamerrrÚ_candidate_tempdir_list–s&    þrMc CsFtƒ}tƒ}|D�]}|tjkr,tj |¡}tdƒD�]ø}t|ƒ}tj ||¡}zft  |t d¡}zCode common to mkstemp, TemporaryFile, and NamedTemporaryFile.ztempfile.mkstemprOr@z#No usable temporary file name foundN)rjrÚmaprr!r8rrSrEr9Ú_sysÚauditrTrZr[rCr\r]r^rRr`ÚEEXIST) r$ZpreZsufÚflagsr%ÚnamesrarCÚfilercrrrÚ_mkstemp_innerîs*    ÿÿrrcGsH|tjkr ||f|žddiŽn$tjdks6tj |¡sD||f|žŽdS)NÚfollow_symlinksFr@)rÚsupports_follow_symlinksrCrEÚislink)ÚfuncrErrrrÚ_dont_follow_symlinks s rwcCs>z tj}Wntk rYnXt||dƒttj|dƒdS)NréÀ)rÚchflagsrIrwÚchmod)rEryrrrÚ _resetpermss   r{cCstS)z-The default prefix for temporary directories.)r rrrrr scCs t tƒ¡S)z6The default prefix for temporary directories as bytes.)rr!r rrrrr !scCs2tdkr.t ¡ztdkr tƒaW5t ¡XtS)zAccessor for tempfile.tempdir.N)r rgrhrirerrrrr 's  cCs t tƒ¡S)z)A bytes version of tempfile.gettempdir().)rr!r rrrrr 3sFcCs2t|||ƒ\}}}}|rt}nt}t|||||ƒS)aŒUser-callable function to create and return a unique temporary file. The return value is a pair (fd, name) where fd is the file descriptor returned by os.open, and name is the filename. If 'suffix' is not None, the file name will end with that suffix, otherwise there will be no suffix. If 'prefix' is not None, the file name will begin with that prefix, otherwise a default prefix is used. If 'dir' is not None, the file will be created in that directory, otherwise a default directory is used. If 'text' is specified and true, the file is opened in text mode. Else (the default) the file is opened in binary mode. If any of 'suffix', 'prefix' and 'dir' are not None, they must be the same type. If they are bytes, the returned name will be bytes; str otherwise. The file is readable and writable only by the creating user ID. If the operating system uses permission bits to indicate whether a file is executable, the file is executable by no one. The file descriptor is not inherited by children of this process. Caller is responsible for deleting the file when done with it. )r&Ú_text_openflagsrUrr)r#r"r$Útextr%rorrrr7s c Csät|||ƒ\}}}}tƒ}|tkr.ttj|ƒ}ttƒD]œ}t|ƒ}tj   ||||¡}t   d|¡zt  |d¡WnVtk rŒYq6Yn@tk rÊtjdkrÄtj  |¡rÄt |tj¡rÄYq6n‚YnX|Sttjdƒ‚dS)aUser-callable function to create and return a unique temporary directory. The return value is the pathname of the directory. Arguments are as for mkstemp, except that the 'text' argument is not accepted. The directory is readable, writable, and searchable only by the creating user. Caller is responsible for deleting the directory when done with it. ztempfile.mkdtemprxr@z(No usable temporary directory name foundN)r&rjrrkrr!r8rrSrEr9rlrmÚmkdirrZr[rCr\r]r^r`rn)r#r"r$r%rprarCrqrrrr^s,     ÿÿr6cCs`|dkrtƒ}tƒ}ttƒD]2}t|ƒ}tj ||||¡}t|ƒs|Sqt t j dƒ‚dS)aêUser-callable function to return a unique temporary file name. The file is not created. Arguments are similar to mkstemp, except that the 'text' argument is not accepted, and suffix=None, prefix=None and bytes file names are not supported. THIS FUNCTION IS UNSAFE AND SHOULD NOT BE USED. The file name may refer to a file that did not exist at some point, but by the time you get around to creating it, someone else may have beaten you to the punch. Nz"No usable temporary filename found) r rjr8rrSrrEr9rrZr`rn)r#r"r$rprarCrqrrrr†s  ÿc@sLeZdZdZdZdZd dd„Zejdkr@ej fdd „Z d d „Z nd d „Z dS)Ú_TemporaryFileCloserz–A separate object allowing proper closing of a temporary file's underlying file object, without adding a __del__ method to the temporary file.NFTcCs||_||_||_dSr.)rqrCÚdelete©r,rqrCr€rrrÚ__init__®sz_TemporaryFileCloser.__init__r@cCs<|js8|jdk r8d|_z|j ¡W5|jr6||jƒXdS©NT)Ú close_calledrqr€rCrW)r,rVrrrrW½s z_TemporaryFileCloser.closecCs | ¡dSr.)rWr/rrrÚ__del__Çsz_TemporaryFileCloser.__del__cCs|jsd|_|j ¡dSrƒ)r„rqrWr/rrrrWËs)T) r;r<r=r>rqr„r‚rrCrVrWr…rrrrr¦s   rc@sBeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)Ú_TemporaryFileWrapperzÄTemporary file wrapper This class provides a wrapper around files opened for temporary use. In particular, it seeks to automatically remove the file when it is no longer needed. TcCs$||_||_||_t|||ƒ|_dSr.)rqrCr€rÚ_closerr�rrrr‚Ùsz_TemporaryFileWrapper.__init__cs^|jd}t||ƒ}t|dƒrD|‰t ˆ¡‡fdd„ƒ}|j|_|}t|tƒsZt|||ƒ|S)NrqÚ__call__cs ˆ||ŽSr.r)rÚkwargs©rvrrÚ func_wrapperçsz7_TemporaryFileWrapper.__getattr__..func_wrapper) Ú__dict__r*ÚhasattrÚ _functoolsÚwrapsr‡rÚintÚsetattr)r,rCrqÚar‹rrŠrÚ __getattr__ßs     z!_TemporaryFileWrapper.__getattr__cCs|j ¡|Sr.)rqÚ __enter__r/rrrr”ôs z_TemporaryFileWrapper.__enter__cCs|j |||¡}| ¡|Sr.)rqÚ__exit__rW)r,ÚexcÚvalueÚtbÚresultrrrr•úsz_TemporaryFileWrapper.__exit__cCs|j ¡dS)zA Close the temporary file, possibly deleting it. N)r‡rWr/rrrrWÿsz_TemporaryFileWrapper.closeccs|jD] }|VqdSr.)rq)r,Úlinerrrr0s z_TemporaryFileWrapper.__iter__N)T) r;r<r=r>r‚r“r”r•rWr0rrrrr†Ñs r†úw+béÿÿÿÿT©ÚerrorscCs˜t|||ƒ\}}}} t} tjdkr0|r0| tjO} t|||| | ƒ\} } z$tj| |||||d�} t| | |ƒWSt k r’t  | ¡t  | ¡‚YnXdS)aÿCreate and return a temporary file. Arguments: 'prefix', 'suffix', 'dir' -- as for mkstemp. 'mode' -- the mode argument to io.open (default "w+b"). 'buffering' -- the buffer size argument to io.open (default -1). 'encoding' -- the encoding argument to io.open (default None) 'newline' -- the newline argument to io.open (default None) 'delete' -- whether the file is deleted on close (default True). 'errors' -- the errors argument to io.open (default None) The file is created as mkstemp() would do it. Returns an object with a file-like interface; the name of the file is accessible as its 'name' attribute. The file will be automatically deleted when it is closed unless the 'delete' argument is set to False. r@©Ú bufferingÚnewlineÚencodingržN) r&rUrrCZ O_TEMPORARYrrrXrTr†Ú BaseExceptionrVrW)Úmoder r¢r¡r#r"r$r€ržr%rorcrCrqrrrrs   ÿ  ÚposixÚcygwinÚ O_TMPFILEc Csòt|||ƒ\}}}}t} tržz$| tjBtj@} t || d¡} Wn*tk rXdaYnFtk rjYn4Xzt j| |||||d�WSt  | ¡‚YnXt |||| |ƒ\} } z"t  | ¡t j| |||||d�WSt  | ¡‚YnXdS)a€Create and return a temporary file. Arguments: 'prefix', 'suffix', 'dir' -- as for mkstemp. 'mode' -- the mode argument to io.open (default "w+b"). 'buffering' -- the buffer size argument to io.open (default -1). 'encoding' -- the encoding argument to io.open (default None) 'newline' -- the newline argument to io.open (default None) 'errors' -- the errors argument to io.open (default None) The file is created as mkstemp() would do it. Returns an object with a file-like interface. The file has no name, and will cease to exist when it is closed. rOFrŸN) r&rUÚ_O_TMPFILE_WORKSrr§ÚO_CREATrTÚIsADirectoryErrorrrXrWrrrV) r¤r r¢r¡r#r"r$ržr%roZflags2rcrCrrrrBs< þ   ÿ c@seZdZdZdZd:ddœdd „Zd d „Zd d „Zdd„Zdd„Z dd„Z dd„Z e dd„ƒZ e dd„ƒZe dd„ƒZdd„Zdd„Zd d!„Ze d"d#„ƒZe d$d%„ƒZe d&d'„ƒZd(d)„Zd*d+„Zd,d-„Zd.d/„Ze d0d1„ƒZd2d3„Zd;d4d5„Zd6d7„Zd8d9„ZdS)r°r‚rµr´r”r•r0rWr?r»r¢ržr¿rÀrÁr¤rCrÂrÃrÅrÆr¹rÇr³rÈrYrÌrrrrr~sTþþ         c@sReZdZdZddd„Zedd„ƒZedd„ƒZd d „Zd d „Z d d„Z dd„Z dS)ra+Create and return a temporary directory. This has the same behavior as mkdtemp but can be used as a context manager. For example: with TemporaryDirectory() as tmpdir: ... Upon exiting the context, the directory and everything contained in it are removed. NcCs0t|||ƒ|_tj||j|jd |¡d�|_dS)NzImplicitly cleaning up {!r})Ú warn_message)rrCÚ_weakrefZfinalizeÚ_cleanupÚformatÚ _finalizer)r,r#r"r$rrrr‚sþzTemporaryDirectory.__init__cs ‡‡fdd„}tjˆ|d�dS)Nc s’t|dtƒr|zV|ˆkr(ttj |¡ƒt|ƒzt |¡Wn"ttfk r`ˆ |¡YnXWqŽt k rxYqŽXnt|dt ƒrŒn‚dS)Nr) Ú issubclassr[r{rrErLrVrªÚ_rmtreer_)rvrEÚexc_info©ÚclsrCrrÚonerror#sz+TemporaryDirectory._rmtree..onerror)rØ)Ú_shutilZrmtree)r×rCrØrrÖrrÔ!szTemporaryDirectory._rmtreecCs| |¡t |t¡dSr.)rÔÚ _warningsÚwarnÚResourceWarning)r×rCrÎrrrrÐ8s zTemporaryDirectory._cleanupcCsd |jj|j¡S)Nz <{} {!r}>)rÑÚ __class__r;rCr/rrrÚ__repr__=szTemporaryDirectory.__repr__cCs|jSr.)rCr/rrrr”@szTemporaryDirectory.__enter__cCs | ¡dSr.)Úcleanupr¾rrrr•CszTemporaryDirectory.__exit__cCs|j ¡r| |j¡dSr.)rÒr·rÔrCr/rrrrßFs zTemporaryDirectory.cleanup)NNN) r;r<r=r>r‚Ú classmethodrÔrÐrÞr”r•rßrrrrrs   )NNNF)NNN)r›rœNNNNNT)r›rœNNNNN)@r>Ú__all__Ú functoolsrŽÚwarningsrÚÚiorXÚosrZshutilrÙÚerrnor`Zrandomrr+ÚsysrlÚweakrefrÏÚ_threadÚ allocate_lockZ_allocate_lockÚO_RDWRr©ÚO_EXCLr|r�rrUrrr rgrrr&r'rMrerfrjrrrwr{r r r r r rrrrr†rrCÚplatformrr¨rÚobjectrrrrrÚs ù        -   ' ( +?þþ ' þþ <