WccszddlmZddlmZddlmZGddZGddZdd ZGd d Z d Z dS)i)suppress) TextIOWrapper)abccs$eZdZdZdfdZdZdS)SpecLoaderAdapterz> Adapt a package spec to adapt the underlying loader. c|jSN)loaderspec 6/usr/lib64/python3.12/importlib/resources/_adapters.pyzzSpecLoaderAdapter. s $++cs0||_|||_dSr)r r)selfr Zadapter r __init__zSpecLoaderAdapter.__init__ s gdm r c2t|j|Sr)getattrr r name r __getattr__zSpecLoaderAdapter.__getattr__styy$''r N)__name__ __module__ __qualname____doc__rrr r rrsI&>%=$$$$(((((r rcseZdZdZdZdZdS)TraversableResourcesLoaderz9 Adapt a loader to provide TraversableResources. c||_dSrrr r rr rz#TraversableResourcesLoader.__init__  r csNt|jjSr)CompatibilityFilesr _nativerrr get_resource_readerz.TraversableResourcesLoader.get_resource_readers!$)),4466r N)rrrrrr!rr r rrs<77777r rrcs`|dkrt|g|Ri|S|dkr|Std|d)Nr"ZrbzInvalid mode value 'z"', only 'r' and 'rb' are supported)r ValueError)Zfilemodeargskwargs r _io_wrapperr( sR s{{T3D333F333  GtGGG r cseZdZdZGddej ZGddej ZGddej ZdZ e d Z d Z d Z d Zd S)rzj Adapter for an existing or non-existent resource reader to provide a compatibility .files(). cHeZdZdZdZdZdZeZdZe dZ d dZ d S) CompatibilityFiles.SpecPathzk Path tied to a module spec. Can be read and exposes the resource reader children. c"||_||_dSr)_spec_reader)r r readerrr rz$CompatibilityFiles.SpecPath.__init__6sDJ!DLLLr csjs tdStfdjjDS)Nrc3s^K|]&}tjj|(dSr)r ChildPathr-)Z.0Zpathr s r z z6CompatibilityFiles.SpecPath.iterdir..=s@#,,T\\4@@@@@r )r-iterZcontentsr s`r iterdirz#CompatibilityFiles.SpecPath.iterdir:sP<<<Bx LL113 r cdSNFrr1r r is_filez#CompatibilityFiles.SpecPath.is_fileB5r cs|jstj|Stj|j|Sr)r-r OrphanPathr/r Zotherrr joinpathz$CompatibilityFiles.SpecPath.joinpathGs3<<<)44U;;%// eD Dr cs.|jjSr)r,rr1r r rz CompatibilityFiles.SpecPath.nameLs::?? "r r"csXt|jjd|g|Ri|Sr)r(r- open_resourcer r$r%r&r'r openz CompatibilityFiles.SpecPath.openPs2t||99$?WWWWPVWW Wr Nr" rrrrrr2r5is_dirr9propertyrr<rr r SpecPathr*0s   " " "       E E E  # #  # X X X X X Xr rAcsJeZdZdZdZdZdZdZdZe dZ d d Z d S) CompatibilityFiles.ChildPathzw Path tied to a resource reader child. Can be read but doesn't expose any meaningful children. cr+r)r-_name)r r.rrr rz%CompatibilityFiles.ChildPath.__init__Ys!DLDJJJr ctdSNrr0r1r r r2z$CompatibilityFiles.ChildPath.iterdir] 8Or csN|jj|jSr)r-Z is_resourcerr1r r r5z$CompatibilityFiles.ChildPath.is_file`s<<++DII6 6r cs&|j Sr)r5r1r r r?z#CompatibilityFiles.ChildPath.is_dircs||~% %r csFtj|j|Sr)rr7rr8rr r9z%CompatibilityFiles.ChildPath.joinpathfs%00EB Br crr)rCr1r r rz!CompatibilityFiles.ChildPath.nameis :: r r"cslt|jj|j|g|Ri|Sr)r(r-r:rr;r'r r<z!CompatibilityFiles.ChildPath.openmsF **4995t>BFL r Nr=r>rr r r/rBSs         7 7 7 & & & C C C           r r/cr)) CompatibilityFiles.OrphanPathz Orphan path, not tied to a module spec or resource reader. Can't be read and doesn't expose any meaningful children. csPt|dkr td||_dS)Nrz/Need at least one path part to construct a path)Zlenr#_path)r Z path_partsrr rz&CompatibilityFiles.OrphanPath.__init__xs(:"" !RSS#DJJJr crDrErFr1r r r2z%CompatibilityFiles.OrphanPath.iterdir}rGr cr3r4rr1r r r5z%CompatibilityFiles.OrphanPath.is_filer6r csFtjg|j|RSr)rr7rIr8rr r9z&CompatibilityFiles.OrphanPath.joinpaths%%00D$**DeDDD Dr cs&|jdS)Ni)rIr1r r rz"CompatibilityFiles.OrphanPath.names::b> !r r"cstd)NzCan't open orphan path)ZFileNotFoundErrorr;r'r r<z"CompatibilityFiles.OrphanPath.opens#$<= =r Nr=r>rr r r7rHrs   $ $ $        E E E  " "  " > > > > > >r r7crrrrrr rzCompatibilityFiles.__init__rr cstt5|jjj |jj cdddS#1swYdSxYwr)rZAttributeErrorr rr!rr1r r r-zCompatibilityFiles._readers n % H H99##77 G H H H H H H H H H H H H H H H H Hs :AA"cs>|j}t|dr|S|S)zB Return the native reader if it supports files(). files)r-Zhasattr)r r.rr r zCompatibilityFiles._natives$ 11v;t;r crr)rr-)r Zattrrr rzCompatibilityFiles.__getattr__st||T**r csZtj|j|jSr)rrAr r-r1r r rJzCompatibilityFiles.filess!**499dllCCr N)rrrrrZ TraversablerAr/r7rr@r-r rrJrr r rr*s !X!X!X!X!X3??!X!XFCOO>>>>>>S__>>:HHH<<<+++DDDDDr rcs<t|jtS)z` Construct a package spec with traversable compatibility on the spec/loader/reader. )rZ__spec__r)Zpackager r wrap_specrKs W--/I JJr Nr=) Z contextlibrZiorZrrrr(rrKrr r rLs ( ( ( ( ( ( ( 7 7 7 7 7 7 7xDxDxDxDxDxDxDvKKKKKr