Wc dZddlZddlZddlZddlmZmZddlmZmZGddejZ Gdd eZ Gd d eZ Gd d ee Z dS)z+ Interface adapters for low-level readers. N)BinaryIOList) TraversableTraversableResourcesceZdZdZej 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. Nselfs 3/usr/lib64/python3.12/importlib/resources/simple.pypackagezSimpleReader.packagecdS)zo Obtain an iterable of SimpleReader for available child containers (e.g. directories). Nr r s rchildrenzSimpleReader.childrenrrcdS)zL Obtain available named resources for this virtual package. Nr r s r resourceszSimpleReader.resources"rrcdS)z: Obtain a File-like for a named resource. Nr )r resources r open_binaryzSimpleReader.open_binary)rrcF|jjddS)N.)rsplitr s rnamezSimpleReader.name0s||!!#&r**rN) __name__ __module__ __qualname____doc__abcabstractpropertyrabstractmethodrrrpropertyrr rrr r s                 +++++rr c2eZdZdZdZdZdZd dZdZdS) ResourceHandlez9 Handle to a named resource in a ResourceReader. c"||_||_dSN)parentr)r r*rs r__init__zResourceHandle.__init__:s  rcdSNTr r s ris_filezResourceHandle.is_file?trcdSNFr r s ris_dirzResourceHandle.is_dirBurrc|jjj|j}d|vrt j |i|}|S)Nb)r*readerrrio TextIOWrapper)r modeargskwargsstreams ropenzResourceHandle.openEsF##// : d??%%t6v66F rctd)NzCannot traverse into a resource) RuntimeError)r rs rjoinpathzResourceHandle.joinpathKs<==rN)r4) rrr r!r+r.r2r>rAr rrr'r'5sn  >>>>>rr'c0eZdZdZdZdZdZdZdZdS)ResourceContainerzI Traversable container for a package's resources via its reader. c||_dSr))r7)r r7s rr+zResourceContainer.__init__Ts  rcdSr-r r s rr2zResourceContainer.is_dirXr/rcdSr1r r s rr.zResourceContainer.is_file[r3rcfdjjD}ttjj }t j ||S)Nc36K|]}t|dSr))r').0rr s r z,ResourceContainer.iterdir.._s*NNd+++++NNr)r7rmaprCr itertoolschain)r filesdirss` riterdirzResourceContainer.iterdir^sNNNNN 8M8MNN$dkk&:&:&<=ud++rctr))IsADirectoryError)r r;r<s rr>zResourceContainer.opencs !!rN) rrr r!r+r2r.rPr>r rrrCrCOsi,,, """""rrCceZdZdZdZdS)TraversableReaderz A TraversableResources based on SimpleReader. Resource providers may derive from this class to provide the TraversableResources interface by supplying the SimpleReader interface. ct|Sr))rCr s rrNzTraversableReader.filesns  &&rN)rrr r!rNr rrrTrTgs- '''''rrT)r!r"r8rLtypingrrrrABCr r'rCrTr rrrXs !!!!!!!!22222222%+%+%+%+%+377%+%+P>>>>>[>>4""""" ""0''''',l''''r