1j.dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZdgZdZd ZejZ d ZGd d ZGd dee jZGddeZddZGddZdS)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)save_method_args) text_encoding) TranslatorPathcHtjt|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 r/builddir/build/BUILD/cloudlinux-venv-1.0.11/venv/lib/python3.11/site-packages/setuptools/_vendor/zipp/__init__.py_parentsrs  IdOOQ 5 55c#K|tj}|tjr<|Vtj|\}}|tj:dSdS)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 .sy* ;;y} % %D ++im $ $+ _T** d ++im $ $+++++rcPtjt|j|S)zZ Return items in minuend not in subtrahend, retaining order with O(1) lookup. )r filterfalseset __contains__)minuend subtrahends r _differencerMs  Z!=w G GGrcBeZdZdZefdZdZfdZxZS)InitializedStatez? Mix-in to save the initialization state for pickling. c:tj|i|dSNsuper__init__)selfargskwargs __class__s r r#zInitializedState.__init__Zs%$)&)))))rc2|jj|jjfSr )_saved___init__r%r&r$s r __getstate__zInitializedState.__getstate__^s#($*>*EEErcD|\}}tj|i|dSr r!)r$stater%r&r's r __setstate__zInitializedState.__setstate__as. f$)&)))))r) __name__ __module__ __qualname____doc__rr#r+r. __classcell__r's@r rrUsz*****FFF*********rrceZdZdZedZfdZdZdZfdZ e dZ e de j d e j fd ZxZS) 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/'] ctjtt|}d|D}t t ||S)Nc34K|]}|tjzVdSr )rr).0ps r z-CompleteDirs._implied_dirs..ts)661y}$666666r)r chain from_iterablemapr_deduper)namesparentsas_dirss r _implied_dirszCompleteDirs._implied_dirsqsL///He0D0DEE66g666{7E22333rct}|t||zSr )r"namelistlistrC)r$r@r's r rEzCompleteDirs.namelistws9  ""tD..u556666rcDt|Sr )rrEr*s r _name_setzCompleteDirs._name_set{s4==??###rcP|}|dz}||vo||v}|r|n|S)zx If the name represents a directory, return that name as a directory (with the trailing slash). /)rH)r$namer@dirname dir_matchs r resolve_dirzCompleteDirs.resolve_dir~s?   *%:'U*: #-ww-rc t|S#t$rD|dr||vrt j|cYSwxYw)z6 Supplement getinfo for implied dirs. rJ)filename)r"getinfoKeyErrorendswithrHzipfileZipInfo)r$rKr's r rQzCompleteDirs.getinfos} 277??4(( ( 2 2 2==%% T^^5E5E)E)E?D111 1 1 1 2s $A A21A2ct|tr|St|tjs ||Sd|jvrt}||_|S)zl Given a source (filename or zipfile), return an appropriate CompleteDirs subclass. r) isinstancer6rTZipFilemoder')clssources r makezCompleteDirs.makes^ fl + + M&'/22 3v;;  fk ! !C rzfreturnc||D]}||d|S)z Given a writable zip file zf, inject directory entries for any directories implied by the presence of children. r)rCrEwritestr)r[r^rKs r injectzCompleteDirs.injectsE %%bkkmm44 # #D KKc " " " " r)r/r0r1r2 staticmethodrCrErHrNrQ classmethodr]rTrYrbr3r4s@r r6r6fs44\4 77777$$$... 2 2 2 2 2[$GO[rr6cleZdZdZdZejfdZdZejfdZ xZ S) FastLookupzV ZipFile subclass to ensure implicit dirs exist and are resolved rapidly. c|jSr ) _namelistr*s r rEzFastLookup.namelists ~rcDtSr )r"rEr$r's r rhzFastLookup._namelistsww!!!rc|jSr )_name_set_propr*s r rHzFastLookup._name_sets ""rcDtSr )r"rHrjs r rlzFastLookup._name_set_propsww  """r) r/r0r1r2rE functoolscached_propertyrhrHrlr3r4s@r rfrfs """""############rrfctjjdk}|otjdk}d|z}t ||||fS)Npypy)rs)sysimplementationrKpypy_version_infor)encodingr%r&is_pypy is_old_pypi stack_levels r _extract_text_encodingr|sF %/G@c3j@Kk/K ; / /v ==rc&eZdZdZdZd"dZdZdZd#dd d Zd Z e d Z e d Z e dZ e dZe dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd ZeZ e d!Z!dS)$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.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})cRt||_||_dS)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)rfr]rootat)r$rrs r r#z Path.__init__9s"OOD)) rch|j|jurtS|j|jf|j|jfkS)zU >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo' False )r'NotImplementedrr)r$others r __eq__z Path.__eq__Fs6 > 0 0! ! 47# EH'===rc8t|j|jfSr )hashrrr*s r __hash__z Path.__hash__OsTY()))rrWNpwdcl|rt||d}|dkr#|st||j|j||}d|vr|s|rtd|St|i|\}}}tj ||g|Ri|S)z Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper(). rrWrbz*encoding args invalid for binary operation) is_dirIsADirectoryErrorexistsFileNotFoundErrorropenr ValueErrorr|io TextIOWrapper)r$rZrr%r&zip_modestreamrxs r rz Path.openRs ;;== *#D)) )7 s??4;;==?#D)) )s;; $;; Ov O !MNNNM!7!H!H!H$B4BBB6BBBrcP|jrtj|jn|jSr )rpathlib PurePosixPathrPr*s r _basez Path._basefs#15Kw$TW---dmKrc4|jSr )rrKr*s r rKz Path.nameizz||  rc4|jSr )rsuffixr*s r rz Path.suffixmszz||""rc4|jSr )rsuffixesr*s r rz Path.suffixesqszz||$$rc4|jSr )rstemr*s r rz Path.stemurrcntj|jj|jSr )rrrrPjoinpathrr*s r rPz Path.filenameys'|DI.//88AAArct|i|\}}}|jd|g|Ri|5}|cdddS#1swxYwYdS)NrW)r|rread)r$r%r&rxstrms r read_textzPath.read_text}s!7!H!H!H$ TYsH 6t 6 6 6v 6 6 $99;;                  sAA Ac|d5}|cdddS#1swxYwYdS)Nrb)rr)r$rs r read_byteszPath.read_bytess~ YYt__ 99;;                  s 7;;ctj|jd|jdkSNrJ)rrLrr)r$r s r _is_childzPath._is_childs4 !4!4559L9LLLrc8||j|Sr )r'r)r$rs r _nextz Path._nexts~~di,,,rcF|j p|jdSr)rrSr*s r rz Path.is_dirs!7{3dg..s333rcT|o| Sr )rrr*s r is_filez Path.is_files {{}}2T[[]]!22rcB|j|jvSr )rrrHr*s r rz Path.existssw$)--////rc|stdt|j|j}t |j|S)NzCan't listdir a file)rrr>rrrEfilterr)r$subss r iterdirz Path.iterdirsR{{}} 5344 44:ty113344dnd+++rcZtj|j|Sr )rrrmatch)r$ path_patterns r rz Path.matchs#$TW--33LAAArc||j|j}|jdz }t j|S)z8 Return whether this path is a symlink. )rrQr external_attrstatS_ISLNK)r$inforZs r is_symlinkzPath.is_symlinks8y  ))!R'|D!!!rcN|std|tj|j}t d}tj|||zj}t|j t||j S)NzUnacceptable pattern: rJ)seps) rreescaperrcompile translate fullmatchr>rrrrE)r$patternprefixtrmatchess r globz Path.globs CAgAABB B47## S ! ! !*Vbll7&;&;;<<F4:vgty/A/A/C/CDDEEErc2|d|S)Nz**/)r)r$rs r rglobz Path.rglobsyyw)))rcptjt|t|j|Sr )rrelpathstrr)r$rextras r relative_tozPath.relative_tos, TC0F,G,GHHHrcJtj|jj|jSr )rjoinrrPrr*s r __str__z Path.__str__s~di0$':::rc8|j|S)Nr*) _Path__reprformatr*s r __repr__z Path.__repr__s{!!t!,,,rctj|jg|R}||j|Sr )rrrrrrN)r$rnexts r rz Path.joinpaths=~dg....zz$)//55666rc|js |jjStj|jd}|r|dz }||Sr)rrPparentrrLrr)r$ parent_ats r rz Path.parentsYw (=' '%dgnnS&9&9::    Izz)$$$r)r~)rW)"r/r0r1r2rr#rrrrpropertyrKrrrrPrrrrrrrrrrrrrrrr __truediv__rrr rrs9ddLNF    >>>***CCCCCC(LLL!!X!##X#%%X%!!X!BBXB MMM---444333000,,, BBB"""FFF***III;;;---777K %%X%%%rr )r2rnrr rrrrrurT _functoolsr compat.py310rrr__all__rr dictfromkeysr?rrrYr6rfr|rrrr rs  (((((('''''' (666&+++6 -/HHH********"HHHHH#W_HHHV########*>>>>x%x%x%x%x%x%x%x%x%x%r