o
    >h/                     @  s*  d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZmZ ddlmZmZ dd	lmZmZmZm Z m!Z!m"Z" d
Z#ede$e%Z&ede$e%Z'edddZ(eeeG dd dee'e&f ee' Z)G dd de)e
e
f Z*ddgZ+dS )zt
This module contains implementations of L{IFilePath} for zip files.

See the constructor of L{ZipArchive} for use.
    )annotationsN)IOTYPE_CHECKINGAnyAnyStrDictGenericIterableListTupleTypeVarUnion)ZipFile)implementer)LiteralSelf)cmp
comparable)AbstractFilePathFilePath	IFilePathOtherAnyStrUnlistableError_coerceToFilesystemEncoding/_ArchiveStr_ZipStr_ZipSelfzZipPath[Any, Any])boundc                   @  s
  e Zd ZU dZded< dId	d
ZdJddZdKddZedLddZ	dMddZ
dNddZer2dOddZdPd d!ZdPd"d#ZdQd%d&ZdQd'd(ZdQd)d*ZdQd+d,ZdRd.d/ZdSd1d2ZdLd3d4ZdLd5d6ZdTdUd;d<ZdVd=d>ZdWd?d@ZdXdBdCZdXdDdEZdXdFdGZdHS )YZipPathzF
    I represent a file or directory contained within a zip file.
    r   patharchiveZipArchive[_ArchiveStr]pathInArchivereturnNonec                 C  sZ   || _ || _t|j|| _t|t}t||j}| j|}tjj	|g|R  }|| _dS )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)
r!   r#   r   _zipfileFilename_nativePathInArchiveZIP_PATH_SEPsplitosr    join)selfr!   r#   separchiveFilenamesegmentsfakePath r1   v/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/python/zippath.py__init__=   s   


zZipPath.__init__otherobjectintc                 C  s(   t |tstS t| j| jf|j|jfS N)
isinstancer   NotImplementedr   r!   r#   r,   r4   r1   r1   r2   __cmp__W   s
   
zZipPath.__cmp__strc                 C  sN   t | jtj| jjg}|| j| j t | jtj}d|	|dS )NzZipPath())
r   r-   r*   r    abspathr!   extendr#   r)   r+   )r,   partsossepr1   r1   r2   __repr__^   s
   zZipPath.__repr__c                 C  s   t | jtS )z
        Return a zip directory separator.

        @return: The zip directory separator.
        @returntype: The same type as C{self.path}.
        )r   r    r(   r,   r1   r1   r2   r-   g   s   zZipPath.sep=Union[ZipPath[_ZipStr, _ArchiveStr], ZipArchive[_ArchiveStr]]c                 C  s<   | j | j}t|dkr| jS t| j| j|dd S )zk
        Return parent, discarding our own encoding in favor of whatever the
        archive's is.
           N)r#   r)   r-   lenr!   r   r+   )r,   splitupr1   r1   r2   _nativeParentq   s   zZipPath._nativeParent9Union[ZipPath[_ZipStr, _ArchiveStr], ZipArchive[_ZipStr]]c                 C  s*   |   }t|trtt| j| jjS |S r7   )rI   r8   
ZipArchiver   r    r!   r&   )r,   parentr1   r1   r2   rL   }   s   
zZipPath.parentCIterable[Union[ZipPath[_ZipStr, _ArchiveStr], ZipArchive[_ZipStr]]]c                 C     d S r7   r1   rC   r1   r1   r2   parents   s   zZipPath.parentsr   !ZipPath[OtherAnyStr, _ArchiveStr]c                 C  s,   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   r(   r#   r   r!   r+   )r,   r    joinerr#   r1   r1   r2   child   s   
zZipPath.childc                 C  s*   |   }t|tr| jn|}||}|S r7   )rL   r8   rK   r!   rR   )r,   r    rL   rightTypedParentrR   r1   r1   r2   sibling   s   
zZipPath.siblingboolc                 C  s   |   p|  S r7   )isdirisfilerC   r1   r1   r2   exists      zZipPath.existsc                 C  s   | j | jjv S r7   )r#   r!   childmaprC   r1   r1   r2   rV      s   zZipPath.isdirc                 C  s   | j | jjjv S r7   )r#   r!   zipfile
NameToInforC   r1   r1   r2   rW      rY   zZipPath.isfilec                 C  s   dS )NFr1   rC   r1   r1   r2   islink      zZipPath.islinkList[_ZipStr]c                   s^      r'  rt jj j} fdd jj|  D S tt	t
jdtt	t
jd)Nc                   s   g | ]}t  j|qS r1   )r   r    ).0eachrC   r1   r2   
<listcomp>   s    
z#ZipPath.listdir.<locals>.<listcomp>zLeaf zip entry listedzNon-existent zip entry listed)rX   rV   r   r!   r&   r#   rZ   keysr   OSErrorerrnoENOTDIRENOENT)r,   parentArchivePathr1   rC   r2   listdir   s   


