o
     JAfI                     @   s  d dl Z d dlZddlmZ ddlmZmZ ddlmZ d dlm	Z	 d dl
mZ d dlmZ d d	lmZmZ d d
lmZ d dlmZ d dlmZmZmZ d dlmZ d dlmZmZ d dlmZ d dlmZ g dZ ee!ef Z"ee!e j#f Z$de"de$defddZ%		d3de"de$de!de!def
ddZ&de"de$de'fddZ(		d3de"de$de!de!de!f
dd Z)de"de$dd!fd"d#Z*d$d% Z+d&d' Z,d(d) Z-de"d*e!de.fd+d,Z/de"dee! fd-d.Z0ed/d0 Z1e12ed1d2 Z3dS )4    N   )_common)as_filefiles)ResourceReader)suppress)ResourceLoader)
ModuleSpec)BytesIOTextIOWrapper)Path)
ModuleType)ContextManagerIterableUnion)cast)BinaryIOTextIO)Sequence)singledispatch)PackageResourcer   r   contentsr   is_resourceopen_binary	open_textpathread_binary	read_textpackageresourcereturnc           	      C   s(  	 t |}t | } t | }|d ur||S tt| j}|jd ur(|j}n|j	d ur9t
jt
j|j	g}|D ]N}t
j||}z	t|ddW   S  ty   tt|j}d }t|jdr{tt ||}W d    n1 svw   Y  |d urt| Y   S Y q;w t|d|j)Nrb)modeget_dataz resource not found in )r   normalize_pathget_packageget_resource_readeropen_resourcer   r	   __spec__submodule_search_locationsoriginosr   dirnameabspathjoinopenOSErrorr   loaderhasattrr   r$   r
   FileNotFoundErrorname)	r   r    readerspecpathsZpackage_path	full_pathr2   data r;   */usr/lib/python3.10/importlib/resources.pyr   (   s6   






r   utf-8strictencodingerrorsc                 C   s   	 t t| |||dS )N)r?   r@   )r   r   )r   r    r?   r@   r;   r;   r<   r   J   s   r   c                 C   s8   	 t | |}| W  d    S 1 sw   Y  d S N)r   read)r   r    fpr;   r;   r<   r   V   s   $r   c                 C   s<   	 t | |||}| W  d    S 1 sw   Y  d S rA   )r   rB   )r   r    r?   r@   rC   r;   r;   r<   r   \   s   $r   zContextManager[Path]c                 C   sB   	 t t | }|rt|t |S t t | t |S rA   )r   r'   r&   _path_from_readerr%   r   r   joinpath)r   r    r6   r;   r;   r<   r   k   s   r   c                 C   s   t | |p	t| |S rA   )_path_from_resource_path_path_from_open_resourcer6   r    r;   r;   r<   rD      s   rD   c                 C   s:   t t t| |W  d    S 1 sw   Y  d S rA   )r   r4   r   Zresource_pathrH   r;   r;   r<   rF      s   
$rF   c                 C   s$   t | | }tj|j|dS )N)suffix)ior
   r(   rB   r   Z	_tempfile)r6   r    Zsavedr;   r;   r<   rG      s   rG   r5   c                 C   s\   	 t | } t | t | }|d ur||S tt| }||vr%dS t | |  S )NF)	r   r&   r%   r'   r   setr   from_packageis_file)r   r5   r6   Zpackage_contentsr;   r;   r<   r      s   



r   c                 C   sV   	 t | } t | }|d urt| S t | }| r)tdd | D S g S )Nc                 s   s    | ]}|j V  qd S rA   )r5   ).0itemr;   r;   r<   	<genexpr>   s    zcontents.<locals>.<genexpr>)	r   r&   r'   _ensure_sequencer   rL   is_dirlistiterdir)r   r6   Ztransversabler;   r;   r<   r      s   


r   c                 C   s   t | S rA   )rS   iterabler;   r;   r<   rQ      s   rQ   c                 C   s   | S rA   r;   rU   r;   r;   r<   _   s   rW   )r=   r>   )4r,   rJ    r   r   r   abcr   
contextlibr   Zimportlib.abcr   importlib.machineryr	   r
   r   pathlibr   typesr   typingr   r   r   r   Z	typing.ior   r   collections.abcr   	functoolsr   __all__strr   PathLiker   r   r   bytesr   r   r   rD   rF   rG   boolr   r   rQ   registerrW   r;   r;   r;   r<   <module>   s~    %
	


