T5?{bddlZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z ddlm Z mZddlmZeeej"efZgdZGddej(ZGd d eZe Gd d eZGd deZy)N)AnyBinaryIOIterableIteratorNoReturnTextOptional)runtime_checkableProtocol)Union)ResourceReader TraversableTraversableResourcesceZdZdZej dedefdZej dedefdZ ej dede fdZ ej de e fdZy ) r zDAbstract base class for loaders to provide resource reading support.resourcereturnct)zReturn an opened, file-like object for binary reading. The 'resource' argument is expected to represent only a file name. If the resource cannot be found, FileNotFoundError is raised. FileNotFoundErrorselfrs >/opt/alt/python312/lib64/python3.12/importlib/resources/abc.py open_resourcezResourceReader.open_resources  ct)zReturn the file system path to the specified resource. The 'resource' argument is expected to represent only a file name. If the resource does not exist on the file system, raise FileNotFoundError. rrs r resource_pathzResourceReader.resource_paths  rpathct)zjReturn True if the named 'path' is a resource. Files are resources, directories are not. rrrs r is_resourcezResourceReader.is_resource,s  rct)z+Return an iterable of entries in `package`.rrs rcontentszResourceReader.contents4s  rN)__name__ __module__ __qualname____doc__abcabstractmethodrrrrboolr rstrr#rrr r sN  d  x       d  t           (3-  rr ) metaclassc eZdZy)TraversalErrorN)r$r%r&r,rrr/r/:srr/c2eZdZdZej dedfdZdefdZ dde e de fdZ ej de fdZej de fd Zd eddfd Zd eddfd Zej ddZeej de fdZy)rz An object with a subset of pathlib.Path methods suitable for traversing directories and opening files. Any exceptions that occur when accessing the backing resource may propagate unaltered. rcy)z3 Yield Traversable objects in self Nr,r"s riterdirzTraversable.iterdirHrcp|jd5}|jcdddS#1swYyxYw)z0 Read contents of self as bytes rbNopenread)rstrms r read_byteszTraversable.read_bytesNs$YYt_99;__s,5Nencodingcr|j|5}|jcdddS#1swYyxYw)z/ Read contents of self as text )r;Nr6)rr;r9s r read_textzTraversable.read_textUs)YYY )T99;* ) )s-6cy)z4 Return True if self is a directory Nr,r"s ris_dirzTraversable.is_dir\r3rcy)z/ Return True if self is a file Nr,r"s ris_filezTraversable.is_filebr3r descendantscL|s|Stjjdttj |D}t |fd|jD} t |}|j|S#t$rtdt|wxYw)z Return Traversable resolved with any descendants applied. Each descendant should be a path segment relative to self and each may contain multiple levels separated by ``posixpath.sep`` (``/``). c34K|]}|jywN)parts).0rs r z'Traversable.joinpath..rs. #J4DJJ#Jc3BK|]}|jk(s|ywrEname)rG traversabletargets rrHz'Traversable.joinpath..vs# +9K[=M=MQW=WK>sz"Target not found during traversal.) itertoolschain from_iterablemappathlib PurePosixPathnextr2 StopIterationr/listjoinpath)rrBnamesmatchesmatchrNs @rrXzTraversable.joinpathhsK--. #&w'<'  ME u~~u%%   4fd5k  s ) B B#childc$|j|S)z2 Return Traversable child in self )rX)rr\s r __truediv__zTraversable.__truediv__s}}U##rcy)z mode may be 'r' or 'rb' to open as text or binary. Return a handle suitable for reading (same as pathlib.Path.open). When opening as text, accepts encoding parameters such as those accepted by io.TextIOWrapper. Nr,)rmodeargskwargss rr7zTraversable.openr3rcy)zM The base name of this object without any parent references. Nr,r"s rrLzTraversable.namer3rrE)r)r$r%r&r'r(r)rr2bytesr:r r+r=r*r?rAStrPathrXr^r7propertyrLr,rrrr>s  -0  E(3-3        &W&&2$$]$     c  rrceZdZdZej d dZdedejfdZ de de fdZ dedefdZdeefd Zy ) rzI The required interface for providing traversable resources. rcy)z3Return a Traversable object for the loaded package.Nr,r"s rfileszTraversableResources.filesr3rrc^|jj|jdS)Nr5)rjrXr7rs rrz"TraversableResources.open_resources$zz|$$X.33D99rct|rErrs rrz"TraversableResources.resource_paths ))rrc\|jj|jSrE)rjrXrArs rr z TraversableResources.is_resources"zz|$$T*2244rcLd|jjDS)Nc34K|]}|jywrErK)rGitems rrHz0TraversableResources.contents..s=&(3->rr)r(rqrOosrStypingrrrrrrr r r r r+PathLikerf__all__ABCMetar Exceptionr/rrr,rrrys  NNN. R[[%% & C' s{{' T Y W (W W t>>>r