%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/tempfile.cpython-38.pyc

U

nak
@sdZddddddddd	d
ddd
g
ZddlZddlZddlZddlZ	ddl
ZddlZ
ddlmZddlZddlZddlZejZe	je	jBe	jBZee	dree	jOZeZee	dree	jOZee	dre	j Z ndZ dZ!eZ"ddZ#ddZ$ddZ%GdddZ&ddZ'dd Z(da)d!d"Z*d#d$Z+d%d	Z,d&dZ-da.d'dZ/d(d
Z0d=d*dZ1d>d+dZ2d,e!dfd-dZ3Gd.d/d/Z4Gd0d1d1Z5d?dd5d6dZ6e	j7d7ksej8d8kre6Z9nee	d9a:d@dd5d:dZ9Gd;ddZ;Gd<dde<Z=dS)AaTemporary 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
TemporaryFileSpooledTemporaryFileTemporaryDirectorymkstempmkdtempmktempTMP_MAX
gettempprefixtempdir
gettempdirgettempprefixbgettempdirbN)Random
O_NOFOLLOWO_BINARYi'tmpcCs.zt|Wntk
r$YdSXdSdS)NFT)_oslstatOSError)fnr$/usr/local/lib/python3.8/tempfile.py_existsKs
rcGs\d}|D]B}|dkrqt|tr6|tkr0tdt}q|tkrFtdt}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.)
isinstancebytesstr	TypeError)argsreturn_typeargrrr_infer_return_typeTs
r!cCsdt|||}|dkr|}|dkr:|tkr0t}n
tt}|dkrX|tkrRt}nt}||||fS)z9Common parameter processing for most APIs in this module.N)r!rtemplaterfsencoderr
)prefixsuffixdiroutput_typerrr_sanitize_paramsis
r(c@s0eZdZdZdZeddZddZddZd	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.%abcdefghijklmnopqrstuvwxyz0123456789_cCs,t}|t|ddkr&t|_||_|jS)N_rng_pid)rgetpidgetattr_Random_rngr+)selfcur_pidrrrrngs
z_RandomNameSequence.rngcCs|SNrr0rrr__iter__sz_RandomNameSequence.__iter__cs0|j|jjfddtdD}d|S)Ncsg|]}qSrr).0dummycchooserr
<listcomp>sz0_RandomNameSequence.__next__.<locals>.<listcomp>)
charactersr2choicerangejoin)r0lettersrr8r__next__sz_RandomNameSequence.__next__N)	__name__
__module____qualname____doc__r>propertyr2r5rCrrrrr){s
r)c	Csg}dD]}t|}|r||qtjdkrX|tjdtjdddddgn|d	d
dgz|tWn$t	t
fk
r|tjYnX|S)z[Generate a list of candidate temporary directories which
    _get_default_tempdir will try.)TMPDIRTEMPTMPntz~\AppData\Local\Tempz%SYSTEMROOT%\Tempzc:\tempzc:\tmpz\tempz\tmpz/tmpz/var/tmpz/usr/tmp)rgetenvappendnameextendpath
expanduser
expandvarsgetcwdAttributeErrorrcurdir)dirlistenvnamedirnamerrr_candidate_tempdir_lists&


rZcCsFt}t}|D]}|tjkr,tj|}tdD]}t|}tj||}zft	|t
d}z<z*t
j	|ddd}|dW5QRXW5t|XW5t|X|WStk
rYq4tk
rtjdkrtj|rt|tjrYq4YqYq4tk
r,YqYq4Xq4qttjd|d	S)
aqCalculate the default directory to use for temporary files.
    This routine should be called exactly once.

    We determine whether or not a candidate temp dir is usable by
    trying to create and write to a file in that directory.  If this
    is successful, the test file is deleted.  To prevent denial of
    service, the name of the test file must be randomized.dwbF)closefdsblatrLz)No usable temporary directory found in %sN)r)rZrrVrQabspathr@nextrAopen_bin_openflagsunlinkclose_iowriteFileExistsErrorPermissionErrorrOisdiraccessW_OKrFileNotFoundError_errnoENOENT)namerrWr&seqrOfilenamefdfprrr_get_default_tempdirs@	


rtcCs2tdkr.tztdkr taW5tXtS)z7Common setup sequence for all user-callable interfaces.N)_name_sequence
_once_lockacquirereleaser)rrrr_get_candidate_namess

ryc
	Cst}|tkrttj|}ttD]}t|}tj	||||}t
d|zt||d}	WnVt
k
rzYq"Yn@tk
rtjdkrtj|rt|tjrYq"nYnX|	tj|fSt
tjddS)z>Code common to mkstemp, TemporaryFile, and NamedTemporaryFile.ztempfile.mkstempr\rLz#No usable temporary file name foundN)ryrmaprr#r@rr`rQrA_sysauditrargrhrOrirjrkr_rmEEXIST)
r&presufflagsr'namesrprOfilerrrrr_mkstemp_inners*rcCstS)z-The default prefix for temporary directories.)r"rrrrr	
scCsttS)z6The default prefix for temporary directories as bytes.)rr#r	rrrrrscCs2tdkr.tztdkr taW5tXtS)zAccessor for tempfile.tempdir.N)r
rvrwrxrtrrrrrs

