o 0¦iIã @sÞddlZddlZddlmZddlmZmZddlmZddlm Z ddl m Z ddl m Z dd lmZmZdd lmZdd lmZdd lmZmZmZdd lmZddlmZmZddlmZddlmZgd¢Z ee!efZ"ee!ej#fZ$de"de$defdd„Z%  d3de"de$de!de!def dd„Z&de"de$de'fdd„Z(  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/d0„ƒZ1e1 2e¡d1d2„ƒZ3dS)4éNé)Ú_common)Úas_fileÚfiles)ÚResourceReader)Úsuppress)ÚResourceLoader)Ú ModuleSpec)ÚBytesIOÚ TextIOWrapper)ÚPath)Ú ModuleType)ÚContextManagerÚIterableÚUnion)Úcast)ÚBinaryIOÚTextIO)ÚSequence)Úsingledispatch) ÚPackageÚResourcerrÚcontentsrÚ is_resourceÚ open_binaryÚ open_textÚpathÚ read_binaryÚ read_textÚpackageÚresourceÚreturnc Cs&t |¡}t |¡}t |¡}|dur| |¡Stt|jƒ}|jdur'|j}n|j dur8t j   t j   |j ¡¡g}|D]N}t j  ||¡}z t|dd�WStyˆtt|jƒ}d}t|jdƒrzttƒ� | |¡}Wdƒn1suwY|dur†t|ƒYSYq:wt|›d|j›�ƒ‚)zDReturn a file-like object opened for binary reading of the resource.NÚrb)ÚmodeÚget_dataz resource not found in )rÚnormalize_pathÚ get_packageÚget_resource_readerÚ open_resourcerr Ú__spec__Úsubmodule_search_locationsÚoriginÚosrÚdirnameÚabspathÚjoinÚopenÚOSErrorrÚloaderÚhasattrrr$r ÚFileNotFoundErrorÚname) rr ÚreaderÚspecÚpathsZ package_pathÚ full_pathr2Údata©r;ú:/opt/alt/python310/lib64/python3.10/importlib/resources.pyr(s4            ÿÿ÷ rúutf-8ÚstrictÚencodingÚerrorscCstt||ƒ||d�S)zBReturn a file-like object opened for text reading of the resource.)r?r@)r r)rr r?r@r;r;r<rJs ÿrcCs6t||ƒ� }| ¡WdƒS1swYdS)z+Return the binary contents of the resource.N)rÚread)rr Úfpr;r;r<rVs $ÿrcCs:t||||ƒ� }| ¡WdƒS1swYdS)z‹Return 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@t t |¡¡}|rt|t |¡ƒSt t |¡ 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||ƒS©N)Ú_path_from_resource_pathÚ_path_from_open_resource©r6r r;r;r<rC�s ÿrCcCs:ttƒ�t| |¡ƒWdƒS1swYdSrD)rr4r Z resource_pathrGr;r;r<rE‡s  $ÿrEcCs$t | |¡ ¡¡}tj|j|d�S)N)Úsuffix)Úior r(rArZ _tempfile)r6r Zsavedr;r;r<rFŒsrFr5cCsZt |¡}t |¡t |¡}|dur| |¡Stt|ƒƒ}||vr$dSt |¡| ¡S)zYTrue if 'name' is a resource inside 'package'. Directories are *not* resources. NF) rr&r%r'rÚsetrÚ from_packageÚis_file)rr5r6Zpackage_contentsr;r;r<r‘s     rcCsTt |¡}t |¡}|durt| ¡ƒSt |¡}| ¡r(tdd„| ¡DƒƒSgS)zõReturn 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)Ú.0Úitemr;r;r<Ú ®s€zcontents..) rr&r'Ú_ensure_sequencerrKÚis_dirÚlistZiterdir)rr6Z transversabler;r;r<r¡s    rcCst|ƒSrD)rR©Úiterabler;r;r<rP²srPcCs|SrDr;rSr;r;r<Ú_·srU)r=r>)4r,rIÚrrrÚabcrÚ contextlibrZ importlib.abcrÚimportlib.machineryr r r Zpathlibr Útypesr ÚtypingrrrrZ typing.iorrZcollections.abcrÚ functoolsrÚ__all__ÚstrrÚPathLikerrrÚbytesrrrrCrErFÚboolrrrPÚregisterrUr;r;r;r<Ús~           %üÿþýü û  üÿþýü ûÿþ ý