ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/tempfile.cpython-34.pyc

�
e f�W�@sdZddddddddd	d
dgZdd
lZdd
lZdd
lZdd
lZ	dd
l
Zdd
lZ
ddlmZdd
lZydd
lZWnek
r�dd
lZYnXejZe	je	jBe	jBZee	d�ree	jOZneZee	d�r&ee	jOZnee	d�rAe	j Z ndZ dZ!e�Z"ee	d�rqe	j#Z$n'ee	d�r�e	j%Z$ndd�Z$dd�Z&Gdd�d�Z'dd�Z(dd�Z)d
a*dd �Z+d!d"�Z,d#d	�Z-d
a.d$d�Z/d%e!d
d&d'd�Z0d%e!d
d(d�Z1d%e!d
d)d�Z2Gd*d+�d+�Z3Gd,d-�d-�Z4d.d7d
d
d%e!d
d0d1d�Z5e	j6d2ks�e	j7j8d3kr�e5Z9n!d.d8d
d
d%e!d
d4d�Z9Gd5d�d�Z:Gd6d�de;�Z<d
S)9a�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.

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�N)�Random�
O_NOFOLLOW�O_BINARYi'Ztmp�lstat�statcCs&tj|tj�}tj|�dS)N)�_os�open�O_RDONLY�close)�fn�fd�r�-/opt/alt/python34/lib64/python3.4/tempfile.py�_statIsrcCs/yt|�Wntk
r&dSYnXdSdS)NFT)r�OSError)rrrr�_existsMs

	rc@sFeZdZdZdZedd��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 six characters long.  Multiple
    threads can safely use the same instance at the same time.

    _RandomNameSequence is an iterator.Z%abcdefghijklmnopqrstuvwxyz0123456789_cCsCtj�}|t|dd�kr<t�|_||_n|jS)N�_rng_pid)r�getpid�getattr�_RandomZ_rngr)�selfZcur_pidrrr�rng_s
z_RandomNameSequence.rngcCs|S)Nr)r"rrr�__iter__gsz_RandomNameSequence.__iter__csD|j�|jj���fdd�td�D�}dj|�S)Ncsg|]}����qSrr)�.0Zdummy)�c�chooserr�
<listcomp>ms	z0_RandomNameSequence.__next__.<locals>.<listcomp>��)�
charactersr#Zchoice�range�join)r"Zlettersr)r&r'r�__next__js	"z_RandomNameSequence.__next__N)	�__name__�
__module__�__qualname__�__doc__r+�propertyr#r$r.rrrrrUs
rcCs�g}x3dD]+}tj|�}|r
|j|�q
q
Wtjdkrg|jddddg�n|jd	d
dg�y|jtj��Wn(ttfk
r�|jtj�YnX|S)
z[Generate a list of candidate temporary directories which
    _get_default_tempdir will try.�TMPDIR�TEMP�TMP�ntzc:\tempzc:\tmpz\tempz\tmpz/tmpz/var/tmpz/usr/tmp)r4r5r6)	r�getenv�append�name�extend�getcwd�AttributeErrorr�curdir)�dirlistZenvname�dirnamerrr�_candidate_tempdir_listps
rAcCs�t�}t�}xT|D]L}|tjkrCtjj|�}nxtd�D]}t|�}tjj||�}yutj	|t
d�}zGz2tj	|ddd��}|jd�WdQXWdtj
|�XWdtj|�X|SWqPtk
rYqPtk
rNtjdkrItjj|�rItj|tj�rIwPnPYqPtk
r`PYqPXqPWqWttjd	|��dS)
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.�di��wb�closefdFsblatNr7z)No usable temporary directory found in %s)rrArr>�path�abspathr,�nextr-r�_bin_openflags�_io�writer�unlink�FileExistsError�PermissionErrorr:�isdir�access�W_OKr�FileNotFoundError�_errno�ENOENT)Znamerr?�dir�seqr:�filenamer�fprrr�_get_default_tempdir�s:			


!
	rXc
CsGtdkrCtj�ztdkr1t�anWdtj�XntS)z7Common setup sequence for all user-callable interfaces.N)�_name_sequence�
_once_lock�acquirer�releaserrrr�_get_candidate_names�s
r]c	Cs�t�}x�tt�D]�}t|�}tjj||||�}y/tj||d�}|tjj|�fSWqt	k
r�wYqt
k
r�tjdkr�tjj|�r�tj
|tj�r�wn�YqXqWt	tjd��dS)z>Code common to mkstemp, TemporaryFile, and NamedTemporaryFile.i�r7z#No usable temporary file name foundN)r]r,rrGrrEr-rrFrLrMr:rNrOrPrR�EEXIST)	rTZpreZsuf�flags�namesrUr:�filerrrr�_mkstemp_inner�s 	

!	rbcCstS)zAccessor for tempdir.template.)�templaterrrrr	�sc
CsGtdkrCtj�ztdkr1t�anWdtj�XntS)zAccessor for tempfile.tempdir.N)r
rZr[rXr\rrrrr�s
r*FcCs@|dkrt�}n|r't}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 specified, the file name will end with that suffix,
    otherwise there will be no suffix.

    If 'prefix' is specified, the file name will begin with that prefix,
    otherwise a default prefix is used.

    If 'dir' is specified, 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.  On
    some operating systems, this makes no difference.

    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.
    N)r�_text_openflagsrHrb)�suffix�prefixrT�textr_rrrr�s	cCs�|dkrt�}nt�}x�tt�D]�}t|�}tjj||||�}ytj|d�|SWq.t	k
r�w.Yq.t
k
r�tjdkr�tjj|�r�tj
|tj�r�w.n�Yq.Xq.Wt	tjd��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.
    Ni�r7z(No usable temporary directory name found)rr]r,rrGrrEr-�mkdirrLrMr:rNrOrPrRr^)rerfrTr`rUr:rarrrrs$
	

!	cCs�|dkrt�}nt�}xMtt�D]?}t|�}tjj||||�}t|�s.|Sq.Wt	t
jd��dS)a�User-callable function to return a unique temporary file name.  The
    file is not created.

    Arguments are as for mkstemp, except that the 'text' argument is
    not accepted.

    This function is unsafe and should not be used.  The file name
    refers 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)rr]r,rrGrrEr-rrLrRr^)rerfrTr`rUr:rarrrr?s		c@smeZdZdZdZdZddd�Zejdkr]ej	dd	�Z
d
d�Znd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||_||_||_dS)N)rar:�delete)r"rar:rjrrr�__init__fs		z_TemporaryFileCloser.__init__r7cCsW|jrS|jdk	rSd|_z|jj�Wd|jrO||j�nXndS)NT)�close_calledrarrjr:)r"rKrrrrus		z_TemporaryFileCloser.closecCs|j�dS)N)r)r"rrr�__del__sz_TemporaryFileCloser.__del__cCs&|js"d|_|jj�ndS)NT)rlrar)r"rrrr�s		)r/r0r1r2rarlrkrr:rKrrmrrrrri^s
ric@saeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�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.
    TcCs4||_||_||_t|||�|_dS)N)rar:rjri�_closer)r"rar:rjrrrrk�s			z_TemporaryFileWrapper.__init__cs�|jd}t||�}t|d�rg|�tj���fdd��}|j|_|}nt|t�s�t|||�n|S)Nra�__call__cs
�||�S)Nr)�args�kwargs)�funcrr�func_wrapper�sz7_TemporaryFileWrapper.__getattr__.<locals>.func_wrapper)	�__dict__r �hasattr�
_functools�wrapsro�
isinstance�int�setattr)r"r:ra�artr)rsr�__getattr__�s
!	z!_TemporaryFileWrapper.__getattr__cCs|jj�|S)N)ra�	__enter__)r"rrrr~�s
z_TemporaryFileWrapper.__enter__cCs&|jj|||�}|j�|S)N)ra�__exit__r)r"�exc�value�tb�resultrrrr�s
z_TemporaryFileWrapper.__exit__cCs|jj�dS)zA
        Close the temporary file, possibly deleting it.
        N)ror)r"rrrr�sz_TemporaryFileWrapper.closeccsx|jD]}|Vq
WdS)N)ra)r"�linerrrr$�sz_TemporaryFileWrapper.__iter__N)
r/r0r1r2rkr}r~rrr$rrrrrn�srnzw+b�TcCs�|dkrt�}nt}tjdkrC|rC|tjO}nt||||�\}	}
y8tj|	|d|d|d|�}t||
|�SWn"t	k
r�tj
|	��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).
    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 file.name.  The file will be automatically deleted
    when it is closed unless the 'delete' argument is set to False.
    Nr7�	buffering�newline�encoding)rrHrr:ZO_TEMPORARYrbrIrrn�	Exceptionr)�moder�r�r�rerfrTrjr_rr:rarrrr�s

�posix�cygwinc
Cs�|dkrt�}nt}t||||�\}}	y3tj|	�tj||d|d|d|�SWntj|��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)
        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.
        Nr�r�r�)rrHrbrrKrIrr)
r�r�r�r�rerfrTr_rr:rrrr�s

c
@s{eZdZdZdZddd8dddeddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Ze
dd��Zdd�Zdd�Zdd�Ze
d d!��Ze
d"d#��Ze
d$d%��Zd&d'�Zd(d)�Zd*d+�Zd,d-�Ze
d.d/��Zd0d1�Zdd2d3�Zd4d5�Zd6d7�ZdS)9rz�Temporary 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.
    Frzw+br�Nr*c		Cs�d|krtj�|_ntjdd�|_||_d|_i|d6|d6|d6|d6|d	6|d6|d
6|_dS)N�br��
Fr�r�rerfr�rT)rI�BytesIO�_file�StringIO�	_max_size�_rolled�_TemporaryFileArgs)	r"�max_sizer�r�r�r�rerfrTrrrrks		zSpooledTemporaryFile.__init__cCs?|jr
dS|j}|r;|j�|kr;|j�ndS)N)r�r��tell�rollover)r"rar�rrr�_check*s
		zSpooledTemporaryFile._checkcCsh|jr
dS|j}t|j�}|_|`|j|j��|j|j�d�d|_dS)NrT)r�r�rr�rJ�getvalue�seekr�)r"raZnewfilerrrr�0s		zSpooledTemporaryFile.rollovercCs|jjrtd��n|S)Nz%Cannot enter context with closed file)r��closed�
ValueError)r"rrrr~AszSpooledTemporaryFile.__enter__cCs|jj�dS)N)r�r)r"r�r�r�rrrrFszSpooledTemporaryFile.__exit__cCs
|jj�S)N)r�r$)r"rrrr$JszSpooledTemporaryFile.__iter__cCs|jj�dS)N)r�r)r"rrrrMszSpooledTemporaryFile.closecCs
|jjS)N)r�r�)r"rrrr�PszSpooledTemporaryFile.closedcCsKy|jjSWn6tk
rFd|jdkr7�n|jdSYnXdS)Nr�r�r�)r�r�r=r�)r"rrrr�Ts
zSpooledTemporaryFile.encodingcCs|j�|jj�S)N)r�r��fileno)r"rrrr�]s
zSpooledTemporaryFile.filenocCs|jj�dS)N)r��flush)r"rrrr�aszSpooledTemporaryFile.flushcCs
|jj�S)N)r��isatty)r"rrrr�dszSpooledTemporaryFile.isattycCs2y|jjSWntk
r-|jdSYnXdS)Nr�)r�r�r=r�)r"rrrr�gs
zSpooledTemporaryFile.modecCs+y|jjSWntk
r&dSYnXdS)N)r�r:r=)r"rrrr:ns
zSpooledTemporaryFile.namecCsKy|jjSWn6tk
rFd|jdkr7�n|jdSYnXdS)Nr�r�r�)r��newlinesr=r�)r"rrrr�us
zSpooledTemporaryFile.newlinescGs|jj|�S)N)r��read)r"rqrrrr�~szSpooledTemporaryFile.readcGs|jj|�S)N)r��readline)r"rqrrrr��szSpooledTemporaryFile.readlinecGs|jj|�S)N)r��	readlines)r"rqrrrr��szSpooledTemporaryFile.readlinescGs|jj|�dS)N)r�r�)r"rqrrrr��szSpooledTemporaryFile.seekcCs
|jjS)N)r��	softspace)r"rrrr��szSpooledTemporaryFile.softspacecCs
|jj�S)N)r�r�)r"rrrr��szSpooledTemporaryFile.tellcCsL|dkr|jj�n,||jkr8|j�n|jj|�dS)N)r��truncater�r�)r"�sizerrrr��s

zSpooledTemporaryFile.truncatecCs)|j}|j|�}|j|�|S)N)r�rJr�)r"�sra�rvrrrrJ�s	
zSpooledTemporaryFile.writecCs)|j}|j|�}|j|�|S)N)r��
writelinesr�)r"�iterablerar�rrrr��s	
zSpooledTemporaryFile.writelines���)r/r0r1r2r�rcrkr�r�r~rr$rr3r�r�r�r�r�r�r:r�r�r�r�r�r�r�r�rJr�rrrrrs8			c@smeZdZdZdeddd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�ZdS)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.
    r*NcCsFt|||�|_tj||j|jddj|��|_dS)N�warn_messagezImplicitly cleaning up {!r})rr:�_weakref�finalize�_cleanup�format�
_finalizer)r"rerfrTrrrrk�szTemporaryDirectory.__init__cCs!tj|�tj|t�dS)N)�_shutil�rmtree�	_warnings�warn�ResourceWarning)�clsr:r�rrrr��s
zTemporaryDirectory._cleanupcCsdj|jj|j�S)Nz	<{} {!r}>)r��	__class__r/r:)r"rrr�__repr__�szTemporaryDirectory.__repr__cCs|jS)N)r:)r"rrrr~�szTemporaryDirectory.__enter__cCs|j�dS)N)�cleanup)r"r�r�r�rrrr�szTemporaryDirectory.__exit__cCs&|jj�r"tj|j�ndS)N)r��detachr�r�r:)r"rrrr��szTemporaryDirectory.cleanup)r/r0r1r2rcrk�classmethodr�r�r~rr�rrrrr�s
r�r�)=r2�__all__�	functoolsrw�warningsr��iorI�osrZshutilr��errnorRZrandomr
r!�weakrefr��_thread�ImportErrorZ
_dummy_thread�
allocate_lockZ_allocate_lock�O_RDWR�O_CREAT�O_EXCLrdrvrrHrrrcrZrrrrrrArXrYr]rbr	r
rrrrrirnrr:�sys�platformrr�objectrrrrr�<module>sx
		-%&+?		$!			�

Zerion Mini Shell 1.0