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 dur9t j t j |j g}|D]N}t j ||}z t|ddWStytt|j}d}t|jdr{tt ||}Wdn1svwY|durt|YSYq;wt|d|j)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(s6             rutf-8strictencodingerrorscCs tt||||dS)N)r?r@)r r)rr r?r@r;r;r<rJs rcCs8 t|| }|WdS1swYdSN)rread)rr fpr;r;r<rVs $rcCs< t|||| }|WdS1swYdSrA)rrB)rr r?r@rCr;r;r<r\s$rzContextManager[Path]cCsB tt|}|rt|t|Stt|t|SrA)rr'r&_path_from_readerr%rrZjoinpath)rr r6r;r;r<rksrcCst||p t||SrA)_path_from_resource_path_path_from_open_resourcer6r r;r;r<rDs rDcCs:ttt||WdS1swYdSrA)rr4r Z resource_pathrGr;r;r<rEs  $rEcCs$t||}tj|j|dS)N)suffix)ior r(rBrZ _tempfile)r6r Zsavedr;r;r<rFsrFr5cCs\ t|}t|t|}|dur||Stt|}||vr%dSt||S)NF) rr&r%r'rsetr from_packageis_file)rr5r6Zpackage_contentsr;r;r<rs     rcCsV t|}t|}|durt|St|}|r)tdd|DSgS)Ncss|]}|jVqdSrA)r5).0itemr;r;r< szcontents..) rr&r'_ensure_sequencerrKis_dirlistZiterdir)rr6Z transversabler;r;r<rs    rcCst|SrA)rRiterabler;r;r<rPsrPcCs|SrAr;rSr;r;r<_srU)r=r>)4r,rIrrrabcr contextlibrZ importlib.abcrimportlib.machineryr r r Zpathlibr typesr typingrrrrZ typing.iorrZcollections.abcr functoolsr__all__strrPathLikerrrbytesrrrrDrErFboolrrrPregisterrUr;r;r;r<s~           %