Wc csdZddlZddlZddlZddlmZmZddlmZmZGddejZ Gdd eZ Gd d eZ Gd d ee Z dS)z+ Interface adapters for low-level readers. iN)BinaryIOListi) TraversableTraversableResourcescseZdZdZej dZejdZejdZ ejdZ e dZ dS) SimpleReaderzQ The minimum, low-level interface required from a resource provider. cdS)zP The name of the package for which this reader loads resources. Nself 3/usr/lib64/python3.12/importlib/resources/simple.pypackagezSimpleReader.packagecr)zo Obtain an iterable of SimpleReader for available child containers (e.g. directories). Nrrr r childrenzSimpleReader.childrenr r cr)zL Obtain available named resources for this virtual package. Nrrr r resourceszSimpleReader.resources"r r cr)z: Obtain a File-like for a named resource. Nr)rZresource r open_binaryzSimpleReader.open_binary)r r csF|jjddS)Nz.i)r Zsplitrr r namezSimpleReader.name0s||!!#&r**r N) __name__ __module__ __qualname____doc__abcZabstractpropertyr ZabstractmethodrrrZpropertyrrr r rr s                 +++++r rcs2eZdZdZdZdZdZd dZdZdS) ResourceHandlez9 Handle to a named resource in a ResourceReader. cs"||_||_dSN)parentr)rrr r __init__zResourceHandle.__init__:s  r crNTrrr r is_filezResourceHandle.is_file?tr crNFrrr r is_dirzResourceHandle.is_dirBur rcs|jjj|j}d|vrt j |i|}|S)NZb)rreaderrrioZ TextIOWrapper)rZmodeargskwargsZstreams r openzResourceHandle.openEsF##// : d??%%t6v66F r cstd)NzCannot traverse into a resource)Z RuntimeError)rrrr joinpathzResourceHandle.joinpathKs<==r N)r#) rrrrrrr!r(r)rr r rr5sn  >>>>>r rcs0eZdZdZdZdZdZdZdZdS)ResourceContainerzI Traversable container for a package's resources via its reader. cs||_dSr)r$)rr$rr rzResourceContainer.__init__Ts  r crrrrr r r!zResourceContainer.is_dirXrr crr rrr r rzResourceContainer.is_file[r"r csfdjjD}ttjj }t j ||S)Nc3s6K|]}t|dSr)r)Z.0rrs r z z,ResourceContainer.iterdir.._s*NNd+++++NNr )r$rZmapr*r itertoolsZchain)rfilesZdirss` r iterdirzResourceContainer.iterdir^sNNNNN 8M8MNN$dkk&:&:&<=ud++r cstr)ZIsADirectoryError)rr&r'rr r(zResourceContainer.opencs !!r N) rrrrrr!rr-r(rr r r*r*Osi,,, """""r r*cseZdZdZdZdS)TraversableReaderz A TraversableResources based on SimpleReader. Resource providers may derive from this class to provide the TraversableResources interface by supplying the SimpleReader interface. cst|Sr)r*rr r r,zTraversableReader.filesns  &&r N)rrrrr,rr r r.r.gs- '''''r r.)rrr%r+ZtypingrrrrZABCrrr*r.rr r r/s !!!!!!!!22222222%+%+%+%+%+377%+%+P>>>>>[>>4""""" ""0''''',l''''r