\bgd4*ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z dgZ dZdZejZ dZGd d ZGd d ZGd deeejZGddeZddZGddZdS)N) 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 q/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/setuptools/_vendor/zipp/__init__.py_parentsr s  IdOOQ 5 55c#K|tj}|r?|tjkr3|Vtj|\}}|r|tjk-dSdSdSdS)aR 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('')) [] N)rstrip posixpathsepsplit)r tails r r r %s ;;y} % %D +49=(( _T** d +49=((((++++((rcPtjt|j|S)zZ Return items in minuend not in subtrahend, retaining order with O(1) lookup. )r filterfalseset __contains__)minuend subtrahends r _differencer?s  Z!=w G GGrc2eZdZdZfdZdZfdZxZS)InitializedStatez? Mix-in to save the initialization state for pickling. cV||_||_tj|i|dSN)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs __class__s r r#zInitializedState.__init__Ls3  $)&)))))rc|j|jfSr)r r!r$s r __getstate__zInitializedState.__getstate__Qs{DM))rcD|\}}tj|i|dSr)r"r#)r$stater%r&r's r __setstate__zInitializedState.__setstate__Ts. f$)&)))))r)__name__ __module__ __qualname____doc__r#r*r- __classcell__r's@r rrGsj***** ************rrc8eZdZdZfdZedZxZS)SanitizedNamesz7 ZipFile mix-in to ensure names are sanitized. ctt|jtSr)listmap _sanitizer"namelistr$r's r r:zSanitizedNames.namelist^s-C(8(8(:(:;;<<>> san = SanitizedNames._sanitize >>> san('/foo/bar') 'foo/bar' >>> san('//foo.txt') 'foo.txt' >>> san('foo/.././bar.txt') 'foo/bar.txt' >>> san('foo../.bar.txt') 'foo../.bar.txt' >>> san('\\foo\\bar.txt') 'foo/bar.txt' >>> san('D:\\foo.txt') 'D/foo.txt' >>> san('\\\\server\\share\\file.txt') 'server/share/file.txt' >>> san('\\\\?\\GLOBALROOT\\Volume3') '?/GLOBALROOT/Volume3' >>> san('\\\\.\\PhysicalDrive1\\root') 'PhysicalDrive1/root' Retain any trailing slash. >>> san('abc/') 'abc/' Raises a ValueError if the result is empty. >>> san('../..') Traceback (most recent call last): ... ValueError: Empty filename c|o|dvS)N>...)parts r allowedz)SanitizedNames._sanitize..alloweds3D 3 3rz ^([A-Z]):z\1)flags\/zEmpty filename) resub IGNORECASEreplacerjoinfilter ValueErrorendswith)namerBbarecleanpartsjoineds r r9zSanitizedNames._sanitizeasP 4 4 4 vk5$bmDDD T3'' C  &%0011 /-.. .dmmC00000r)r.r/r0r1r: staticmethodr9r2r3s@r r5r5Ys]=====2121\2121212121rr5ceZdZdZedZfdZdZdZfdZ 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..s)661y}$666666r)rchain from_iterabler8r _deduper)namesparentsas_dirss r _implied_dirszCompleteDirs._implied_dirssL///He0D0DEE66g666{7E22333rct}|t||zSr)r"r:r7ra)r$r^r's r r:zCompleteDirs.namelists9  ""tD..u556666rcDt|Sr)rr:r)s r _name_setzCompleteDirs._name_sets4==??###rcP|}|dz}||vo||v}|r|n|S)zx If the name represents a directory, return that name as a directory (with the trailing slash). rE)rd)r$rNr^dirname dir_matchs r resolve_dirzCompleteDirs.resolve_dirs?   *%:'U*: #-ww-rc t|S#t$rD|dr||vrt j|cYSwxYw)z6 Supplement getinfo for implied dirs. rEfilename)r"getinfoKeyErrorrMrdzipfileZipInfo)r$rNr's r rlzCompleteDirs.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) isinstancerUrnZipFilemoder')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)rar:writestr)rurxrNs r injectzCompleteDirs.injectsE %%bkkmm44 # #D KKc " " " " r)r.r/r0r1rSrar:rdrhrl classmethodrwrnrsr|r2r3s@r rUrUs44\4 77777$$$... 2 2 2 2 2[$GO[rrUc,eZdZdZfdZfdZxZS) FastLookupzV ZipFile subclass to ensure implicit dirs exist and are resolved rapidly. ctjt5|jcdddS#1swxYwYt |_|jSr) contextlibsuppressAttributeError_FastLookup__namesr"r:r;s r r:zFastLookup.namelists   0 0  <                ww'')) | /33ctjt5|jcdddS#1swxYwYt |_|jSr)rrr_FastLookup__lookupr"rdr;s r rdzFastLookup._name_sets   0 0 ! != ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !))++ }r)r.r/r0r1r:rdr2r3s@r rrs[  rrc\tjjdk}d|z}t||||fS)Npypy)sysimplementationrNr)encodingr%r&is_pypy stack_levels r _extract_text_encodingrs2 %/Gg+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)rrwrootat)r$rrs r r#z Path.__init__es"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__rs6 > 0 0! ! 47# EH'===rc8t|j|jfSr)hashrrr)s r __hash__z Path.__hash__{sTY()))rrqNpwdcl|rt||d}|s|dkrt||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(). rrqrbz*encoding args invalid for binary operation) is_dirIsADirectoryErrorexistsFileNotFoundErrorropenrrLrio TextIOWrapper)r$rtrr%r&zip_modestreamrs r rz Path.open~s ;;== *#D)) )7{{}} *S#D)) )s;; $;; Ov O !MNNNM!7!H!H!H$B4BBB6BBBrcLtj|jp |jjSr)pathlib PurePosixPathrrrkr)s r _basez Path._bases$TW%B 0BCCCrc4|jSr)rrNr)s r rNz Path.namezz||  rc4|jSr)rsuffixr)s r rz Path.suffixszz||""rc4|jSr)rsuffixesr)s r rz Path.suffixesszz||$$rc4|jSr)rstemr)s r rz Path.stemrrcntj|jj|jSr)rrrrkjoinpathrr)s r rkz Path.filenames'|DI.//88AAArct|i|\}}}|jd|g|Ri|5}|cdddS#1swxYwYdS)Nrq)rrread)r$r%r&rstrms r read_textzPath.read_texts!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|jdkSNrE)rrfrr)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)rrMr)s r rz Path.is_dirs!7{3dg..s333rcT|o| Sr)rrr)s r is_filez Path.is_files {{}}2T[[]]!22rcB|j|jvSr)rrrdr)s r rz Path.existssw$)--////rc|stdt|j|j}t |j|S)NzCan't listdir a file)rrLr8rrr:rKr)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. )rrlr external_attrstatS_ISLNK)r$inforts r is_symlinkzPath.is_symlinks8y  ))!R'|D!!!rcL|std|tj|j}t d}tj|||zj}d|jj D}t|j t||S)NzUnacceptable pattern: rE)sepsc3$K|] }|jV dSrrj)rXdatas r rZzPath.glob..s$>>4>>>>>>r) rLrFescaperrcompile translate fullmatchrfilelistr8rrK)r$patternprefixtrmatchesr^s r globz Path.globs CAgAABB B47## S ! ! !*Vbll7&;&;;<<F>>49+=>>>4:vgu55666rc2|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)rrJrrkrr)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)rrJrrrrh)r$rnexts r rz Path.joinpaths=~dg....zz$)//55666rc|js |jjStj|jd}|r|dz }||Sr)rrkparentrrfrr)r$ parent_ats r rz Path.parentsYw (=' '%dgnnS&9&9::    Izz)$$$r)r)rq)"r.r/r0r1rr#rrrrpropertyrNrrrrkrrrrrrrrrrrrrrrr __truediv__rr@rr rrs6ddLNF    >>>***CCCCCC(DDD!!X!##X#%%X%!!X!BBXB MMM---444333000,,, BBB"""777***III;;;---777K %%X%%%rr)rrrnrrrrFrr compat.py310rrr__all__r r dictfromkeysr]rrr5rsrUrrrr@rr rs  '''''' (666&+++, -/HHH********$;1;1;1;1;1;1;1;1|HHHHH#^W_HHHV&>>>>y%y%y%y%y%y%y%y%y%y%r