1 ÷a ´i)ã@sÈddlZddlmZddlmZddlmZddlmZmZddl m Z ddl m Z dd l mZmZdd lmZdd lmZdd lmZmZmZmZdd lmZddlmZmZgd¢ZeeefZeeej fZ!edœdd„Z"edœdd„Z#edœdd„Z$eeej%dœdd„Z&dd„Z'ee!edœdd„Z(d4ee!eeed!œd"d#„Z)ee!e*dœd$d%„Z+d5ee!eeed!œd&d'„Z,eej-dœd(d)„Z.ee!d*dœd+d,„Z/ed-d.„ƒZ0eee1d/œd0d1„Z2eeedœd2d3„Z3dS)6éNé)Úabc)Ú_common)Úas_file)ÚcontextmanagerÚsuppress)Ú import_module)ÚResourceLoader)ÚBytesIOÚ TextIOWrapper)ÚPath)Ú ModuleType)ÚContextManagerÚIterableÚOptionalÚUnion)Úcast)ÚBinaryIOÚTextIO) ÚPackageÚResourcerÚcontentsÚfilesÚ is_resourceÚ open_binaryÚ open_textÚpathÚ read_binaryÚ read_text)ÚreturncCst|dƒr|St|ƒS)z)If name is a string, resolve to a module.Ú__spec__)Úhasattrr©Úname©r$ú+/usr/lib64/python3.9/importlib/resources.pyÚ_resolve$s r&cCs&t|ƒ}|jjdur"td |¡ƒ‚|S)z±Take a package name or module object and return the module. If a name, the module is imported. If the resolved module object is not a package, raise an exception. Nz{!r} is not a package)r&r Úsubmodule_search_locationsÚ TypeErrorÚformat)ÚpackageÚmoduler$r$r%Ú _get_package+s r,cCs&tj |¡\}}|r"td |¡ƒ‚|S)z€Normalize a path by ensuring it is a string. If the resulting string contains path separators, an exception is raised. z{!r} must be only a file name)ÚosrÚsplitÚ ValueErrorr))rÚparentÚ file_namer$r$r%Ú_normalize_path7sr2)r*rcCs,|j}t|jdƒr(ttj|j |j¡ƒSdS)NÚget_resource_reader)r r!ÚloaderrÚ resources_abcÚResourceReaderr3r#)r*Úspecr$r$r%Ú_get_resource_readerBs   ÿr8cCs&|jjdus|jjs"td|›�ƒ‚dS)NzPackage has no location )r ÚoriginÚ has_locationÚFileNotFoundError©r*r$r$r%Ú_check_locationPsr=)r*Úresourcerc Csüt|ƒ}t|ƒ}t|ƒ}|dur*| |¡Stj |jjp:d¡}tj  |¡}tj  ||¡}zt |dd�WSt yöt t|jjƒ}d}t|jjdƒrÆtt ƒ�| |¡}Wdƒn1s¼0Y|durê|jj}d ||¡} t| ƒ‚t|ƒYS0dS)zDReturn a file-like object opened for binary reading of the resource.Nznon-existent fileÚrb)ÚmodeÚget_dataz{!r} resource not found in {!r})r2r,r8Ú open_resourcer-rÚabspathr r9ÚdirnameÚjoinÚopenÚOSErrorrr r4r!rrAr#r)r;r ) r*r>ÚreaderZabsolute_package_pathÚ package_pathÚ full_pathr4ÚdataZ package_nameÚmessager$r$r%rUs2  ÿ   (ÿrúutf-8Ústrict)r*r>ÚencodingÚerrorsrcCstt||ƒ||d�S)zBReturn a file-like object opened for text reading of the resource.)rOrP)r r)r*r>rOrPr$r$r%rss ÿrcCs6t||ƒ�}| ¡WdƒS1s(0YdS)z+Return the binary contents of the resource.N)rÚread)r*r>Úfpr$r$r%r|s rcCs:t||||ƒ�}| ¡WdƒS1s,0YdS)z‹Return the decoded string of the resource. The decoding-related arguments have the same semantics as those of bytes.decode(). N)rrQ)r*r>rOrPrRr$r$r%r‚s rcCst t|ƒ¡S)z3 Get a Traversable resource from a package )rÚ from_packager,r<r$r$r%r�srzContextManager[Path]cCs2tt|ƒƒ}|rt||ƒSt t|ƒ t|ƒ¡¡S)akA con