Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/zippath.cpython-37.pyc

B

:��]$�@s�dZddlmZmZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZmZddlmZddlmZdd	lmZd
Ze
ee
�Gdd�de���ZGd
d�de�ZddgZdS)zt
This module contains implementations of L{IFilePath} for zip files.

See the constructor of L{ZipArchive} for use.
�)�absolute_import�divisionN)�ZipFile)�
comparable�cmp)�	IFilePath�FilePath�AbstractFilePath)�_coerceToFilesystemEncoding)�UnlistableError)�implementer�/c@s�eZdZdZdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd.d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-S)/�ZipPathzF
    I represent a file or directory contained within a zip file.
    cCsD||_||_t|t�}t||jj�}tjj|f|j�	|���|_dS)z�
        Don't construct me directly.  Use C{ZipArchive.child()}.

        @param archive: a L{ZipArchive} instance.

        @param pathInArchive: a ZIP_PATH_SEP-separated string.
        N)
�archive�
pathInArchiver
�ZIP_PATH_SEP�zipfile�filename�os�path�join�split)�selfrr�sepZarchiveFilename�r�I/opt/alt/python37/lib64/python3.7/site-packages/twisted/python/zippath.py�__init__%s

zZipPath.__init__cCs(t|t�stSt|j|jf|j|jf�S)N)�
isinstancer�NotImplementedrrr)r�otherrrr�__cmp__9s
zZipPath.__cmp__cCsLt|jtj�|jj��g}|�|j�|j��t|jtj�}d|�	|�fS)NzZipPath(%r))
r
rrr�abspathr�extendrrr)r�partsZosseprrr�__repr__@s
zZipPath.__repr__cCst|jt�S)z�
        Return a zip directory separator.

        @return: The zip directory separator.
        @returntype: The same type as C{self.path}.
        )r
rr)rrrrrHszZipPath.sepcCs<|j�|j�}t|�dkr |jSt|j|j�|dd���S)N����)rrr�lenrrr)rZsplituprrr�parentSszZipPath.parentcCs,t|t�}t||j�}t|j|�||g��S)a&
        Return a new ZipPath representing a path in C{self.archive} which is
        a child of this path.

        @note: Requesting the C{".."} (or other special name) child will not
            cause L{InsecurePath} to be raised since these names do not have
            any special meaning inside a zip archive.  Be particularly
            careful with the C{path} attribute (if you absolutely must use
            it) as this means it may include special names with special
            meaning outside of the context of a zip archive.
        )r
rrrrr)rrZjoinerrrrr�childZs
z
ZipPath.childcCs|���|�S)N)r(r))rrrrr�siblingkszZipPath.siblingcCs|��p|��S)N)�isdir�isfile)rrrr�existsoszZipPath.existscCs|j|jjkS)N)rr�childmap)rrrrr+ssz
ZipPath.isdircCs|j|jjjkS)N)rrr�
NameToInfo)rrrrr,wszZipPath.isfilecCsdS)NFr)rrrr�islink{szZipPath.islinkcCsL|��r8|��r&t|jj|j���Sttt	j
d���nttt	jd���dS)NzLeaf zip entry listedzNon-existent zip entry listed)r-r+�listrr.r�keysr�OSError�errno�ENOTDIR�ENOENT)rrrr�listdirszZipPath.listdircCstj�|j�S)zQ
        Return a value similar to that returned by C{os.path.splitext}.
        )rr�splitext)rrrrr8�szZipPath.splitextcCs|j�|j�dS)Nr&)rrr)rrrr�basename�szZipPath.basenamecCs
|��jS)N)r(r)rrrr�dirname�szZipPath.dirname�rcCstd|j�}|jjj||d�S)N�)�mode)r
rrr�open)rr=rrrrr>�szZipPath.opencCsdS)Nr)rrrr�changed�szZipPath.changedcCstd|j�}|jjj|jS)zR
        Retrieve this file's size.

        @return: file size, in bytes
        r<)r
rrrr/�	file_size)rrrrr�getsize�szZipPath.getsizecCs
|j��S)z�
        Retrieve this file's last access-time.  This is the same as the last access
        time for the archive.

        @return: a number of seconds since the epoch
        )r�
getAccessTime)rrrrrB�szZipPath.getAccessTimecCs&td|j�}t�|jjj|jd�S)z�
        Retrieve this file's last modification time.  This is the time of
        modification recorded in the zipfile.

        @return: a number of seconds since the epoch.
        r<)rrr)r
r�time�mktimerrr/�	date_time)rrrrr�getModificationTime�szZipPath.getModificationTimecCs|��S)z�
        Retrieve this file's last modification time.  This name is provided for
        compatibility, and returns the same value as getmtime.

        @return: a number of seconds since the epoch.
        )rF)rrrr�getStatusChangeTime�szZipPath.getStatusChangeTimeN)r;)�__name__�
__module__�__qualname__�__doc__rr r$�propertyrr(r)r*r-r+r,r0r7r8r9r:r>r?rArBrFrGrrrrrs,




rc@sTeZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�
ZipArchivea�
    I am a L{FilePath}-like object which can wrap a zip archive as if it were a
    directory.

    It works similarly to L{FilePath} in L{bytes} and L{unicode} handling --
    instantiating with a L{bytes} will return a "bytes mode" L{ZipArchive},
    and instantiating with a L{unicode} will return a "text mode"
    L{ZipArchive}. Methods that return new L{ZipArchive} or L{ZipPath}
    instances will be in the mode of the argument to the creator method,
    converting if required.
    cCs|S)Nr)rrrr�<lambda>��zZipArchive.<lambda>cCs�||_ttd|��|_t|d�|_i|_x�|j��D]z}t|j|��|j�}xVt	t
|��D]F}||}|j�|d|��}||jkr�i|j|<d|j||<qZWt|d�}q4WdS)z�
        Create a ZipArchive, treating the archive at archivePathname as a zip
        file.

        @param archivePathname: a L{bytes} or L{unicode}, naming a path in the
            filesystem.
        r<Nr%)rrr
rrr.�namelistrr�ranger'r)rZarchivePathname�name�xr)r(rrrr�s



zZipArchive.__init__cCs
t||�S)z�
        Create a ZipPath pointing at a path within the archive.

        @param path: a L{bytes} or L{unicode} with no path separators in it
            (either '/' or the system path separator, if it's different).
        )r)rrrrrr)�szZipArchive.childcCst|jj���S)zC
        Returns C{True} if the underlying archive exists.
        )rrrr-)rrrrr-szZipArchive.existscCst|jj���S)z=
        Return the archive file's last access time.
        )rrrrB)rrrrrBszZipArchive.getAccessTimecCst|jj���S)z>
        Return the archive file's modification time.
        )rrrrF)rrrrrFszZipArchive.getModificationTimecCst|jj���S)z?
        Return the archive file's status change time.
        )rrrrG)rrrrrGszZipArchive.getStatusChangeTimecCsdtj�|j�fS)NzZipArchive(%r))rrr!)rrrrr$#szZipArchive.__repr__N)
rHrIrJrKrLrrr)r-rBrFrGr$rrrrrM�s
rM)rK�
__future__rrrrCr4rrZtwisted.python.compatrrZtwisted.python.filepathrrr	r
rZzope.interfacerrrrM�__all__rrrr�<module>	s"
5S