Ë
    ojñ/  ã            	      óh  — 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¬«      Z'e ee«       G d„ dee&e%f   ee&   «      «       «       Z( G d„ de(e
e
f   «      Z)ddgZ*y)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                  óø   — e Zd ZU dZded<   	 	 	 	 	 	 dd„Zdd„Zdd„Zedd„«       Z		 	 d d„Z
d!d	„Zer	 	 d"d
„Zd#d„Zd#d„Zd$d„Zd$d„Zd$d„Zd$d„Zd%d„Zd&d„Zdd„Zdd„Zd'd(d„Zd)d„Zd*d„Zd+d„Zd+d„Zd+d„Zy),ÚZipPathzF
    I represent a file or directory contained within a zip file.
    r   Úpathc                ó&  — || _         || _        t        |j                  |«      | _        t        |t
        «      }t        ||j                  «      }| j                  j                  |«      }t        j                  j                  |g|¢­Ž }|| _        y)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   Ú_zipfileFilenameÚ_nativePathInArchiveÚZIP_PATH_SEPÚsplitÚosr"   Újoin)Úselfr$   r%   ÚsepÚarchiveFilenameÚsegmentsÚfakePaths          ú8/usr/lib/python3/dist-packages/twisted/python/zippath.pyÚ__init__zZipPath.__init__=   s„   € ð 18ˆŒØ&3ˆÔÜ1LØ×$Ñ$ mó2
ˆÔ!ô *¨-¼ÓFˆÜ#>Ø˜7×3Ñ3ó$
ˆð #'×"4Ñ"4×":Ñ":¸3Ó"?ˆÜŸG™GŸL™L¨ÐD¸8ÒDˆØ%ˆ�	ó    c                óž   — t        |t        «      st        S t        | j                  | j
                  f|j                  |j
                  f«      S ©N)Ú
isinstancer!   ÚNotImplementedr   r$   r%   ©r,   Úothers     r1   Ú__cmp__zZipPath.__cmp__W   sB   € Ü˜%¤Ô)Ü!Ð!ÜØ�\‰\˜4×-Ñ-Ð.°·±À×@SÑ@SÐ0Tó
ð 	
r3   c                ól  — t        | j                  t        j                  j	                  | j
                  j                  «      «      g}|j                  | j                  j                  | j                  «      «       t        | j                  t        j                  «      }d|j                  |«      ›d�S )NzZipPath(ú))
r   r-   r*   r"   Úabspathr$   Úextendr%   r)   r+   )r,   ÚpartsÚosseps      r1   Ú__repr__zZipPath.__repr__^   s€   € ô (¨¯©´"·'±'·/±/À$Ç,Á,×BSÑBSÓ2TÓUð
ˆð 	�‰�T×'Ñ'×-Ñ-¨d¯h©hÓ7Ô8Ü+¨D¯H©H´b·f±fÓ=ˆØ˜%Ÿ*™* UÓ+Ð.¨aÐ0Ð0r3   c                ó6   — 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,   s    r1   r-   zZipPath.sepg   s   € ô +¨4¯9©9´lÓCÐCr3   c                óä   — | j                   j                  | j                  «      }t        |«      dk(  r| j                  S t        | j                  | 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,   Úsplitups     r1   Ú_nativeParentzZipPath._nativeParentq   sX   € ð ×$Ñ$×*Ñ*¨4¯8©8Ó4ˆÜˆw‹<˜1ÒØ—<‘<ÐÜ�t—|‘| T§X¡X§]¡]°7¸3¸B°<Ó%@ÓAÐAr3   c                ó¬   — | j                  «       }t        |t        «      r3t        t        | j                  | j
                  j                  «      «      S |S r5   )rI   r6   Ú
