HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/thread-self/root/lib/python3/dist-packages/twisted/python/__pycache__/zippath.cpython-38.pyc
U


W[$�@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�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__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|���|�Sr)r*r+�rrrrr�siblingkszZipPath.siblingcCs|��p|��Sr)�isdir�isfiler&rrr�existsoszZipPath.existscCs|j|jjkSr)rr�childmapr&rrrr.ssz
ZipPath.isdircCs|j|jjjkSr)rrr�
NameToInfor&rrrr/wszZipPath.isfilecCsdS)NFrr&rrr�islink{szZipPath.islinkcCsL|��r8|��r&t|jj|j���Sttt	j
d���nttt	jd���dS)NzLeaf zip entry listedzNon-existent zip entry listed)r0r.�listrr1r�keysr�OSError�errnoZENOTDIRZENOENTr&rrr�listdirs
�
�zZipPath.listdircCstj�|j�S)zQ
        Return a value similar to that returned by C{os.path.splitext}.
        )rr�splitextr&rrrr9�szZipPath.splitextcCs|j�|j�dS)Nr()rrrr&rrr�basename�szZipPath.basenamecCs
|��jSr)r*rr&rrr�dirname�szZipPath.dirname�rcCstd|j�}|jjj||d�S)N�)�mode)r
rrr�open)rr>rrrrr?�szZipPath.opencCsdSrrr&rrr�changed�szZipPath.changedcCstd|j�}|jjj|jS)zR
        Retrieve this file's size.

        @return: file size, in bytes
        r=)r
rrrr2�	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&rrrrD�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�mktimerrr2Z	date_timerBrrr�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.
        )rGr&rrr�getStatusChangeTime�szZipPath.getStatusChangeTimeN)r<)�__name__�
__module__�__qualname__�__doc__rr!r%�propertyrr*r+r-r0r.r/r3r8r9r:r;r?r@rCrDrGrHrrrrrs.






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|Srrr&rrr�<lambda>��zZipArchive.<lambda>cCs�||_ttd|��|_t|d�|_i|_|j��D]v}t|j|��|j�}t	t
|��D]F}||}|j�|d|��}||jkr�i|j|<d|j||<qVt|d�}q2dS)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
rrr1Znamelistrr�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).
        )rr,rrrr+�szZipArchive.childcCst|jj���S)zC
        Returns C{True} if the underlying archive exists.
        )rrrr0r&rrrr0szZipArchive.existscCst|jj���S)z=
        Return the archive file's last access time.
        )rrrrDr&rrrrDszZipArchive.getAccessTimecCst|jj���S)z>
        Return the archive file's modification time.
        )rrrrGr&rrrrGszZipArchive.getModificationTimecCst|jj���S)z?
        Return the archive file's status change time.
        )rrrrHr&rrrrHszZipArchive.getStatusChangeTimecCsdtj�|j�fS)NzZipArchive(%r))rrr"r&rrrr%#szZipArchive.__repr__N)
rIrJrKrLrMrrr+r0rDrGrHr%rrrrrN�s
rN)rLZ
__future__rrrrEr7rrZtwisted.python.compatrrZtwisted.python.filepathrrr	r
rZzope.interfacerrrrN�__all__rrrr�<module>s"5S