cCsttS)z)A bytes version of tempfile.gettempdir().)rr#rrrrrr
#sFcCs2t|||\}}}}|rt}nt}t|||||S)aUser-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_openflagsrbr)r%r$r&textr'rrrrr's
c	Cst|||\}}}}t}|tkr.ttj|}ttD]}t|}tj	
||||}td|zt
|dWnVtk
rYq6Yn@tk
rtjdkrtj	|rt|tjrYq6nYnX|SttjddS)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.mkdtemprLz(No usable temporary directory name foundN)r(ryrrzrr#r@rr`rQrAr{r|mkdirrgrhrOrirjrkrmr})r%r$r&r'rrprOrrrrrNs,
r=cCs`|dkrt}t}ttD]2}t|}tj||||}t|s|Sqt	t
jddS)aUser-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)rryr@rr`rrQrArrgrmr})r%r$r&rrprOrrrrrvs
c@sLeZdZdZdZdZd
ddZejdkr@ej	fdd	Z
d
dZndd	Z
dS)_TemporaryFileCloserzA separate object allowing proper closing of a temporary file's
    underlying file object, without adding a __del__ method to the
    temporary file.NFTcCs||_||_||_dSr3)rrOdeleter0rrOrrrr__init__sz_TemporaryFileCloser.__init__rLcCs<|js8|jdk	r8d|_z|jW5|jr6||jXdSNT)close_calledrrrOrd)r0rcrrrrdsz_TemporaryFileCloser.closecCs|dSr3)rdr4rrr__del__sz_TemporaryFileCloser.__del__cCs|jsd|_|jdSr)rrrdr4rrrrds)T)rDrErFrGrrrrrOrcrdrrrrrrs



rc@sBeZdZdZdddZddZddZd	d
ZddZd
dZ	dS)_TemporaryFileWrapperzTemporary 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||||_dSr3)rrOrr_closerrrrrrsz_TemporaryFileWrapper.__init__cs^|jd}t||}t|drD|tfdd}|j|_|}t|tsZt||||S)Nr__call__cs
||Sr3r)rkwargsfuncrrfunc_wrappersz7_TemporaryFileWrapper.__getattr__.<locals>.func_wrapper)	__dict__r-hasattr
_functoolswrapsrrintsetattr)r0rOrarrrr__getattr__s



z!_TemporaryFileWrapper.__getattr__cCs|j|Sr3)r	__enter__r4rrrrs
z_TemporaryFileWrapper.__enter__cCs|j|||}||Sr3)r__exit__rd)r0excvaluetbresultrrrrsz_TemporaryFileWrapper.__exit__cCs|jdS)zA
        Close the temporary file, possibly deleting it.
        N)rrdr4rrrrdsz_TemporaryFileWrapper.closeccs|jD]
}|VqdSr3)r)r0linerrrr5s
z_TemporaryFileWrapper.__iter__N)T)
rDrErFrGrrrrrdr5rrrrrs
rw+bTerrorscCst|||\}}}}	t}
tjdkr0|r0|
tjO}
t||||
|	\}}z$tj||||||d}
t|
||WSt	k
rt
|t|YnXdS)aCreate 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.
    rL	bufferingnewlineencodingrN)r(rbrrOO_TEMPORARYrrerar
BaseExceptionrcrd)moderrrr%r$r&rrr'rrrrOrrrrrs 



posixcygwin	O_TMPFILEc
Cst|||\}}}}t}	trz$|	tjBtj@}
t||
d}Wn*tk
rXdaYnFtk
rjYn4Xzt	j||||||dWSt
|YnXt||||	|\}}z"t|t	j||||||dWSt
|YnXdS)aCreate 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.
        r\FrN)
r(rb_O_TMPFILE_WORKSrrO_CREATraIsADirectoryErrorrrerdrrc)
rrrrr%r$r&rr'rflags2rrrOrrrr2s<




c@seZdZdZdZd:dddd	Zd
dZdd
ZddZddZ	ddZ
ddZeddZ
eddZeddZddZddZd d!Zed"d#Zed$d%Zed&d'Zd(d)Zd*d+Zd,d-Zd.d/Zed0d1Zd2d3Zd;d4d5Zd6d7Zd8d9ZdS)<rzTemporary file wrapper, specialized to switch from BytesIO
    or StringIO to a real file when it exceeds a certain size or
    when a fileno is needed.
    FrrrNrc	
	CsTd|krt|_ntjt||	|d|_||_d|_||||||||	d|_dS)Nb)rrrF)rrr%r$rrr&r)reBytesIO_file
TextIOWrapper	_max_size_rolled_TemporaryFileArgs)
r0max_sizerrrrr%r$r&rrrrrus"
zSpooledTemporaryFile.__init__cCs,|jr
dS|j}|r(||kr(|dSr3)rrtellrollover)r0rrrrr_checks
zSpooledTemporaryFile._checkcCsr|jr
dS|j}tf|j}|_|`|}t|drN|j|	n||	|
|dd|_dS)NbufferrT)rrrrrrrrfdetachgetvalueseek)r0rnewfileposrrrrs
zSpooledTemporaryFile.rollovercCs|jjrtd|S)Nz%Cannot enter context with closed file)rclosed
ValueErrorr4rrrrszSpooledTemporaryFile.__enter__cCs|jdSr3rrdr0rrrrrrrszSpooledTemporaryFile.__exit__cCs
|jSr3)rr5r4rrrr5szSpooledTemporaryFile.__iter__cCs|jdSr3rr4rrrrdszSpooledTemporaryFile.closecCs|jjSr3)rrr4rrrrszSpooledTemporaryFile.closedcCs|jjSr3)rrr4rrrrszSpooledTemporaryFile.encodingcCs|jjSr3)rrr4rrrrszSpooledTemporaryFile.errorscCs||jSr3)rrfilenor4rrrrszSpooledTemporaryFile.filenocCs|jdSr3)rflushr4rrrrszSpooledTemporaryFile.flushcCs
|jSr3)risattyr4rrrrszSpooledTemporaryFile.isattycCs.z
|jjWStk
r(|jdYSXdS)Nr)rrrUrr4rrrrs
zSpooledTemporaryFile.modecCs&z
|jjWStk
r YdSXdSr3)rrOrUr4rrrrOs
zSpooledTemporaryFile.namecCs|jjSr3)rnewlinesr4rrrrszSpooledTemporaryFile.newlinescGs|jj|Sr3)rreadr0rrrrrszSpooledTemporaryFile.readcGs|jj|Sr3)rreadlinerrrrrszSpooledTemporaryFile.readlinecGs|jj|Sr3)r	readlinesrrrrrszSpooledTemporaryFile.readlinescGs|jj|Sr3)rrrrrrrszSpooledTemporaryFile.seekcCs|jjSr3)r	softspacer4rrrrszSpooledTemporaryFile.softspacecCs
|jSr3)rrr4rrrrszSpooledTemporaryFile.tellcCs6|dkr|jn||jkr&||j|dSr3)rtruncaterr)r0sizerrrrs

zSpooledTemporaryFile.truncatecCs|j}||}|||Sr3)rrfr)r0srrvrrrrfs

zSpooledTemporaryFile.writecCs|j}||}|||Sr3)r
writelinesr)r0iterablerrrrrrs

zSpooledTemporaryFile.writelines)rrrNNNNN)N)rDrErFrGrrrrrrr5rdrHrrrrrrrrOrrrrrrrrrfrrrrrrnsT







c@sReZdZdZdddZeddZeddZd	d
ZddZ	d
dZ
ddZdS)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)rrO_weakreffinalize_cleanupformat
_finalizer)r0r%r$r&rrrrszTemporaryDirectory.__init__cs fdd}tj|ddS)Nc	st|dtrdd}zV|kr0|tj|||zt|Wn"ttfk
rh|YnXWqtk
rYqXnt|dtrndS)NrcSs6zt|dWntk
r$YnXt|ddS)Nrr)rchflagsrUchmod)rQrrr
resetpermss
z?TemporaryDirectory._rmtree.<locals>.onerror.<locals>.resetperms)	
issubclassrhrrQrYrcr_rmtreerl)rrQexc_inforclsrOrronerrorsz+TemporaryDirectory._rmtree.<locals>.onerror)r)_shutilrmtree)rrOrrrrrszTemporaryDirectory._rmtreecCs||t|tdSr3)r	_warningswarnResourceWarning)rrOrrrrr/s
zTemporaryDirectory._cleanupcCsd|jj|jS)Nz	<{} {!r}>)r	__class__rDrOr4rrr__repr__4szTemporaryDirectory.__repr__cCs|jSr3)rOr4rrrr7szTemporaryDirectory.__enter__cCs|dSr3)cleanuprrrrr:szTemporaryDirectory.__exit__cCs|jr||jdSr3)rrrrOr4rrrr=s
zTemporaryDirectory.cleanup)NNN)rDrErFrGrclassmethodrrrrrrrrrrrs


)NNNF)NNN)rrNNNNNT)rrNNNNN)>rG__all__	functoolsrwarningsrioreosrshutilrerrnormrandomrr.sysr{weakrefr_thread
allocate_lock_allocate_lockO_RDWRrO_EXCLrrrrbrrr"rvrr!r(r)rZrtruryrr	rr
rr
rrrrrrrOplatformrrrobjectrrrrr<module>s





	-
'
( +?'
<

Zerion Mini Shell 1.0