@,bi.SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK r SSK J r S/r Sr Sr\R rSr"S S 5r"S S \\ R(5r"S S\5rSSjr"SS5rg)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) TranslatorPathcD[R"[U5SS5$)z 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 =/opt/alt/python313/lib64/python3.13/zipfile/_path/__init__.py_parentsr s   IdOQ 55c## UR[R5nUR[R5(aCUv [R"U5upUR[R5(aMBgg7f)a 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'] N)rstrip posixpathsepsplit)r tails r r r ,sV* ;;y}} %D ++imm $ $ __T*  ++imm $ $s BB B cV[R"[U5RU5$)zN Return items in minuend not in subtrahend, retaining order with O(1) lookup. )r filterfalseset __contains__)minuend subtrahends r _differencerKs!  Z!=!=w GGr c>^\rSrSrSrU4SjrSrU4SjrSrU=r $)InitializedStateSz7 Mix-in to save the initialization state for pickling. c>>XlX l[TU] "U0UD6 gN)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs __class__s r r#InitializedState.__init__Xs   $)&)r c2URUR4$r)r r!r$s r __getstate__InitializedState.__getstate__]s{{DMM))r c.>Uup#[TU]"U0UD6 gr)r"r#)r$stater%r&r's r __setstate__InitializedState.__setstate__`s  $)&)r )__args__kwargs) __name__ __module__ __qualname____firstlineno____doc__r#r+r/__static_attributes__ __classcell__r's@r rrSs* ***r rc^\rSrSrSr\S5rU4SjrSrSr U4Sjr \ S5r \ S \ RS \ R4S j5rS rU=r$) CompleteDirsea 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/'] c[RR[[U55nSU5n[ [ X 55$)Nc3F# UHo[R-v M g7fr)rr).0ps r -CompleteDirs._implied_dirs..ss6gy}}$gs!)rchain from_iterablemapr _deduper)namesparentsas_dirss r _implied_dirsCompleteDirs._implied_dirsps7////He0DE6g6{7233r cZ>[TU]5nU[URU55-$r)r"namelistlistrK)r$rHr's r rNCompleteDirs.namelistvs+ "tD..u5666r c4[UR55$r)rrNr*s r _name_setCompleteDirs._name_setzs4==?##r c`UR5nUS-nX;=(a X2;nU(aU$U$)z` If the name represents a directory, return that name as a directory (with the trailing slash). /)rR)r$namerHdirname dir_matchs r resolve_dirCompleteDirs.resolve_dir}s6  *%:'*: #w--r c>[TU]U5$![aA URS5(aXR 5;ae[ R "US9s$f=f)z& Supplement getinfo for implied dirs. rU)filename)r"getinfoKeyErrorendswithrRzipfileZipInfo)r$rVr's r r]CompleteDirs.getinfosS 27?4( ( 2==%%^^5E)E??D1 1 2sAAAc[U[5(aU$[U[R5(dU"U5$SUR;a[nXlU$)zT Given a source (filename or zipfile), return an appropriate CompleteDirs subclass. r) isinstancer<r`ZipFilemoder')clssources r makeCompleteDirs.makesO fl + +M&'//22v;  fkk !C r zfreturncvURUR55HnURUS5 M U$)zq Given a writable zip file zf, inject directory entries for any directories implied by the presence of children. r )rKrNwritestr)rhrlrVs r injectCompleteDirs.injects2 %%bkkm4D KKc "5 r )r3r4r5r6r7 staticmethodrKrNrRrYr] classmethodrjr`rfrpr8r9r:s@r r<r<esn44 7$. 2$GOOr r<c8^\rSrSrSrU4SjrU4SjrSrU=r$) FastLookupzJ ZipFile subclass to ensure implicit dirs exist and are resolved rapidly. c>[R"[5 URsSSS5 $!,(df  O=f[TU]5UlUR$r) contextlibsuppressAttributeError_FastLookup__namesr"rNr$r's r rNFastLookup.namelists=   0<<1 0 0w') || 2 Ac>[R"[5 URsSSS5 $!,(df  O=f[TU]5UlUR$r)ryrzr{_FastLookup__lookupr"rRr}s r rRFastLookup._name_sets=   0==1 0 0)+ }}r)__lookup__names) r3r4r5r6r7rNrRr8r9r:s@r rvrvs  r rvc[RRS:HnU=(a [RS:nSU-n[R "X5X4$)Npypy)r)sysimplementationrVpypy_version_infoio text_encoding)encodingr%r&is_pypy is_old_pypi stack_levels r _extract_text_encodingrsN  %%/G@c33j@Kk/K  H 2D @@r c\rSrSrSrSrS"SjrSrSrS#SS.S jjr S r \ S 5r \ S 5r \ S 5r\ S5r\ S5rSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSr \ r!\ S 5r"S!r#g)$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 >>> path = Path(zf) From there, several path operations are available. Directory iteration (including the zip file itself): >>> a, b = path.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. >>> str(path) 'mem/abcde.zip/' >>> path.name 'abcde.zip' >>> path.filename == pathlib.Path('mem/abcde.zip') True >>> str(path.parent) 'mem' If the zipfile has no filename, such attributes are not valid and accessing them will raise an Exception. >>> zf.filename = None >>> path.name Traceback (most recent call last): ... TypeError: ... >>> path.filename Traceback (most recent call last): ... TypeError: ... >>> path.parent Traceback (most recent call last): ... TypeError: ... # workaround python/cpython#106763 >>> pass z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})cD[RU5UlX lg)a  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)rvrjrootat)r$rrs r r# Path.__init__5sOOD) r cURURLa[$URUR4URUR4:H$)z= >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo' False )r'NotImplementedrr)r$others r __eq__ Path.__eq__Bs? >> 0! ! 477# EHH'===r cD[URUR45$r)hashrrr*s r __hash__ Path.__hash__KsTYY())r NpwdcrUR5(a [U5eUSnUS:Xa UR5(d [U5eURR UR XRS9nSU;aU(dU(a [S5eU$[U0UD6upsn[R"Xg/UQ70UD6$)z Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper(). rrdrbz*encoding args invalid for binary operation) is_dirIsADirectoryErrorexistsFileNotFoundErrorropenr ValueErrorrr TextIOWrapper)r$rgrr%r&zip_modestreamrs r r Path.openNs ;;==#D) )7 s?4;;==#D) ); $;v !MNNM!7!H!HB4B6BBr c|UR(a [R"UR5$UR$r)rpathlib PurePosixPathr\r*s r _base Path._basebs&15w$$TWW-KdmmKr c6UR5R$r)rrVr*s r rV Path.nameezz|   r c6UR5R$r)rsuffixr*s r r Path.suffixiszz|"""r c6UR5R$r)rsuffixesr*s r r Path.suffixesmszz|$$$r c6UR5R$r)rstemr*s r r Path.stemqrr c[R"URR5R UR 5$r)rrrr\joinpathrr*s r r\ Path.filenameus*||DII../88AAr c[U0UD6up1nUR"SU/UQ70UD6nUR5sSSS5 $!,(df  g=f)Nrd)rrread)r$r%r&rstrms r read_textPath.read_textysE!7!H!H YYsH 6t 6v 6$99;7 6 6s A AczURS5nUR5sSSS5 $!,(df  g=f)Nrb)rr)r$rs r read_bytesPath.read_bytes~s" YYt_99;__s, :c[R"URRS55URRS5:H$NrU)rrWrr)r$r s r _is_childPath._is_childs2  !459LLLr c:URURU5$r)r'r)r$rs r _next Path._nexts~~dii,,r chUR(+=(d URRS5$r)rr_r*s r r Path.is_dirs"77{3dgg..s33r cZUR5=(a UR5(+$r)rrr*s r is_file Path.is_files{{}2T[[]!22r cPURURR5;$r)rrrRr*s r r Path.existssww$))--///r cUR5(d [S5e[URURR 55n[ URU5$)NzCan't listdir a file)rrrFrrrNfilterr)r$subss r iterdir Path.iterdirsG{{}}34 44::tyy1134dnnd++r c`[R"UR5RU5$r)rrrmatch)r$ path_patterns r r Path.matchs"$$TWW-33LAAr cURRUR5nURS- n[R "U5$)z( Return whether this path is a symlink. )rr]r external_attrstatS_ISLNK)r$inforgs r is_symlinkPath.is_symlinks;yy  )!!R'||D!!r cPU(d[SU<35e[R"UR5n[ SS9n[R "X#R U5-5Rn[UR[X@RR555$)NzUnacceptable pattern: rU)seps) rreescaperrcompile translate fullmatchrFrrrrN)r$patternprefixtrmatchess r glob Path.globsw5g[AB B477# S !**Vll7&;;<FF4::vgyy/A/A/CDEEr c*URSU35$)Nz**/)r)r$rs r rglob Path.rglobsyy3wi))r cn[R"[U5[UR"U655$r)rrelpathstrr)r$rextras r relative_toPath.relative_tos'  TC0F,GHHr cl[R"URRUR5$r)rjoinrr\rr*s r __str__ Path.__str__s!~~dii00$''::r c4URRUS9$)Nr*) _Path__reprformatr*s r __repr__ Path.__repr__s{{!!t!,,r c[R"UR/UQ76nURURR U55$r)rrrrrrY)r$rnexts r r Path.joinpaths7~~dgg..zz$))//566r cUR(dURR$[R"URR S55nU(aUS- nUR U5$r)rr\parentrrWrr)r$ parent_ats r r Path.parentsRww=='' '%%dggnnS&9:   Izz)$$r )rr))rd)$r3r4r5r6r7rr#rrrrpropertyrVrrrr\rrrrrrrrrrrrrrr r __truediv__rr8rrr r rrsdLNF >*CC(L!!##%%!!BB M-430, B"F*I;-7K %%r r)r7ryrrrrrrrr`rr__all__r r dictfromkeysrGrrrfr<rvrrrrr r rs   (6&+6 --/H**$H#W__HV$Ax%x%r