
    h/              	      b   S r SSKJr  SSKrSSKrSSKrSSKJrJrJ	r	J
r
JrJrJrJrJrJrJr  SSKJr  SSKJr  SSKJrJr  SSKJrJr  SS	KJrJrJrJ r J!r!J"r"  S
r#\" S\$\%5      r&\" S\$\%5      r'\" SSS9r(\\" \5       " S S\\'\&4   \\'   5      5       5       r) " S S\)\
\
4   5      r*SS/r+g)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                  :   \ rS rSr% SrS\S'         SS jrSS jrS S jr\	S!S j5       r
  S"S	 jrS#S
 jr\(       a    S$S jrS%S jrS%S jrS&S jrS&S jrS&S jrS&S jrS'S jrS(S jrS!S jrS!S jrS)S*S jjrS+S jrS,S jrS-S jrS-S jrS-S jrSrg).ZipPath4   z>
I represent a file or directory contained within a zip file.
r   pathc                    Xl         X l        [        UR                  U5      U l        [        U[
        5      n[        X!R                  5      nU R                  R                  U5      n[        R                  R                  " U/UQ76 nX`l        g)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          ]/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/zippath.py__init__ZipPath.__init__=   s|     18&31L$$m2
! *-F#>33$
 #'"4"4":":3"?GGLLD8D%	    c                    [        U[        5      (       d  [        $ [        U R                  U R
                  4UR                  UR
                  45      $ N)
isinstancer!   NotImplementedr   r%   r&   r-   others     r2   __cmp__ZipPath.__cmp__W   sE    %))!!\\4--.@S@S0T
 	
r5   c                n   [        U R                  [        R                  R	                  U R
                  R                  5      5      /nUR                  U R                  R                  U R                  5      5        [        U R                  [        R                  5      nSUR                  U5      < S3$ )NzZipPath())
r   r.   r+   r#   abspathr%   extendr&   r*   r,   )r-   partsosseps      r2   __repr__ZipPath.__repr__^   s     ("''//$,,BSBS2TU
 	T''--dhh78+DHHbff=%**U+.a00r5   c                6    [        U R                  [        5      $ )zv
Return a zip directory separator.

@return: The zip directory separator.
@returntype: The same type as C{self.path}.
)r   r#   r)   r-   s    r2   r.   ZipPath.sepg   s     +499lCCr5   c                    U R                   R                  U R                  5      n[        U5      S:X  a  U R                  $ [        U R                  U R                  R                  USS 5      5      $ )zS
Return parent, discarding our own encoding in favor of whatever the
archive's is.
   N)r&   r*   r.   lenr%   r!   r,   )r-   splitups     r2   _nativeParentZipPath._nativeParentq   sX     $$**4884w<1<<t||TXX]]73B<%@AAr5   c                    U R                  5       n[        U[        5      (       a3  [        [        U R                  U R
                  R                  5      5      $ U$ r7   )rN   r8   
ZipArchiver   r#   r%   r'   )r-   parents     r2   rR   ZipPath.parent}   sI    ##%fj))+DIIt||7T7TU  r5   c                    g r7    rG   s    r2   parentsZipPath.parents   s     r5   c                    [        U[        5      n[        XR                  5      n[        U R                  UR                  X1/5      5      $ )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       r2   childZipPath.child   s=     -T<@3D:L:LMt||V[[-1F%GHHr5   c                    U R                  5       n[        U[        5      (       a  U R                  OUnUR	                  U5      nU$ r7   )rR   r8   rQ   r%   rZ   )r-   r#   rR   rightTypedParentrZ   s        r2   siblingZipPath.sibling   s<     +5fj+I+I4<<v3C3I3I$3Or5   c                P    U R                  5       =(       d    U R                  5       $ r7   )isdirisfilerG   s    r2   existsZipPath.exists   s    zz|,t{{},r5   c                H    U R                   U R                  R                  ;   $ r7   )r&   r%   childmaprG   s    r2   ra   ZipPath.isdir   s    !!T\\%:%:::r5   c                \    U R                   U R                  R                  R                  ;   $ r7   )r&   r%   zipfile
NameToInforG   s    r2   rb   ZipPath.isfile   s#    !!T\\%9%9%D%DDDr5   c                    g)NFrU   rG   s    r2   islinkZipPath.islink   s    r5   c                   U R                  5       (       a  U R                  5       (       av  [        U R                  R                  U R
                  5      nU R                  R                  U   R                  5        Vs/ s H  n[        U R                  U5      PM     sn$ [        [        [        R                  S5      5      e[        [        [        R                  S5      5      es  snf )NzLeaf zip entry listedzNon-existent zip entry listed)rc   ra   r   r%   r'   r&   rf   keysr#   r   OSErrorerrnoENOTDIRENOENT)r-   parentArchivePatheachs      r2   listdirZipPath.listdir   s    ;;==zz||1LLL1143E3E2!
 !% 5 56G H M M O O 0		4@ O 
 &gemm=T&UVV!&EF s   > C'c                T    [         R                  R                  U R                  5      $ )zA
Return a value similar to that returned by C{os.path.splitext}.
)r+   r#   splitextrG   s    r2   rz   ZipPath.splitext   s     ww		**r5   c                R    U R                   R                  U R                  5      S   $ )NrK   )r&   r*   r.   rG   s    r2   basenameZipPath.basename   s"    !!''1"55r5   c                6    U R                  5       R                  $ r7   )rR   r#   rG   s    r2   dirnameZipPath.dirname   s     {{}!!!r5   c                t    [        SU R                  5      nU R                  R                  R	                  X!S9$ )N )mode)r   r&   r%   ri   open)r-   r   r&   s      r2   r   ZipPath.open   s4     4B8J8JK||##(((BBr5   c                    g r7   rU   rG   s    r2   changedZipPath.changed   s    r5   c                    [        SU R                  5      nU R                  R                  R                  U   R
                  $ )z:
Retrieve this file's size.

@return: file size, in bytes
r   )r   r&   r%   ri   rj   	file_sizer-   r&   s     r2   getsizeZipPath.getsize   s7     4B8J8JK||##..}=GGGr5   c                6    U R                   R                  5       $ )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%   getAccessTimerG   s    r2   r   ZipPath.getAccessTime   s     ||))++r5   c                    [        SU R                  5      n[        R                  " U R                  R
                  R                  U   R                  S-   5      $ )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   )r   r   r   )r   r&   timemktimer%   ri   rj   	date_timer   s     r2   getModificationTimeZipPath.getModificationTime   sJ     4B8J8JK{{LL  ++M:DDyP
 	
r5   c                "    U R                  5       $ )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   rG   s    r2   getStatusChangeTimeZipPath.getStatusChangeTime   s     ''))r5   )r(   r%   r#   r&   N)r%   zZipArchive[_ArchiveStr]r&   r   returnNoner;   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)r   zLiteral['r', 'w']r   z	IO[bytes])r   r   )r   r   r   float) __name__
__module____qualname____firstlineno____doc____annotations__r3   r<   rD   propertyr.   rN   rR   r   rV   rZ   r^   rc   ra   rb   rm   rw   rz   r}   r   r   r   r   r   r   r   __static_attributes__rU   r5   r2   r!   r!   4   s     M&.&?F&	&4
1 D D
B	F
B 	P	
I -;E"+6"
CH,

*r5   r!   c                      \ rS rSr% SrS\S'   \SS j5       rSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSrg)rQ   i  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                    U $ r7   rU   rG   s    r2   r%   ZipArchive.archive  s    r5   c                j   Xl         [        [        SU5      5      U l        U R                  R                  nUc   S5       e[        X5      U l        [        US5      U l        0 U l        U R                  R                  5        H  n[        U R                   U5      R                  U R                  5      n[        [        U5      5       HW  nXE*    nU R                  R                  USU*  5      nXpR                  ;  a  0 U R                  U'   SU R                  U   U'   MY     [        US5      nM     g)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   Nz7zipfile must have filename when initialized with a pathrJ   )r#   r   r   ri   filenamer'   r&   rf   namelistr*   r.   rangerL   r,   )r-   archivePathnamezfnamename	splitNamexrZ   rR   s           r2   r3   ZipArchive.__init__  s    $	:2OP&&	ED	E ;O T8"M :<LL))+D3DIItDJJ488TI3y>*!"y1"~6.,.DMM&)/0f%e, + 1"EF ,r5   c                x    [        U[        5      (       d  [        $ [        U R                  UR                  5      $ r7   )r8   rQ   r9   r   r#   r:   s     r2   r<   ZipArchive.__cmp__6  s*    %,,!!499ejj))r5   c                    [        X5      $ )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     r2   rZ   ZipArchive.child;  s     t""r5   c                H    [        U R                  5      R                  5       $ )z3
Returns C{True} if the underlying archive exists.
)r   r'   rc   rG   s    r2   rc   ZipArchive.existsD  s     --.5577r5   c                H    [        U R                  5      R                  5       $ )z-
Return the archive file's last access time.
)r   r'   r   rG   s    r2   r   ZipArchive.getAccessTimeJ  s     --.<<>>r5   c                H    [        U R                  5      R                  5       $ )z.
Return the archive file's modification time.
)r   r'   r   rG   s    r2   r   ZipArchive.getModificationTimeP       --.BBDDr5   c                H    [        U R                  5      R                  5       $ )z/
Return the archive file's status change time.
)r   r'   r   rG   s    r2   r   ZipArchive.getStatusChangeTimeV  r   r5   c                ^    S[         R                  R                  U R                  5      < S3$ )NzZipArchive(r?   )r+   r#   r@   rG   s    r2   rD   ZipArchive.__repr__\  s#    RWW__TYY7:!<<r5   )r'   rf   r#   r&   ri   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   r%   r3   r<   rZ   rc   r   r   r   rD   r   rU   r5   r2   rQ   rQ     sL    
  F<*
#8?EE=r5   rQ   ),r   
__future__r   rr   r+   r   typingr   r   r   r   r   r	   r
   r   r   r   r   ri   r   zope.interfacer   typing_extensionsr   r   twisted.python.compatr   r   twisted.python.filepathr   r   r   r   r   r   r)   bytesr   r   r   r   r!   rQ   __all__rU   r5   r2   <module>r      s   

 #  	      & + 1   mUC0
)UC
(:%89 YL*gg{*+-=g-F L*  L*^X=( X=v 
#r5   