o ?OgI @sddlZddlZddlmZddlmZmZddlmZddlm Z ddl m Z ddl m Z dd lmZmZdd lmZdd lmZdd lmZmZmZdd lmZddlmZmZddlmZddlmZgdZ ee!efZ"ee!ej#fZ$de"de$defddZ%  d3de"de$de!de!def ddZ&de"de$de'fddZ(  d3de"de$de!de!de!f dd Z)de"de$dd!fd"d#Z*d$d%Z+d&d'Z,d(d)Z-de"d*e!de.fd+d,Z/de"dee!fd-d.Z0ed/d0Z1e12ed1d2Z3dS)4N)_common)as_filefiles)ResourceReader)suppress)ResourceLoader) ModuleSpec)BytesIO TextIOWrapper)Path) ModuleType)ContextManagerIterableUnion)cast)BinaryIOTextIO)Sequence)singledispatch) PackageResourcerrcontentsr is_resource open_binary open_textpath read_binary read_textpackageresourcereturnc Cs&t|}t|}t|}|dur||Stt|j}|jdur'|j}n|j dur8t j t j |j g}|D]N}t j ||}z t|ddWStytt|j}d}t|jdrztt ||}Wdn1suwY|durt|YSYq:wt|d|j)zDReturn a file-like object opened for binary reading of the resource.Nrb)modeget_dataz resource not found in )rnormalize_path get_packageget_resource_reader open_resourcerr __spec__submodule_search_locationsoriginosrdirnameabspathjoinopenOSErrorrloaderhasattrrr$r FileNotFoundErrorname) rr readerspecpathsZ package_path full_pathr2datar;:/opt/alt/python310/lib64/python3.10/importlib/resources.pyr(s4             rutf-8strictencodingerrorscCstt||||dS)zBReturn a file-like object opened for text reading of the resource.)r?r@)r r)rr r?r@r;r;r<rJs rcCs6t|| }|WdS1swYdS)z+Return the binary contents of the resource.N)rread)rr fpr;r;r<rVs $rcCs:t|||| }|WdS1swYdS)zReturn the decoded string of the resource. The decoding-related arguments have the same semantics as those of bytes.decode(). N)rrA)rr r?r@rBr;r;r<r\s $rzContextManager[Path]cCs@tt|}|rt|t|Stt|t|S)akA context manager providing a file path object to the resource. If the resource does not already exist on its own on the file system, a temporary file will be created. If the file was created, the file will be deleted upon exiting the context manager (no exception is raised if the file was deleted prior to the context manager exiting). )rr'r&_path_from_readerr%rrZjoinpath)rr r6r;r;r<rks rcCst||p t||SN)_path_from_resource_path_path_from_open_resourcer6r r;r;r<rCs rCcCs:ttt||WdS1swYdSrD)rr4r Z resource_pathrGr;r;r<rEs  $rEcCs$t||}tj|j|dS)N)suffix)ior r(rArZ _tempfile)r6r Zsavedr;r;r<rFsrFr5cCsZt|}t|t|}|dur||Stt|}||vr$dSt||S)zYTrue if 'name' is a resource inside 'package'. Directories are *not* resources. NF) rr&r%r'rsetr from_packageis_file)rr5r6Zpackage_contentsr;r;r<rs     rcCsTt|}t|}|durt|St|}|r(tdd|DSgS)zReturn an iterable of entries in 'package'. Note that not all entries are resources. Specifically, directories are not considered resources. Use `is_resource()` on each entry returned here to check if it is a resource or not. Ncss|]}|jVqdSrD)r5).0itemr;r;r< szcontents..) rr&r'_ensure_sequencerrKis_dirlistZiterdir)rr6Z transversabler;r;r<rs    rcCst|SrD)rRiterabler;r;r<rPsrPcCs|SrDr;rSr;r;r<_srU)r=r>)4r,rIrrrabcr contextlibrZ importlib.abcrimportlib.machineryr r r Zpathlibr typesr typingrrrrZ typing.iorrZcollections.abcr functoolsr__all__strrPathLikerrrbytesrrrrCrErFboolrrrPregisterrUr;r;r;r<s~           %