RhddlZddlZddlZddlZddlZddlmZddlmZdZ GddejZ Gdd ejZ Gd d ejZGd d ejZy)N)abc)onlycRttjj|SN)iter collections OrderedDictfromkeys)itemss 2/usr/lib/python3.12/importlib/resources/readers.pyremove_duplicatesr s  ''007 88ceZdZdZdZdZy) FileReaderc`tj|jj|_yr)pathlibPathpathparent)selfloaders r __init__zFileReader.__init__sLL-44 rcJt|jj|Sz{ Return the file system path to prevent `resources.path()` from creating a temporary copy. strrjoinpathrresources r resource_pathzFileReader.resource_path 499%%h/00rc|jSrrrs r fileszFileReader.files yyrN__name__ __module__ __qualname__rr!r&rr rrs51rrc0eZdZdZfdZdZdZxZS) ZipReaderc|jd\}}}|jjdd|zdz|_|j|_y)N.\/) rpartitionprefixreplacearchive)rrmodule_names r rzZipReader.__init__!sE&&s+ 1dmm++D#6=C ~~ rcv t||S#t$r}t|jdd}~wwxYwNr)super open_resourceKeyErrorFileNotFoundErrorargs)rr exc __class__s r r=zZipReader.open_resource&s; 17(2 2 1#CHHQK0 0 1s 838c|jj|}|jxr|jS)zf Workaround for `zipfile.Path.is_file` returning true for non-existent paths. )r&ris_fileexists)rrtargets r is_resourcezZipReader.is_resource,s2 &&t,~~3FMMO3rcVtj|j|jSr)zipfilerr6r4r%s r r&zZipReader.files4s||DLL$++66r)r)r*r+rr=rGr& __classcell__rBs@r r.r. s& 1 47rr.creZdZdZdZdZdZdZdZdZ fdZ e d Z d Z ed Zd ZxZS) MultiplexedPathz Given a series of Traversable objects, implement a merged version of the interface across all objects. Useful for namespace packages which may be multihomed at a single name. ctttjt ||_|j s d}t |td|j Ds tdy)Nz.MultiplexedPath must contain at least one pathc3<K|]}|jywr)is_dir.0rs r z+MultiplexedPath.__init__..Es9T4;;=9sz)MultiplexedPath only supports directories) listmaprrr_pathsr?allNotADirectoryError)rpathsmessages r rzMultiplexedPath.__init__@sY3w||->u-EFG {{FG#G, ,9T[[99$%PQ Q:rcd|jD}tjd}tjt |||}t |jd|DS)Nc3JK|]}|jD]}|ywr)iterdir)rRrchilds r rSz*MultiplexedPath.iterdir..Is"Ndt||~NeENENs!#r9)keyc3&K|] \}}| ywrr,)rRr9locss r rSz*MultiplexedPath.iterdir..Ls!@:4$!@s)rVoperator attrgetter itertoolsgroupbysortedrU_follow)rchildrenby_namegroupss r r]zMultiplexedPath.iterdirHsPNdkkN%%f-""6(#@gN4<**K8 8 9s /AActj|d\}}} t|S#t$r% ||cYS#t$rt |cYcYSwxYwwxYw)z Construct a MultiplexedPath if needed. If children contains a sole element, return it. Otherwise, return a MultiplexedPath of the items. Unless one of the items is not a Directory, then return the first. )rdteer ValueErrorrXnext)clsrhsubdirsone_dirone_files r rgzMultiplexedPath._followbsa&/]]8Q%?"( &=  & &G}$% &H~% & &s) ' A8AA AAAct|drlrmrqs r openzMultiplexedPath.openurorc4|jdjSr;)rVr9r%s r r9zMultiplexedPath.namexs{{1~"""rcRdjd|jD}d|dS)Nz, c3(K|] }d|d yw)'Nr,rQs r rSz+MultiplexedPath.__repr__..}s>$AdV1+>szMultiplexedPath())joinrV)rrYs r __repr__zMultiplexedPath.__repr__|s) >$++>>!%**r)r)r*r+__doc__rr]rnrsrPrDr classmethodrgrpropertyr9rrJrKs@r rMrM8s_RB 999&&$9##+rrMceZdZdZdZdZy)NamespaceReaderc`dt|vr tdtt||_y)N NamespacePathz Invalid path)rr|rMrTr)rnamespace_paths r rzNamespaceReader.__init__s+ #n"5 5^, ,#T.%9: rcJt|jj|Srrrs r r!zNamespaceReader.resource_pathr"rc|jSrr$r%s r r&zNamespaceReader.filesr'rNr(r,rr rrs; 1rr)r rdrrbrIr _itertoolsrrTraversableResourcesrr. TraversablerMrr,rr rsh9 ))  7((70F+cooF+Rc..r