zZipPath.listdirTuple[_ZipStr, _ZipStr]c                 C  s   t j| jS )zQ
        Return a value similar to that returned by C{os.path.splitext}.
        )r*   r    splitextrC   r1   r1   r2   rk      s   zZipPath.splitextc                 C  s   | j | jd S )NrF   )r#   r)   r-   rC   r1   r1   r2   basename   s   zZipPath.basenamec                 C  s
   |   jS r7   )rL   r    rC   r1   r1   r2   dirname   s   
zZipPath.dirnamermodeLiteral['r', 'w']	IO[bytes]c                 C  s   t d| j}| jjj||dS )N )ro   )r   r#   r!   r[   open)r,   ro   r#   r1   r1   r2   rs      s   zZipPath.openc                 C  rN   r7   r1   rC   r1   r1   r2   changed   r^   zZipPath.changedc                 C  s   t d| j}| jjj| jS )zR
        Retrieve this file's size.

        @return: file size, in bytes
        rr   )r   r#   r!   r[   r\   	file_sizer,   r#   r1   r1   r2   getsize   s   zZipPath.getsizefloatc                 C  s
   | 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!   getAccessTimerC   r1   r1   r2   ry         
zZipPath.getAccessTimec                 C  s&   t d| j}t| jjj| jd 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.
        rr   )r   r   r   )r   r#   timemktimer!   r[   r\   	date_timerv   r1   r1   r2   getModificationTime   s   zZipPath.getModificationTimec                 C  s   |   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.
        )r~   rC   r1   r1   r2   getStatusChangeTime   s   zZipPath.getStatusChangeTimeN)r!   r"   r#   r   r$   r%   r4   r5   r$   r6   r$   r<   )r$   r   )r$   rD   )r$   rJ   )r$   rM   )r    r   r$   rP   r$   rU   )r$   r_   )r$   rj   )rn   )ro   rp   r$   rq   )r$   r%   )r$   r6   r$   rx   )__name__
__module____qualname____doc____annotations__r3   r;   rB   propertyr-   rI   rL   r   rO   rR   rT   rX   rV   rW   r]   ri   rk   rl   rm   rs   rt   rw   ry   r~   r   r1   r1   r1   r2   r   4   s8   
 


	
	




	





	



	
	r   c                   @  sx   e Zd ZU dZded< ed$ddZd%d
dZd&ddZd'ddZ	d(ddZ
d)ddZd)ddZd)ddZd*d!d"Zd#S )+rK   a  
    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.
    r   r&   r$   r   c                 C  s   | S r7   r1   rC   r1   r1   r2   r!     s   zZipArchive.archivearchivePathnamer%   c                 C  s   || _ ttd|| _| jj}|dusJ dt||| _t|d| _i | _| j D ];}t| j |	| j
}tt|D ]#}||  }| j
|d|  }|| jvrYi | j|< d| j| |< q=t|d}q+dS )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.
        rr   Nz7zipfile must have filename when initialized with a pathrE   )r    r   r   r[   filenamer&   r#   rZ   namelistr)   r-   rangerG   r+   )r,   r   zfnamename	splitNamexrR   rL   r1   r1   r2   r3     s&   



zZipArchive.__init__r4   r5   r6   c                 C  s   t |tstS t| j|jS r7   )r8   rK   r9   r   r    r:   r1   r1   r2   r;   6  s   
zZipArchive.__cmp__r    r   ZipPath[OtherAnyStr, AnyStr]c                 C  s
   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   )r,   r    r1   r1   r2   rR   ;  rz   zZipArchive.childrU   c                 C     t | j S )zC
        Returns C{True} if the underlying archive exists.
        )r   r&   rX   rC   r1   r1   r2   rX   D     zZipArchive.existsrx   c                 C  r   )z=
        Return the archive file's last access time.
        )r   r&   ry   rC   r1   r1   r2   ry   J  r   zZipArchive.getAccessTimec                 C  r   )z>
        Return the archive file's modification time.
        )r   r&   r~   rC   r1   r1   r2   r~   P  r   zZipArchive.getModificationTimec                 C  r   )z?
        Return the archive file's status change time.
        )r   r&   r   rC   r1   r1   r2   r   V  r   zZipArchive.getStatusChangeTimer<   c                 C  s   dt j| jdS )NzZipArchive(r=   )r*   r    r>   rC   r1   r1   r2   rB   \  s   zZipArchive.__repr__N)r$   r   )r   r   r$   r%   r   )r    r   r$   r   r   r   r   )r   r   r   r   r   r   r!   r3   r;   rR   rX   ry   r~   r   rB   r1   r1   r1   r2   rK     s   
 



	


rK   ),r   
__future__r   re   r*   r{   typingr   r   r   r   r   r   r	   r
   r   r   r   r[   r   zope.interfacer   typing_extensionsr   r   twisted.python.compatr   r   twisted.python.filepathr   r   r   r   r   r   r(   bytesr<   r   r   r   r   rK   __all__r1   r1   r1   r2   <module>   s*   4 	" P[