CasperSecurity

Current Path : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/zippath.cpython-310.pyc

o

�bD#�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZmZmZmZmZdZee	e�Gd	d
�d
e���ZGdd�de�Zdd
gZdS)
zt
This module contains implementations of L{IFilePath} for zip files.

See the constructor of L{ZipArchive} for use.
�N)�Dict)�ZipFile)�implementer)�cmp�
comparable)�AbstractFilePath�FilePath�	IFilePath�UnlistableError�_coerceToFilesystemEncoding�/c@s�eZdZdZdd�Zdd�Zdefdd�Zed	d
��Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd/d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.S)0�ZipPathzF
    I represent a file or directory contained within a zip file.
    cCsF||_||_t|t�}t||jj�}tjj|g|j�	|��R�|_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�sep�archiveFilename�r�8/usr/lib/python3/dist-packages/twisted/python/zippath.py�__init__(s
�"zZipPath.__init__cCs(t|t�stSt|j|jf|j|jf�S�N)�
isinstancer
�NotImplementedrrr)r�otherrrr�__cmp__;s

�zZipPath.__cmp__�returncCsNt|jtj�|jj��g}|�|j�|j��t|jtj�}d|�	|��d�S)NzZipPath(�))
rrrr�abspathr�extendrrr)r�parts�osseprrr�__repr__Bs
�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}.
        )rrr�rrrrrJszZipPath.sepcCs<|j�|j�}t|�dkr|jSt|j|j�|dd���S)N����)rrr�lenrr
r)r�splituprrr�parentTs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.
        )rrrr
rr)rr�joinerrrrr�childZs
z
ZipPath.childcCs|���|�Sr)r.r0�rrrrr�siblingj�zZipPath.siblingcCs|��p|��Sr)�isdir�isfiler)rrr�existsm�zZipPath.existscCs|j|jjvSr)rr�childmapr)rrrr4pr3z
ZipPath.isdircCs|j|jjjvSr)rrr�
NameToInfor)rrrr5sr7zZipPath.isfilecCsdS)NFrr)rrr�islinkv�zZipPath.islinkcCsF|��r|��rt|jj|j���Sttt	j
d���ttt	jd���)NzLeaf zip entry listedzNon-existent zip entry listed)r6r4�listrr8r�keysr
�OSError�errno�ENOTDIR�ENOENTr)rrr�listdirys
�zZipPath.listdircCstj�|j�S)zQ
        Return a value similar to that returned by C{os.path.splitext}.
        )rr�splitextr)rrrrC�szZipPath.splitextcCs|j�|j�dS)Nr+)rrrr)rrr�basename�szZipPath.basenamecCs
|��jSr)r.rr)rrr�dirname�s
zZipPath.dirname�rcCstd|j�}|jjj||d�S)N�)�mode)rrrr�open)rrHrrrrrI�szZipPath.opencCsdSrrr)rrr�changed�r;zZipPath.changedcCstd|j�}|jjj|jS)zR
        Retrieve this file's size.

        @return: file size, in bytes
        rG)rrrrr9�	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�
getAccessTimer)rrrrN��
zZipPath.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.
        rG)rrr)rr�time�mktimerrr9�	date_timerLrrr�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.
        )rSr)rrr�getStatusChangeTime�szZipPath.getStatusChangeTimeN)rF)�__name__�
__module__�__qualname__�__doc__rr!�strr(�propertyrr.r0r2r6r4r5r:rBrCrDrErIrJrMrNrSrTrrrrr
!s0
		
		r
c@sZeZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdefdd�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|Srrr)rrrr�szZipArchive.archivecCs�||_ttd|��|_t|d�|_i|_|j��D];}t|j|��|j�}t	t
|��D]#}||}|j�|d|��}||jvrGi|j|<d|j||<q+t|d�}qdS)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.
        rGNr*)rrrrrr8�namelistrr�ranger,r)r�archivePathname�name�xr0r.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
r1rrrr0�rOzZipArchive.childcC�t|jj���S)zC
        Returns C{True} if the underlying archive exists.
        )rrrr6r)rrrr6��zZipArchive.existscCra)z=
        Return the archive file's last access time.
        )rrrrNr)rrrrN�rbzZipArchive.getAccessTimecCra)z>
        Return the archive file's modification time.
        )rrrrSr)rrrrSrbzZipArchive.getModificationTimecCra)z?
        Return the archive file's status change time.
        )rrrrTr)rrrrT	rbzZipArchive.getStatusChangeTimer"cCsdtj�|j��d�S)NzZipArchive(r#)rrr$r)rrrr(szZipArchive.__repr__N)rUrVrWrXrZrrr0r6rNrSrTrYr(rrrrr[�s
	r[)rXr?rrP�typingrrr�zope.interfacer�twisted.python.compatrr�twisted.python.filepathrrr	r
rrr
r[�__all__rrrr�<module>s "O
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY