U  e*@sddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z ddlm Z m Z ddlmZdddgZGd ddejd ZGd d d eZe Gd dde ZGdddeZdS)N)AnyBinaryIOIterableIteratorNoReturnTextOptional)runtime_checkableProtocol)StrPathResourceReader TraversableTraversableResourcesc@sjeZdZdZejeedddZejeedddZ ejee ddd Z eje e d d d Zd S)r zDAbstract base class for loaders to provide resource reading support.resourcereturncCstdS)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. NFileNotFoundErrorselfrrE/opt/hc_python/lib/python3.8/site-packages/importlib_resources/abc.py open_resources zResourceReader.open_resourcecCstdS)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. Nrrrrr resource_paths zResourceReader.resource_pathpathrcCstdS)zjReturn True if the named 'path' is a resource. Files are resources, directories are not. Nrrrrrr is_resource*szResourceReader.is_resourcercCstdS)z+Return an iterable of entries in `package`.Nrrrrrcontents2szResourceReader.contentsN)__name__ __module__ __qualname____doc__abcabstractmethodrrrrboolrrstrr!rrrrr s  ) metaclassc@s eZdZdS)TraversalErrorN)r"r#r$rrrrr+8sr+c@seZdZdZejeddddZedddZ de e e dd d Z eje dd d Zeje dd dZeddddZeddddZejdddZeeje dddZdS)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. rcCsdS)z3 Yield Traversable objects in self Nrr rrriterdirFszTraversable.iterdirc Cs*|d}|W5QRSQRXdS)z0 Read contents of self as bytes rbNopenread)rstrmrrr read_bytesLs zTraversable.read_bytesN)encodingrc Cs,|j|d}|W5QRSQRXdS)z/ Read contents of self as text )r3Nr.)rr3r1rrr read_textSszTraversable.read_textcCsdS)z4 Return True if self is a directory Nrr rrris_dirZszTraversable.is_dircCsdS)z/ Return True if self is a file Nrr rrris_file`szTraversable.is_file) descendantsrcs|s|Stjddttj|D}t|fdd|D}z t|}Wn$tk rtt dt |YnX|j |S)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`` (``/``). css|] }|jVqdSN)parts).0rrrr psz'Traversable.joinpath..c3s|]}|jkr|VqdSr8name)r:Z traversabletargetrrr;ts z"Target not found during traversal.) itertoolschain from_iterablemappathlib PurePosixPathnextr, StopIterationr+listjoinpath)rr7namesmatchesmatchrr>rrIfs$     zTraversable.joinpath)childrcCs ||S)z2 Return Traversable child in self )rI)rrMrrr __truediv__szTraversable.__truediv__rcOsdS)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)rmodeargskwargsrrrr/szTraversable.opencCsdS)zM The base name of this object without any parent references. Nrr rrrr=szTraversable.name)N)rO)r"r#r$r%r&r'rr,bytesr2rr)r4r(r5r6r rIrNr/propertyr=rrrrr<s  c@sheZdZdZejddddZeej dddZ e e dd d Z eed d d ZeedddZdS)rzI The required interface for providing traversable resources. rrcCsdS)z3Return a Traversable object for the loaded package.Nrr rrrfilesszTraversableResources.filesrcCs||dS)Nr-)rUrIr/rrrrrsz"TraversableResources.open_resourcecCs t|dSr8rrrrrrsz"TraversableResources.resource_pathrcCs||Sr8)rUrIr6rrrrrsz TraversableResources.is_resourcecCsdd|DS)Ncss|] }|jVqdSr8r<)r:itemrrrr;sz0TraversableResources.contents..)rUr,r rrrr!szTraversableResources.contentsN)r"r#r$r%r&r'rUr ioBufferedReaderrrrrr(rrr)r!rrrrrs)r&rWr@rDtypingrrrrrrrr r Z compat.py38r __all__ABCMetar Exceptionr+rrrrrrs$  *Z