ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- __pycache__/__init__.cpython-312.opt-1.pyc000064400000044736152346666110014205 0ustar00 ֦il*dZddlZddlZddlZddlZddlZddlZddlZddlm Z dgZ dZ dZ e jZ dZGd d ZGd d eej$ZGd deZddZGddZy)z A Path-like interface for zipfiles. This codebase is shared between zipfile.Path in the stdlib and zipp in PyPI. See https://github.com/python/importlib_metadata/wiki/Development-Methodology for more detail. N) translatePathcBtjt|ddS)a2 Given a path with elements separated by posixpath.sep, generate all parents of that path. >>> list(_parents('b/d')) ['b'] >>> list(_parents('/b/d/')) ['/b'] >>> list(_parents('b/d/f/')) ['b/d', 'b'] >>> list(_parents('b')) [] >>> list(_parents('')) [] rN) itertoolsislice _ancestry)paths //usr/lib64/python3.12/zipfile/_path/__init__.py_parentsr s   IdOQ 55c#K|jtj}|jtjr=|tj|\}}|jtjr>> list(_ancestry('b/d')) ['b/d', 'b'] >>> list(_ancestry('/b/d/')) ['/b/d', '/b'] >>> list(_ancestry('b/d/f/')) ['b/d/f', 'b/d', 'b'] >>> list(_ancestry('b')) ['b'] >>> list(_ancestry('')) [] Multiple separators are treated like a single. >>> list(_ancestry('//b//d///f//')) ['//b//d///f', '//b//d', '//b'] N)rstrip posixpathsepsplit)r tails r r r +sS* ;;y}} %D ++imm $ __T* d ++imm $s A:A?=A?cTtjt|j|S)zZ Return items in minuend not in subtrahend, retaining order with O(1) lookup. )r filterfalseset __contains__)minuend subtrahends r _differencerJs!  Z!=!=w GGr c2eZdZdZfdZdZfdZxZS)InitializedStatez? Mix-in to save the initialization state for pickling. c@||_||_t| |i|yN)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs __class__s r r"zInitializedState.__init__Ws#   $)&)r c2|j|jfSr)rr r#s r __getstate__zInitializedState.__getstate__\s{{DMM))r c.|\}}t||i|yr)r!r")r#stater$r%r&s r __setstate__zInitializedState.__setstate___s f $)&)r )__name__ __module__ __qualname____doc__r"r)r, __classcell__r&s@r rrRs* ***r rcXeZdZdZedZfdZdZdZfdZ e dZ xZ S) CompleteDirsa8 A ZipFile subclass that ensures that implied directories are always included in the namelist. >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt'])) ['foo/', 'foo/bar/'] >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/'])) ['foo/'] ctjjtt|}d|D}t t ||S)Nc3BK|]}|tjzywr)rr).0ps r z-CompleteDirs._implied_dirs..rs6g1y}}$gs)rchain from_iterablemapr _deduper)namesparentsas_dirss r _implied_dirszCompleteDirs._implied_dirsos9////He0DE6g6{7E233r cZt|}|t|j|zSr)r!namelistlistrA)r#r>r&s r rCzCompleteDirs.namelistus+ "tD..u5666r c4t|jSr)rrCr(s r _name_setzCompleteDirs._name_setys4==?##r cL|j}|dz}||vxr||v}|r|S|S)zx If the name represents a directory, return that name as a directory (with the trailing slash). /)rF)r#namer>dirname dir_matchs r resolve_dirzCompleteDirs.resolve_dir|s:  *%:'U*: #w--r c t||S#t$r=|jdr||j vrt j |cYSwxYw)z6 Supplement getinfo for implied dirs. rH)filename)r!getinfoKeyErrorendswithrFzipfileZipInfo)r#rIr&s r rOzCompleteDirs.getinfosR 27?4( ( 2==%T^^5E)E??D1 1 2sAAAct|tr|St|tjs||Sd|jvrt}||_|S)zl Given a source (filename or zipfile), return an appropriate CompleteDirs subclass. r) isinstancer4rRZipFilemoder&)clssources r makezCompleteDirs.makesK fl +M&'//2v;  fkk !C r ) r-r.r/r0 staticmethodrArCrFrLrO classmethodr[r1r2s@r r4r4dsD44 7$. 2r r4c,eZdZdZfdZfdZxZS) FastLookupzV ZipFile subclass to ensure implicit dirs exist and are resolved rapidly. ctjt5|jcdddS#1swYnxYwt||_|jSr) contextlibsuppressAttributeError_FastLookup__namesr!rCr#r&s r rCzFastLookup.namelists=   0<<1 0 0w') || 1:ctjt5|jcdddS#1swYnxYwt||_|jSr)rarbrc_FastLookup__lookupr!rFres r rFzFastLookup._name_sets=   0==1 0 0)+ }}rf)r-r.r/r0rCrFr1r2s@r r_r_s  r r_c4tj|d||fS)N)io text_encoding)encodingr$r%s r _extract_text_encodingrns  Ha ($ 66r ceZdZdZdZd dZdZdZd!dddZd Z e d Z e d Z e d Z e d Ze dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZeZ e dZ!y)"ru A :class:`importlib.resources.abc.Traversable` interface for zip files. Implements many of the features users enjoy from :class:`pathlib.Path`. Consider a zip file with this structure:: . ├── a.txt └── b ├── c.txt └── d └── e.txt >>> data = io.BytesIO() >>> zf = ZipFile(data, 'w') >>> zf.writestr('a.txt', 'content of a') >>> zf.writestr('b/c.txt', 'content of c') >>> zf.writestr('b/d/e.txt', 'content of e') >>> zf.filename = 'mem/abcde.zip' Path accepts the zipfile object itself or a filename >>> root = Path(zf) From there, several path operations are available. Directory iteration (including the zip file itself): >>> a, b = root.iterdir() >>> a Path('mem/abcde.zip', 'a.txt') >>> b Path('mem/abcde.zip', 'b/') name property: >>> b.name 'b' join with divide operator: >>> c = b / 'c.txt' >>> c Path('mem/abcde.zip', 'b/c.txt') >>> c.name 'c.txt' Read text: >>> c.read_text(encoding='utf-8') 'content of c' existence: >>> c.exists() True >>> (b / 'missing.txt').exists() False Coercion to string: >>> import os >>> str(c).replace(os.sep, posixpath.sep) 'mem/abcde.zip/b/c.txt' At the root, ``name``, ``filename``, and ``parent`` resolve to the zipfile. Note these attributes are not valid and will raise a ``ValueError`` if the zipfile has no filename. >>> root.name 'abcde.zip' >>> str(root.filename).replace(os.sep, posixpath.sep) 'mem/abcde.zip' >>> str(root.parent) 'mem' z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})cFtj||_||_y)aX Construct a Path from a ZipFile or filename. Note: When the source is an existing ZipFile object, its type (__class__) will be mutated to a specialized type. If the caller wishes to retain the original type, the caller should either create a separate ZipFile object or pass a filename. N)r_r[rootat)r#rqrrs r r"z Path.__init__sOOD) r c|j|jurtS|j|jf|j|jfk(S)zU >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo' False )r&NotImplementedrqrr)r#others r __eq__z Path.__eq__s? >> 0! ! 477# EHH'===r cDt|j|jfSr)hashrqrrr(s r __hash__z Path.__hash__&sTYY())r NpwdcN|jr t||d}|dk(r|js t||jj |j ||}d|vr|s|r td|St|i|\}}}tj||g|i|S)z Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper(). rrUrzbz*encoding args invalid for binary operation) is_dirIsADirectoryErrorexistsFileNotFoundErrorrqopenrr ValueErrorrnrk TextIOWrapper)r#rXr{r$r%zip_modestreamrms r rz Path.open)s ;;=#D) )7 s?4;;=#D) )s; $;v !MNNM!7!H!H$B4B6BBr cptj|jxs|jjSr)pathlib PurePosixPathrrrqrNr(s r _basez Path._base=s&$$TWW%B 0B0BCCr c6|jjSr)rrIr(s r rIz Path.name@zz|   r c6|jjSr)rsuffixr(s r rz Path.suffixDszz|"""r c6|jjSr)rsuffixesr(s r rz Path.suffixesHszz|$$$r c6|jjSr)rstemr(s r rz Path.stemLrr ctj|jjj |j Sr)rrrqrNjoinpathrrr(s r rNz Path.filenamePs*||DII../88AAr ct|i|\}}}|jd|g|i|5}|jcdddS#1swYyxYw)NrU)rnrread)r#r$r%rmstrms r read_textzPath.read_textTsI!7!H!H$ TYYsH 6t 6v 6$99;7 6 6s AA cp|jd5}|jcdddS#1swYyxYw)Nrb)rr)r#rs r read_byteszPath.read_bytesYs" YYt_99;__s,5ctj|jjd|jjdk(SNrH)rrJrrr)r#r s r _is_childzPath._is_child]s2  !459LLLr c:|j|j|Sr)r&rq)r#rrs r _nextz Path._next`s~~dii,,r cV|j xs|jjdSr)rrrQr(s r r~z Path.is_dircs"77{3dgg..s33r cH|jxr|j Sr)rr~r(s r is_filez Path.is_filefs{{}2T[[]!22r cN|j|jjvSr)rrrqrFr(s r rz Path.existsisww$))--///r c|js tdt|j|jj }t |j|S)NzCan't listdir a file)r~rr<rrqrCfilterr)r#subss r iterdirz Path.iterdirlsE{{}34 44::tyy1134dnnd++r c^tj|jj|Sr)rrrrmatch)r# path_patterns r rz Path.matchrs"$$TWW-33LAAr cy)z] Return whether this path is a symlink. Always false (python/cpython#82102). Fr(s r is_symlinkzPath.is_symlinkusr c&|std|tj|j}tj|t |zj }t|jt||jjS)NzUnacceptable pattern: ) rreescaperrcompiler fullmatchr<rrrqrC)r#patternprefixmatchess r globz Path.glob{sm5g[AB B477#**Vi&889CC4::vgtyy/A/A/CDEEr c*|jd|S)Nz**/)r)r#rs r rglobz Path.rglobsyy3wi))r cltjt|t|j|Sr)rrelpathstrr)r#ruextras r relative_tozPath.relative_tos)  TC0F,GHHr cjtj|jj|jSr)rjoinrqrNrrr(s r __str__z Path.__str__s!~~dii00$''::r c:|jj|S)Nr() _Path__reprformatr(s r __repr__z Path.__repr__s{{!!t!,,r ctj|jg|}|j|jj |Sr)rrrrrrqrL)r#runexts r rz Path.joinpaths7~~dgg..zz$))//566r c|js|jjStj|jj d}|r|dz }|j |Sr)rrrNparentrrJrr)r# parent_ats r rz Path.parentsRww=='' '%%dggnnS&9:   Izz)$$r ))rU)"r-r.r/r0rr"rvryrrpropertyrIrrrrNrrrrr~rrrrrrrrrrr __truediv__rrr r rrsN`NF >*CC(D!!##%%!!BB M-430, B F*I;-7K %%r r)r0rkrrRrrarrrr__all__r r dictfromkeysr=rrrWr4r_rnrrr r rs   (6&+6 --/H**$>#W__>B&7 _%_%r __pycache__/glob.cpython-312.opt-2.pyc000064400000002555152346666110013363 0ustar00 ֦i*ddlZdZdZdZdZdZy)Nc*tt|S)N) match_dirstranslate_corepatterns +/usr/lib64/python3.12/zipfile/_path/glob.py translater s nW- ..c |dS)Nz[/]?rs rrrs it r cT djttt|S)N)joinmapreplaceseparaters rrrs$  773w 12 33r c0 tjd|S)Nz+([^\[]+)|(?P[\[].*?[\]])|([\[][^\]]*$))refinditerrs rrrs ;;Ew OOr c |jdxsTtj|jdjddjddjddS) Nsetrz\*\*z.*z\*z[^/]*z\?.)grouprescaper)matchs rrr+sW ;;u   %++a.! 5 !  !   r )rr rrrrr r rrs" / 4 P r __pycache__/glob.cpython-312.pyc000064400000003643152346666110012422 0ustar00 ֦i*ddlZdZdZdZdZdZy)Nc*tt|S)N) match_dirstranslate_corepatterns +/usr/lib64/python3.12/zipfile/_path/glob.py translater s nW- ..c |dS)zx Ensure that zipfile.Path directory names are matched. zipfile.Path directory names always end in a slash. z[/]?rs rrrs it r cRdjttt|S)z Given a glob pattern, produce a regex that matches it. >>> translate('*.txt') '[^/]*\\.txt' >>> translate('a?txt') 'a.txt' >>> translate('**/*') '.*/[^/]*' )joinmapreplaceseparaters rrrs 773w 12 33r c.tjd|S)z Separate out character sets to avoid translating their contents. >>> [m.group(0) for m in separate('*.txt')] ['*.txt'] >>> [m.group(0) for m in separate('a[?]txt')] ['a', '[?]', 'txt'] z+([^\[]+)|(?P[\[].*?[\]])|([\[][^\]]*$))refinditerrs rrrs ;;Ew OOr c|jdxsTtj|jdjddjddjddS) zE Perform the replacements for a match from :func:`separate`. setrz\*\*z.*z\*z[^/]*z\?.)grouprescaper)matchs rrr+sR ;;u   %++a.! 5 !  !   r )rr rrrrr r rrs" / 4 P r __pycache__/__init__.cpython-312.opt-2.pyc000064400000034545152346666110014203 0ustar00 ֦il* ddlZddlZddlZddlZddlZddlZddlZddlmZdgZ dZ dZ e jZ dZGdd ZGd d eej"ZGd d eZddZGddZy)N) translatePathcD tjt|ddS)Nr) itertoolsislice _ancestry)paths //usr/lib64/python3.12/zipfile/_path/__init__.py_parentsr s"   IdOQ 55c#K |jtj}|jtjr=|tj|\}}|jtjrBcV tjt|j|Sr)r filterfalseset __contains__)minuend subtrahends r _differencerJs&  Z!=!=w GGr c0eZdZ fdZdZfdZxZS)InitializedStatec@||_||_t| |i|yr)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs __class__s r r"zInitializedState.__init__Ws#   $)&)r c2|j|jfSr)rr r#s r __getstate__zInitializedState.__getstate__\s{{DMM))r c.|\}}t||i|yr)r!r")r#stater$r%r&s r __setstate__zInitializedState.__setstate___s f $)&)r )__name__ __module__ __qualname__r"r)r, __classcell__r&s@r rrRs* ***r rcVeZdZ edZfdZdZdZfdZe dZ xZ S) CompleteDirsctjjtt|}d|D}t t ||S)Nc3BK|]}|tjzywr)rr).0ps r z-CompleteDirs._implied_dirs..rs6g1y}}$gs)rchain from_iterablemapr _deduper)namesparentsas_dirss r _implied_dirszCompleteDirs._implied_dirsos9////He0DE6g6{7E233r cZt|}|t|j|zSr)r!namelistlistr@)r#r=r&s r rBzCompleteDirs.namelistus+ "tD..u5666r c4t|jSr)rrBr(s r _name_setzCompleteDirs._name_setys4==?##r cN |j}|dz}||vxr||v}|r|S|SN/)rE)r#namer=dirname dir_matchs r resolve_dirzCompleteDirs.resolve_dir|s?  *%:'U*: #w--r c t||S#t$r=|jdr||j vrt j |cYSwxYw)NrH)filename)r!getinfoKeyErrorendswithrEzipfileZipInfo)r#rIr&s r rOzCompleteDirs.getinfosW  27?4( ( 2==%T^^5E)E??D1 1 2sAAAc t|tr|St|tjs||Sd|jvrt}||_|SNr) isinstancer3rRZipFilemoder&)clssources r makezCompleteDirs.makesP  fl +M&'//2v;  fkk !C r ) r-r.r/ staticmethodr@rBrErLrO classmethodr\r0r1s@r r3r3dsD44 7$. 2r r3c*eZdZ fdZfdZxZS) FastLookupctjt5|jcdddS#1swYnxYwt||_|jSr) contextlibsuppressAttributeError_FastLookup__namesr!rBr#r&s r rBzFastLookup.namelists=   0<<1 0 0w') || 1:ctjt5|jcdddS#1swYnxYwt||_|jSr)rbrcrd_FastLookup__lookupr!rErfs r rEzFastLookup._name_sets=   0==1 0 0)+ }}rg)r-r.r/rBrEr0r1s@r r`r`s  r r`c4tj|d||fS)N)io text_encoding)encodingr$r%s r _extract_text_encodingros  Ha ($ 66r ceZdZ dZddZdZdZd dddZdZe d Z e d Z e d Z e d Z e d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZeZe dZ y)!rz>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})cH tj||_||_yr)r`r\rootat)r#rrrss r r"z Path.__init__s  OOD) r c |j|jurtS|j|jf|j|jfk(Sr)r&NotImplementedrrrs)r#others r __eq__z Path.__eq__sD  >> 0! ! 477# EHH'===r cDt|j|jfSr)hashrrrsr(s r __hash__z Path.__hash__&sTYY())r NpwdcP |jr t||d}|dk(r|js t||jj |j ||}d|vr|s|r td|St|i|\}}}tj||g|i|S)NrrVr{bz*encoding args invalid for binary operation) is_dirIsADirectoryErrorexistsFileNotFoundErrorrropenrs ValueErrorrorl TextIOWrapper)r#rYr|r$r%zip_modestreamrns r rz Path.open)s ;;=#D) )7 s?4;;=#D) )s; $;v !MNNM!7!H!H$B4B6BBr cptj|jxs|jjSr)pathlib PurePosixPathrsrrrNr(s r _basez Path._base=s&$$TWW%B 0B0BCCr c6|jjSr)rrIr(s r rIz Path.name@zz|   r c6|jjSr)rsuffixr(s r rz Path.suffixDszz|"""r c6|jjSr)rsuffixesr(s r rz Path.suffixesHszz|$$$r c6|jjSr)rstemr(s r rz Path.stemLrr ctj|jjj |j Sr)rrrrrNjoinpathrsr(s r rNz Path.filenamePs*||DII../88AAr ct|i|\}}}|jd|g|i|5}|jcdddS#1swYyxYwrU)rorread)r#r$r%rnstrms r read_textzPath.read_textTsI!7!H!H$ TYYsH 6t 6v 6$99;7 6 6s AA cp|jd5}|jcdddS#1swYyxYw)Nrb)rr)r#rs r read_byteszPath.read_bytesYs" YYt_99;__s,5ctj|jjd|jjdk(SrG)rrJrsr)r#r s r _is_childzPath._is_child]s2  !459LLLr c:|j|j|Sr)r&rr)r#rss r _nextz Path._next`s~~dii,,r cV|j xs|jjdSrG)rsrQr(s r rz Path.is_dircs"77{3dgg..s33r cH|jxr|j Sr)rrr(s r is_filez Path.is_filefs{{}2T[[]!22r cN|j|jjvSr)rsrrrEr(s r rz Path.existsisww$))--///r c|js tdt|j|jj }t |j|S)NzCan't listdir a file)rrr;rrrrBfilterr)r#subss r iterdirz Path.iterdirlsE{{}34 44::tyy1134dnnd++r c^tj|jj|Sr)rrrsmatch)r# path_patterns r rz Path.matchrs"$$TWW-33LAAr c y)NFr(s r is_symlinkzPath.is_symlinkus  r c&|std|tj|j}tj|t |zj }t|jt||jjS)NzUnacceptable pattern: ) rreescaperscompiler fullmatchr;rrrrrB)r#patternprefixmatchess r globz Path.glob{sm5g[AB B477#**Vi&889CC4::vgtyy/A/A/CDEEr c*|jd|S)Nz**/)r)r#rs r rglobz Path.rglobsyy3wi))r cltjt|t|j|Sr)rrelpathstrr)r#rvextras r relative_tozPath.relative_tos)  TC0F,GHHr cjtj|jj|jSr)rjoinrrrNrsr(s r __str__z Path.__str__s!~~dii00$''::r c:|jj|S)Nr() _Path__reprformatr(s r __repr__z Path.__repr__s{{!!t!,,r ctj|jg|}|j|jj |Sr)rrrsrrrrL)r#rvnexts r rz Path.joinpaths7~~dgg..zz$))//566r c|js|jjStj|jj d}|r|dz }|j |SrG)rsrNparentrrJrr)r# parent_ats r rz Path.parentsRww=='' '%%dggnnS&9:   Izz)$$r ))rV)!r-r.r/rr"rwrzrrpropertyrIrrrrNrrrrrrrrrrrrrrrr __truediv__rrr r rrsN`NF >*CC(D!!##%%!!BB M-430, B F*I;-7K %%r r)rlrrRrrbrrrr__all__r r dictfromkeysr<rrrXr3r`rorrr r rs   (6&+6 --/H**$>#W__>B&7 _%_%r __pycache__/glob.cpython-312.opt-1.pyc000064400000003643152346666110013361 0ustar00 ֦i*ddlZdZdZdZdZdZy)Nc*tt|S)N) match_dirstranslate_corepatterns +/usr/lib64/python3.12/zipfile/_path/glob.py translater s nW- ..c |dS)zx Ensure that zipfile.Path directory names are matched. zipfile.Path directory names always end in a slash. z[/]?rs rrrs it r cRdjttt|S)z Given a glob pattern, produce a regex that matches it. >>> translate('*.txt') '[^/]*\\.txt' >>> translate('a?txt') 'a.txt' >>> translate('**/*') '.*/[^/]*' )joinmapreplaceseparaters rrrs 773w 12 33r c.tjd|S)z Separate out character sets to avoid translating their contents. >>> [m.group(0) for m in separate('*.txt')] ['*.txt'] >>> [m.group(0) for m in separate('a[?]txt')] ['a', '[?]', 'txt'] z+([^\[]+)|(?P[\[].*?[\]])|([\[][^\]]*$))refinditerrs rrrs ;;Ew OOr c|jdxsTtj|jdjddjddjddS) zE Perform the replacements for a match from :func:`separate`. setrz\*\*z.*z\*z[^/]*z\?.)grouprescaper)matchs rrr+sR ;;u   %++a.! 5 !  !   r )rr rrrrr r rrs" / 4 P r __pycache__/__init__.cpython-312.pyc000064400000044736152346666110013246 0ustar00 ֦il*dZddlZddlZddlZddlZddlZddlZddlZddlm Z dgZ dZ dZ e jZ dZGd d ZGd d eej$ZGd deZddZGddZy)z A Path-like interface for zipfiles. This codebase is shared between zipfile.Path in the stdlib and zipp in PyPI. See https://github.com/python/importlib_metadata/wiki/Development-Methodology for more detail. N) translatePathcBtjt|ddS)a2 Given a path with elements separated by posixpath.sep, generate all parents of that path. >>> list(_parents('b/d')) ['b'] >>> list(_parents('/b/d/')) ['/b'] >>> list(_parents('b/d/f/')) ['b/d', 'b'] >>> list(_parents('b')) [] >>> list(_parents('')) [] rN) itertoolsislice _ancestry)paths //usr/lib64/python3.12/zipfile/_path/__init__.py_parentsr s   IdOQ 55c#K|jtj}|jtjr=|tj|\}}|jtjr>> list(_ancestry('b/d')) ['b/d', 'b'] >>> list(_ancestry('/b/d/')) ['/b/d', '/b'] >>> list(_ancestry('b/d/f/')) ['b/d/f', 'b/d', 'b'] >>> list(_ancestry('b')) ['b'] >>> list(_ancestry('')) [] Multiple separators are treated like a single. >>> list(_ancestry('//b//d///f//')) ['//b//d///f', '//b//d', '//b'] N)rstrip posixpathsepsplit)r tails r r r +sS* ;;y}} %D ++imm $ __T* d ++imm $s A:A?=A?cTtjt|j|S)zZ Return items in minuend not in subtrahend, retaining order with O(1) lookup. )r filterfalseset __contains__)minuend subtrahends r _differencerJs!  Z!=!=w GGr c2eZdZdZfdZdZfdZxZS)InitializedStatez? Mix-in to save the initialization state for pickling. c@||_||_t| |i|yN)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs __class__s r r"zInitializedState.__init__Ws#   $)&)r c2|j|jfSr)rr r#s r __getstate__zInitializedState.__getstate__\s{{DMM))r c.|\}}t||i|yr)r!r")r#stater$r%r&s r __setstate__zInitializedState.__setstate___s f $)&)r )__name__ __module__ __qualname____doc__r"r)r, __classcell__r&s@r rrRs* ***r rcXeZdZdZedZfdZdZdZfdZ e dZ xZ S) CompleteDirsa8 A ZipFile subclass that ensures that implied directories are always included in the namelist. >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt'])) ['foo/', 'foo/bar/'] >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/'])) ['foo/'] ctjjtt|}d|D}t t ||S)Nc3BK|]}|tjzywr)rr).0ps r z-CompleteDirs._implied_dirs..rs6g1y}}$gs)rchain from_iterablemapr _deduper)namesparentsas_dirss r _implied_dirszCompleteDirs._implied_dirsos9////He0DE6g6{7E233r cZt|}|t|j|zSr)r!namelistlistrA)r#r>r&s r rCzCompleteDirs.namelistus+ "tD..u5666r c4t|jSr)rrCr(s r _name_setzCompleteDirs._name_setys4==?##r cL|j}|dz}||vxr||v}|r|S|S)zx If the name represents a directory, return that name as a directory (with the trailing slash). /)rF)r#namer>dirname dir_matchs r resolve_dirzCompleteDirs.resolve_dir|s:  *%:'U*: #w--r c t||S#t$r=|jdr||j vrt j |cYSwxYw)z6 Supplement getinfo for implied dirs. rH)filename)r!getinfoKeyErrorendswithrFzipfileZipInfo)r#rIr&s r rOzCompleteDirs.getinfosR 27?4( ( 2==%T^^5E)E??D1 1 2sAAAct|tr|St|tjs||Sd|jvrt}||_|S)zl Given a source (filename or zipfile), return an appropriate CompleteDirs subclass. r) isinstancer4rRZipFilemoder&)clssources r makezCompleteDirs.makesK fl +M&'//2v;  fkk !C r ) r-r.r/r0 staticmethodrArCrFrLrO classmethodr[r1r2s@r r4r4dsD44 7$. 2r r4c,eZdZdZfdZfdZxZS) FastLookupzV ZipFile subclass to ensure implicit dirs exist and are resolved rapidly. ctjt5|jcdddS#1swYnxYwt||_|jSr) contextlibsuppressAttributeError_FastLookup__namesr!rCr#r&s r rCzFastLookup.namelists=   0<<1 0 0w') || 1:ctjt5|jcdddS#1swYnxYwt||_|jSr)rarbrc_FastLookup__lookupr!rFres r rFzFastLookup._name_sets=   0==1 0 0)+ }}rf)r-r.r/r0rCrFr1r2s@r r_r_s  r r_c4tj|d||fS)N)io text_encoding)encodingr$r%s r _extract_text_encodingrns  Ha ($ 66r ceZdZdZdZd dZdZdZd!dddZd Z e d Z e d Z e d Z e d Ze dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZeZ e dZ!y)"ru A :class:`importlib.resources.abc.Traversable` interface for zip files. Implements many of the features users enjoy from :class:`pathlib.Path`. Consider a zip file with this structure:: . ├── a.txt └── b ├── c.txt └── d └── e.txt >>> data = io.BytesIO() >>> zf = ZipFile(data, 'w') >>> zf.writestr('a.txt', 'content of a') >>> zf.writestr('b/c.txt', 'content of c') >>> zf.writestr('b/d/e.txt', 'content of e') >>> zf.filename = 'mem/abcde.zip' Path accepts the zipfile object itself or a filename >>> root = Path(zf) From there, several path operations are available. Directory iteration (including the zip file itself): >>> a, b = root.iterdir() >>> a Path('mem/abcde.zip', 'a.txt') >>> b Path('mem/abcde.zip', 'b/') name property: >>> b.name 'b' join with divide operator: >>> c = b / 'c.txt' >>> c Path('mem/abcde.zip', 'b/c.txt') >>> c.name 'c.txt' Read text: >>> c.read_text(encoding='utf-8') 'content of c' existence: >>> c.exists() True >>> (b / 'missing.txt').exists() False Coercion to string: >>> import os >>> str(c).replace(os.sep, posixpath.sep) 'mem/abcde.zip/b/c.txt' At the root, ``name``, ``filename``, and ``parent`` resolve to the zipfile. Note these attributes are not valid and will raise a ``ValueError`` if the zipfile has no filename. >>> root.name 'abcde.zip' >>> str(root.filename).replace(os.sep, posixpath.sep) 'mem/abcde.zip' >>> str(root.parent) 'mem' z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})cFtj||_||_y)aX Construct a Path from a ZipFile or filename. Note: When the source is an existing ZipFile object, its type (__class__) will be mutated to a specialized type. If the caller wishes to retain the original type, the caller should either create a separate ZipFile object or pass a filename. N)r_r[rootat)r#rqrrs r r"z Path.__init__sOOD) r c|j|jurtS|j|jf|j|jfk(S)zU >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo' False )r&NotImplementedrqrr)r#others r __eq__z Path.__eq__s? >> 0! ! 477# EHH'===r cDt|j|jfSr)hashrqrrr(s r __hash__z Path.__hash__&sTYY())r NpwdcN|jr t||d}|dk(r|js t||jj |j ||}d|vr|s|r td|St|i|\}}}tj||g|i|S)z Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper(). rrUrzbz*encoding args invalid for binary operation) is_dirIsADirectoryErrorexistsFileNotFoundErrorrqopenrr ValueErrorrnrk TextIOWrapper)r#rXr{r$r%zip_modestreamrms r rz Path.open)s ;;=#D) )7 s?4;;=#D) )s; $;v !MNNM!7!H!H$B4B6BBr cptj|jxs|jjSr)pathlib PurePosixPathrrrqrNr(s r _basez Path._base=s&$$TWW%B 0B0BCCr c6|jjSr)rrIr(s r rIz Path.name@zz|   r c6|jjSr)rsuffixr(s r rz Path.suffixDszz|"""r c6|jjSr)rsuffixesr(s r rz Path.suffixesHszz|$$$r c6|jjSr)rstemr(s r rz Path.stemLrr ctj|jjj |j Sr)rrrqrNjoinpathrrr(s r rNz Path.filenamePs*||DII../88AAr ct|i|\}}}|jd|g|i|5}|jcdddS#1swYyxYw)NrU)rnrread)r#r$r%rmstrms r read_textzPath.read_textTsI!7!H!H$ TYYsH 6t 6v 6$99;7 6 6s AA cp|jd5}|jcdddS#1swYyxYw)Nrb)rr)r#rs r read_byteszPath.read_bytesYs" YYt_99;__s,5ctj|jjd|jjdk(SNrH)rrJrrr)r#r s r _is_childzPath._is_child]s2  !459LLLr c:|j|j|Sr)r&rq)r#rrs r _nextz Path._next`s~~dii,,r cV|j xs|jjdSr)rrrQr(s r r~z Path.is_dircs"77{3dgg..s33r cH|jxr|j Sr)rr~r(s r is_filez Path.is_filefs{{}2T[[]!22r cN|j|jjvSr)rrrqrFr(s r rz Path.existsisww$))--///r c|js tdt|j|jj }t |j|S)NzCan't listdir a file)r~rr<rrqrCfilterr)r#subss r iterdirz Path.iterdirlsE{{}34 44::tyy1134dnnd++r c^tj|jj|Sr)rrrrmatch)r# path_patterns r rz Path.matchrs"$$TWW-33LAAr cy)z] Return whether this path is a symlink. Always false (python/cpython#82102). Fr(s r is_symlinkzPath.is_symlinkusr c&|std|tj|j}tj|t |zj }t|jt||jjS)NzUnacceptable pattern: ) rreescaperrcompiler fullmatchr<rrrqrC)r#patternprefixmatchess r globz Path.glob{sm5g[AB B477#**Vi&889CC4::vgtyy/A/A/CDEEr c*|jd|S)Nz**/)r)r#rs r rglobz Path.rglobsyy3wi))r cltjt|t|j|Sr)rrelpathstrr)r#ruextras r relative_tozPath.relative_tos)  TC0F,GHHr cjtj|jj|jSr)rjoinrqrNrrr(s r __str__z Path.__str__s!~~dii00$''::r c:|jj|S)Nr() _Path__reprformatr(s r __repr__z Path.__repr__s{{!!t!,,r ctj|jg|}|j|jj |Sr)rrrrrrqrL)r#runexts r rz Path.joinpaths7~~dgg..zz$))//566r c|js|jjStj|jj d}|r|dz }|j |Sr)rrrNparentrrJrr)r# parent_ats r rz Path.parentsRww=='' '%%dggnnS&9:   Izz)$$r ))rU)"r-r.r/r0rr"rvryrrpropertyrIrrrrNrrrrr~rrrrrrrrrrr __truediv__rrr r rrsN`NF >*CC(D!!##%%!!BB M-430, B F*I;-7K %%r r)r0rkrrRrrarrrr__all__r r dictfromkeysr=rrrWr4r_rnrrr r rs   (6&+6 --/H**$>#W__>B&7 _%_%r glob.py000064400000002206152346666110006053 0ustar00import re def translate(pattern): return match_dirs(translate_core(pattern)) def match_dirs(pattern): """ Ensure that zipfile.Path directory names are matched. zipfile.Path directory names always end in a slash. """ return rf'{pattern}[/]?' def translate_core(pattern): r""" Given a glob pattern, produce a regex that matches it. >>> translate('*.txt') '[^/]*\\.txt' >>> translate('a?txt') 'a.txt' >>> translate('**/*') '.*/[^/]*' """ return ''.join(map(replace, separate(pattern))) def separate(pattern): """ Separate out character sets to avoid translating their contents. >>> [m.group(0) for m in separate('*.txt')] ['*.txt'] >>> [m.group(0) for m in separate('a[?]txt')] ['a', '[?]', 'txt'] """ return re.finditer(r'([^\[]+)|(?P[\[].*?[\]])|([\[][^\]]*$)', pattern) def replace(match): """ Perform the replacements for a match from :func:`separate`. """ return match.group('set') or ( re.escape(match.group(0)) .replace('\\*\\*', r'.*') .replace('\\*', r'[^/]*') .replace('\\?', r'.') ) __init__.py000064400000025154152346666110006676 0ustar00""" A Path-like interface for zipfiles. This codebase is shared between zipfile.Path in the stdlib and zipp in PyPI. See https://github.com/python/importlib_metadata/wiki/Development-Methodology for more detail. """ import io import posixpath import zipfile import itertools import contextlib import pathlib import re from .glob import translate __all__ = ['Path'] def _parents(path): """ Given a path with elements separated by posixpath.sep, generate all parents of that path. >>> list(_parents('b/d')) ['b'] >>> list(_parents('/b/d/')) ['/b'] >>> list(_parents('b/d/f/')) ['b/d', 'b'] >>> list(_parents('b')) [] >>> list(_parents('')) [] """ return itertools.islice(_ancestry(path), 1, None) def _ancestry(path): """ Given a path with elements separated by posixpath.sep, generate all elements of that path. >>> list(_ancestry('b/d')) ['b/d', 'b'] >>> list(_ancestry('/b/d/')) ['/b/d', '/b'] >>> list(_ancestry('b/d/f/')) ['b/d/f', 'b/d', 'b'] >>> list(_ancestry('b')) ['b'] >>> list(_ancestry('')) [] Multiple separators are treated like a single. >>> list(_ancestry('//b//d///f//')) ['//b//d///f', '//b//d', '//b'] """ path = path.rstrip(posixpath.sep) while path.rstrip(posixpath.sep): yield path path, tail = posixpath.split(path) _dedupe = dict.fromkeys """Deduplicate an iterable in original order""" def _difference(minuend, subtrahend): """ Return items in minuend not in subtrahend, retaining order with O(1) lookup. """ return itertools.filterfalse(set(subtrahend).__contains__, minuend) class InitializedState: """ Mix-in to save the initialization state for pickling. """ def __init__(self, *args, **kwargs): self.__args = args self.__kwargs = kwargs super().__init__(*args, **kwargs) def __getstate__(self): return self.__args, self.__kwargs def __setstate__(self, state): args, kwargs = state super().__init__(*args, **kwargs) class CompleteDirs(InitializedState, zipfile.ZipFile): """ A ZipFile subclass that ensures that implied directories are always included in the namelist. >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt'])) ['foo/', 'foo/bar/'] >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/'])) ['foo/'] """ @staticmethod def _implied_dirs(names): parents = itertools.chain.from_iterable(map(_parents, names)) as_dirs = (p + posixpath.sep for p in parents) return _dedupe(_difference(as_dirs, names)) def namelist(self): names = super().namelist() return names + list(self._implied_dirs(names)) def _name_set(self): return set(self.namelist()) def resolve_dir(self, name): """ If the name represents a directory, return that name as a directory (with the trailing slash). """ names = self._name_set() dirname = name + '/' dir_match = name not in names and dirname in names return dirname if dir_match else name def getinfo(self, name): """ Supplement getinfo for implied dirs. """ try: return super().getinfo(name) except KeyError: if not name.endswith('/') or name not in self._name_set(): raise return zipfile.ZipInfo(filename=name) @classmethod def make(cls, source): """ Given a source (filename or zipfile), return an appropriate CompleteDirs subclass. """ if isinstance(source, CompleteDirs): return source if not isinstance(source, zipfile.ZipFile): return cls(source) # Only allow for FastLookup when supplied zipfile is read-only if 'r' not in source.mode: cls = CompleteDirs source.__class__ = cls return source class FastLookup(CompleteDirs): """ ZipFile subclass to ensure implicit dirs exist and are resolved rapidly. """ def namelist(self): with contextlib.suppress(AttributeError): return self.__names self.__names = super().namelist() return self.__names def _name_set(self): with contextlib.suppress(AttributeError): return self.__lookup self.__lookup = super()._name_set() return self.__lookup def _extract_text_encoding(encoding=None, *args, **kwargs): # stacklevel=3 so that the caller of the caller see any warning. return io.text_encoding(encoding, 3), args, kwargs class Path: """ A :class:`importlib.resources.abc.Traversable` interface for zip files. Implements many of the features users enjoy from :class:`pathlib.Path`. Consider a zip file with this structure:: . ├── a.txt └── b ├── c.txt └── d └── e.txt >>> data = io.BytesIO() >>> zf = ZipFile(data, 'w') >>> zf.writestr('a.txt', 'content of a') >>> zf.writestr('b/c.txt', 'content of c') >>> zf.writestr('b/d/e.txt', 'content of e') >>> zf.filename = 'mem/abcde.zip' Path accepts the zipfile object itself or a filename >>> root = Path(zf) From there, several path operations are available. Directory iteration (including the zip file itself): >>> a, b = root.iterdir() >>> a Path('mem/abcde.zip', 'a.txt') >>> b Path('mem/abcde.zip', 'b/') name property: >>> b.name 'b' join with divide operator: >>> c = b / 'c.txt' >>> c Path('mem/abcde.zip', 'b/c.txt') >>> c.name 'c.txt' Read text: >>> c.read_text(encoding='utf-8') 'content of c' existence: >>> c.exists() True >>> (b / 'missing.txt').exists() False Coercion to string: >>> import os >>> str(c).replace(os.sep, posixpath.sep) 'mem/abcde.zip/b/c.txt' At the root, ``name``, ``filename``, and ``parent`` resolve to the zipfile. Note these attributes are not valid and will raise a ``ValueError`` if the zipfile has no filename. >>> root.name 'abcde.zip' >>> str(root.filename).replace(os.sep, posixpath.sep) 'mem/abcde.zip' >>> str(root.parent) 'mem' """ __repr = "{self.__class__.__name__}({self.root.filename!r}, {self.at!r})" def __init__(self, root, at=""): """ Construct a Path from a ZipFile or filename. Note: When the source is an existing ZipFile object, its type (__class__) will be mutated to a specialized type. If the caller wishes to retain the original type, the caller should either create a separate ZipFile object or pass a filename. """ self.root = FastLookup.make(root) self.at = at def __eq__(self, other): """ >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo' False """ if self.__class__ is not other.__class__: return NotImplemented return (self.root, self.at) == (other.root, other.at) def __hash__(self): return hash((self.root, self.at)) def open(self, mode='r', *args, pwd=None, **kwargs): """ Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper(). """ if self.is_dir(): raise IsADirectoryError(self) zip_mode = mode[0] if zip_mode == 'r' and not self.exists(): raise FileNotFoundError(self) stream = self.root.open(self.at, zip_mode, pwd=pwd) if 'b' in mode: if args or kwargs: raise ValueError("encoding args invalid for binary operation") return stream # Text mode: encoding, args, kwargs = _extract_text_encoding(*args, **kwargs) return io.TextIOWrapper(stream, encoding, *args, **kwargs) def _base(self): return pathlib.PurePosixPath(self.at or self.root.filename) @property def name(self): return self._base().name @property def suffix(self): return self._base().suffix @property def suffixes(self): return self._base().suffixes @property def stem(self): return self._base().stem @property def filename(self): return pathlib.Path(self.root.filename).joinpath(self.at) def read_text(self, *args, **kwargs): encoding, args, kwargs = _extract_text_encoding(*args, **kwargs) with self.open('r', encoding, *args, **kwargs) as strm: return strm.read() def read_bytes(self): with self.open('rb') as strm: return strm.read() def _is_child(self, path): return posixpath.dirname(path.at.rstrip("/")) == self.at.rstrip("/") def _next(self, at): return self.__class__(self.root, at) def is_dir(self): return not self.at or self.at.endswith("/") def is_file(self): return self.exists() and not self.is_dir() def exists(self): return self.at in self.root._name_set() def iterdir(self): if not self.is_dir(): raise ValueError("Can't listdir a file") subs = map(self._next, self.root.namelist()) return filter(self._is_child, subs) def match(self, path_pattern): return pathlib.PurePosixPath(self.at).match(path_pattern) def is_symlink(self): """ Return whether this path is a symlink. Always false (python/cpython#82102). """ return False def glob(self, pattern): if not pattern: raise ValueError(f"Unacceptable pattern: {pattern!r}") prefix = re.escape(self.at) matches = re.compile(prefix + translate(pattern)).fullmatch return map(self._next, filter(matches, self.root.namelist())) def rglob(self, pattern): return self.glob(f'**/{pattern}') def relative_to(self, other, *extra): return posixpath.relpath(str(self), str(other.joinpath(*extra))) def __str__(self): return posixpath.join(self.root.filename, self.at) def __repr__(self): return self.__repr.format(self=self) def joinpath(self, *other): next = posixpath.join(self.at, *other) return self._next(self.root.resolve_dir(next)) __truediv__ = joinpath @property def parent(self): if not self.at: return self.filename.parent parent_at = posixpath.dirname(self.at.rstrip('/')) if parent_at: parent_at += '/' return self._next(parent_at)