ZipArchiver   r"   r$   r&   )r,   Úparents     r1   rL   zZipPath.parent}   sF   € Ø×#Ñ#Ó%ˆÜ�fœjÔ)ÜÜ+¨D¯I©I°t·|±|×7TÑ7TÓUóð ð ˆr3   c                 ó   — y r5   © rC   s    r1   ÚparentszZipPath.parents‡   s   € ð r3   c                óœ   — t        |t        «      }t        || j                  «      }t        | j                  |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%   s       r1   ÚchildzZipPath.childŒ   sA   € ô -¨T´<Ó@ˆÜ3°D¸$×:LÑ:LÓMˆÜ�t—|‘| V§[¡[°-ÀÐ1FÓ%GÓHÐHr3   c                ó„   — | j                  «       }t        |t        «      r| j                  n|}|j	                  |«      }|S r5   )rL   r6   rK   r$   rR   )r,   r"   rL   ÚrightTypedParentrR   s        r1   ÚsiblingzZipPath.siblingœ   s9   € ð —‘“ˆÜ+5°f¼jÔ+I˜4Ÿ<š<ÈvÐØ3C×3IÑ3IÈ$Ó3OˆØˆr3   c                óF   — | j                  «       xs | j                  «       S r5   )ÚisdirÚisfilerC   s    r1   ÚexistszZipPath.exists¥   s   € Ø�z‰z‹|Ò,˜tŸ{™{›}Ð,r3   c                óF   — | j                   | j                  j                  v S r5   )r%   r$   ÚchildmaprC   s    r1   rW   zZipPath.isdir¨   s   € Ø×!Ñ! T§\¡\×%:Ñ%:Ð:Ð:r3   c                óZ   — | j                   | j                  j                  j                  v S r5   )r%   r$   ÚzipfileÚ
NameToInforC   s    r1   rX   zZipPath.isfile«   s#   € Ø×!Ñ! T§\¡\×%9Ñ%9×%DÑ%DÐDÐDr3   c                 ó   — y)NFrN   rC   s    r1   ÚislinkzZipPath.islink®   s   € Ør3   c                ó¾  — | j                  «       r¦| j                  «       rst        | j                  j                  | j
                  «      }| j                  j                  |   j                  «       D �cg c]  }t        | j                  |«      ‘Œ c}S t        t        t        j                  d«      «      ‚t        t        t        j                  d«      «      ‚c c}w )NzLeaf zip entry listedzNon-existent zip entry listed)rY   rW   r   r$   r&   r%   r[   Úkeysr"   r   ÚOSErrorÚerrnoÚENOTDIRÚENOENT)r,   ÚparentArchivePathÚeachs      r1   ÚlistdirzZipPath.listdir±   s¯   € Ø�;‰;Œ=Ø�z‰zŒ|Ü1LØ—L‘L×1Ñ1°4×3EÑ3Eó2Ð!ð
 !%§¡× 5Ñ 5Ð6GÑ H× MÑ MÓ Oöàô 0°·	±	¸4Õ@òð ô
 &¤g¬e¯m©mÐ=TÓ&UÓVÐVä!ÜœŸ™Ð&EÓFóð ùòs   Á4Cc                óT   — t         j                  j                  | j                  «      S )zQ
        Return a value similar to that returned by C{os.path.splitext}.
        )r*   r"   ÚsplitextrC   s    r1   rk   zZipPath.splitextÂ   s   € ô �w‰w×Ñ §	¡	Ó*Ð*r3   c                óR   — | j                   j                  | j                  «      d   S )NrF   )r%   r)   r-   rC   s    r1   ÚbasenamezZipPath.basenameË   s"   € Ø×!Ñ!×'Ñ'¨¯©Ó1°"Ñ5Ð5r3   c                ó6   — | j                  «       j                  S r5   )rL   r"   rC   s    r1   ÚdirnamezZipPath.dirnameÎ   s   € ð �{‰{‹}×!Ñ!Ð!r3   c                ó|   — t        d| j                  «      }| j                  j                  j	                  ||¬«      S )NÚ )Úmode)r   r%   r$   r]   Úopen)r,   rr   r%   s      r1   rs   zZipPath.openÓ   s6   € ô 4°B¸×8JÑ8JÓKˆØ�|‰|×#Ñ#×(Ñ(¨¸TÐ(ÓBÐBr3   c                 ó   — y r5   rN   rC   s    r1   ÚchangedzZipPath.changedÚ   s   € Ør3   c                óˆ   — t        d| j                  «      }| j                  j                  j                  |   j
                  S )zR
        Retrieve this file's size.

        @return: file size, in bytes
        rq   )r   r%   r$   r]   r^   Ú	file_size©r,   r%   s     r1   ÚgetsizezZipPath.getsizeÝ   s7   € ô 4°B¸×8JÑ8JÓKˆØ�|‰|×#Ñ#×.Ñ.¨}Ñ=×GÑGÐGr3   c                ó6   — | j                   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   s    r1   r{   zZipPath.getAccessTimeæ   s   € ð �|‰|×)Ñ)Ó+Ð+r3   c                ó´   — t        d| j                  «      }t        j                  | j                  j
                  j                  |   j                  dz   «      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.
        rq   )r   r   r   )r   r%   ÚtimeÚmktimer$   r]   r^   Ú	date_timerx   s     r1   ÚgetModificationTimezZipPath.getModificationTimeï   sJ   € ô 4°B¸×8JÑ8JÓKˆÜ�{‰{Ø�L‰L× Ñ ×+Ñ+¨MÑ:×DÑDÀyÑPó
ð 	
r3   c                ó"   — | j                  «       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   s    r1   ÚgetStatusChangeTimezZipPath.getStatusChangeTimeû   s   € ð ×'Ñ'Ó)Ð)r3   N)r$   zZipArchive[_ArchiveStr]r%   r   ÚreturnÚNone©r9   Úobjectrƒ   Úint©rƒ   Ústr)rƒ   r   )rƒ   z=Union[ZipPath[_ZipStr, _ArchiveStr], ZipArchive[_ArchiveStr]])rƒ   z9Union[ZipPath[_ZipStr, _ArchiveStr], ZipArchive[_ZipStr]])rƒ   zCIterable[Union[ZipPath[_ZipStr, _ArchiveStr], ZipArchive[_ZipStr]]])r"   r   rƒ   z!ZipPath[OtherAnyStr, _ArchiveStr]©rƒ   Úbool)rƒ   zList[_ZipStr])rƒ   zTuple[_ZipStr, _ZipStr])Úr)rr   zLiteral['r', 'w']rƒ   z	IO[bytes])rƒ   r„   )rƒ   r‡   ©rƒ   Úfloat)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r2   r:   rA   Úpropertyr-   rI   rL   r   rO   rR   rU   rY   rW   rX   r`   ri   rk   rm   ro   rs   ru   ry   r{   r€   r‚   rN   r3   r1   r!   r!   4   sÅ   … ñð ƒMð&Ø.ð&Ø?Fð&à	ó&ó4
ó1ð òDó ðDð
Bà	Fó
Bóñ ð	àPó	ó
Ió ó-ó;óEóóó"+ó6ó"ô
CóóHó,ó

ô*r3   r!   c                  ón   — e Zd ZU dZded<   edd„«       Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zdd„Zdd„Zy)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&   c                ó   — | S r5   rN   rC   s    r1   r$   zZipArchive.archive  s   € àˆr3   c                ód  — || _         t        t        d|«      «      | _        | j                  j                  }|€J d«       ‚t        ||«      | _        t        |d«      | _        i | _        | j                  j                  «       D ]ª  }t        | j                   |«      j                  | j                  «      }t        t        |«      «      D ]V  }||    }| j                  j                  |d|  «      }|| j                  vri | j                  |<   d| j                  |   |<   ŒX t        |d«      }Œ¬ y)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.
        rq   Nz7zipfile must have filename when initialized with a pathrE   )r"   r   r   r]   Úfilenamer&   r%   r[   Únamelistr)   r-   ÚrangerG   r+   )r,   ÚarchivePathnameÚzfnameÚnameÚ	splitNameÚxrR   rL   s           r1   r2   zZipArchive.__init__  s"  € ð $ˆŒ	ÜÔ:¸2¸ÓOÓPˆŒØ—‘×&Ñ&ˆàÐð	EàDó	EØä ;¸OÈVÓ TˆÔÜ8¸È"ÓMˆÔð :<ˆŒà—L‘L×)Ñ)Ó+ò 	FˆDÜ3°D·I±I¸tÓD×JÑJÈ4Ï8É8ÓTˆIÜœ3˜y›>Ó*ò 1�Ø! 1 "™�ØŸ™Ÿ™ y°°1°" ~Ó6�Ø §¡Ñ.Ø,.�D—M‘M &Ñ)Ø/0�—‘˜fÑ% eÒ,ð1ô 1°À"ÓE‰Fñ	Fr3   c                ón   — t        |t        «      st        S t        | j                  |j                  «      S r5   )r6   rK   r7   r   r"   r8   s     r1   r:   zZipArchive.__cmp__6  s'   € Ü˜%¤Ô,Ü!Ð!Ü�4—9‘9˜eŸj™jÓ)Ð)r3   c                ó   — 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"   s     r1   rR   zZipArchive.child;  s   € ô �t˜TÓ"Ð"r3   c                óH   — t        | j                  «      j                  «       S )zC
        Returns C{True} if the underlying archive exists.
        )r   r&   rY   rC   s    r1   rY   zZipArchive.existsD  s   € ô ˜×-Ñ-Ó.×5Ñ5Ó7Ð7r3   c                óH   — t        | j                  «      j                  «       S )z=
        Return the archive file's last access time.
        )r   r&   r{   rC   s    r1   r{   zZipArchive.getAccessTimeJ  s   € ô ˜×-Ñ-Ó.×<Ñ<Ó>Ð>r3   c                óH   — t        | j                  «      j                  «       S )z>
        Return the archive file's modification time.
        )r   r&   r€   rC   s    r1   r€   zZipArchive.getModificationTimeP  ó   € ô ˜×-Ñ-Ó.×BÑBÓDÐDr3   c                óH   — t        | j                  «      j                  «       S )z?
        Return the archive file's status change time.
        )r   r&   r‚   rC   s    r1   r‚   zZipArchive.getStatusChangeTimeV  r¥   r3   c                ó\   — dt         j                  j                  | j                  «      ›d�S )NzZipArchive(r<   )r*   r"   r=   rC   s    r1   rA   zZipArchive.__repr__\  s#   € ØœRŸW™WŸ_™_¨T¯Y©YÓ7Ð:¸!Ð<Ð<r3   N)rƒ   r   )r›   r   rƒ   r„   r…   )r"   r   rƒ   zZipPath[OtherAnyStr, AnyStr]rŠ   r�   rˆ   )r�   r�   r‘   r’   r“   r”   r$   r2   r:   rR   rY   r{   r€   r‚   rA   rN   r3   r1   rK   rK     sL   … ñ
ð Óàòó ðóFó<*ó
#ó8ó?óEóEô=r3   rK   )+r’   Ú
__future__r   rd   r*   r}   Útypingr   r   r   r   r   r	   r
   r   r   r   r   r]   r   Úzope.interfacer   r   r   Útwisted.python.compatr   r   Útwisted.python.filepathr   r   r   r   r   r   r(   Úbytesr‰   r   r   r   r!   rK   Ú__all__rN   r3   r1   ú<module>r¯      sØ   ðñ
õ
 #ã Û 	Û ÷÷ ÷ ñ õ å &ç  ç 1÷÷ ð €ñ �m U¨CÓ0€Ù
�)˜U CÓ
(€Ù�:Ð%8Ô9€ð ÙˆYÓôL*ˆg�g˜{Ð*Ñ+Ð-=¸gÑ-Fó L*ó ó ðL*ô^X=�˜ ˜Ñ(ô X=ðv ˜Ð
#�r3   