Ϫf/ hdZddlmZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z mZmZmZmZddlmZddlmZddlmZmZddlmZmZdd lmZmZmZmZm Z m!Z!d Z"ed e#e$Z%ed e#e$Z&ed dZ'eeeGdde e&e%fee&Z(Gdde(e e fZ)ddgZ*y)zt This module contains implementations of L{IFilePath} for zip files. See the constructor of L{ZipArchive} for use. ) annotationsN) IO TYPE_CHECKINGAnyAnyStrDictGenericIterableListTupleTypeVarUnion)ZipFile) implementer)LiteralSelf)cmp comparable)AbstractFilePathFilePath IFilePath OtherAnyStrUnlistableError_coerceToFilesystemEncoding/ _ArchiveStr_ZipStr_ZipSelfzZipPath[Any, Any])boundceZdZUdZded< ddZddZddZeddZ d dZ d!d Z e r d"d Z d#d Zd#d Zd$d Zd$dZd$dZd$dZd%dZd&dZddZddZd'd(dZd)dZd*dZd+dZd+dZd+dZy),ZipPathzF I represent a file or directory contained within a zip file. rpathc&||_||_t|j||_t|t }t||j}|jj |}tjj|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_SEPsplitosr"join)selfr$r%separchiveFilenamesegmentsfakePaths 8/usr/lib/python3/dist-packages/twisted/python/zippath.py__init__zZipPath.__init__=s18 &31L  $ $m2 ! *-F#> 733$ #'"4"4":":3"?GGLLD8D% ct|tstSt|j|j f|j|j fSN) isinstancer!NotImplementedrr$r%r,others r1__cmp__zZipPath.__cmp__WsB%)! ! \\4-- .@S@S0T  r3clt|jtjj |j jg}|j |jj|jt|jtj}d|j|dS)NzZipPath()) rr-r*r"abspathr$extendr%r)r+)r,partsosseps r1__repr__zZipPath.__repr__^s ("''//$,,BSBS2T U   T''--dhh78+DHHbff=%**U+.a00r3c6t|jtS)z Return a zip directory separator. @return: The zip directory separator. @returntype: The same type as C{self.path}. )rr"r(r,s r1r-z ZipPath.sepgs+499lCCr3c|jj|j}t|dk(r |jSt |j|jj |ddS)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 _nativeParentzZipPath._nativeParentqsX$$**4884 w<1 << t||TXX]]73B<%@AAr3c|j}t|tr3tt|j|j j S|Sr5)rIr6 ZipArchiverr"r$r&)r,parents r1rLzZipPath.parent}sF##% fj )+DIIt||7T7TU  r3cyr5rCs r1parentszZipPath.parentss r3ct|t}t||j}t|j|j ||gS)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. )rr(r%r!r$r+)r,r"joinerr%s r1childz ZipPath.childsA-T<@3D$:L:LM t||V[[-1F%GHHr3c|j}t|tr |jn|}|j |}|Sr5)rLr6rKr$rR)r,r"rLrightTypedParentrRs r1siblingzZipPath.siblings9+5fj+I4<* 1!1" y1"~6.,.DMM&)/0 f%e,  1 1"EF Fr3cnt|tstSt|j|jSr5)r6rKr7rr"r8s r1r:zZipArchive.__cmp__6s'%,! !499ejj))r3ct||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 r1rRzZipArchive.child;stT""r3cHt|jjS)zC Returns C{True} if the underlying archive exists. )rr&rYrCs r1rYzZipArchive.existsDs--.5577r3cHt|jjS)z= Return the archive file's last access time. )rr&r{rCs r1r{zZipArchive.getAccessTimeJs--.<<>>r3cHt|jjS)z> Return the archive file's modification time. )rr&rrCs r1rzZipArchive.getModificationTimeP--.BBDDr3cHt|jjS)z? Return the archive file's status change time. )rr&rrCs r1rzZipArchive.getStatusChangeTimeVrr3c\dtjj|jdS)Nz ZipArchive(r<)r*r"r=rCs r1rAzZipArchive.__repr__\s#RWW__TYY7:!<rs  #     & 1 mUC0 )UC ( :%8 9  YL*gg{*+-=g-FL* L*^X=(X=v  #r3