o
    }¨Êhb  ã                   @   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
mZ d dlmZ d dlmZ d d	lmZmZmZmZmZ d d
lmZ d dlmZmZ 	 eeef Zejdkr`eee jf ZneZdededefdd„Z 		d(dededededef
dd„Z!dedede"fdd„Z#		d(dededededef
dd„Z$dededdfdd „Z%ed!d"„ ƒZ&ded#ede'fd$d%„Z(dedee fd&d'„Z)dS ))é    Né   )Ú_common)ÚcontextmanagerÚsuppress)ÚResourceLoader)ÚBytesIOÚTextIOWrapper)ÚPath)Ú
ModuleType)ÚIterableÚIteratorÚOptionalÚSetÚUnion)Úcast)ÚBinaryIOÚTextIOF)ÚContextManager)é   é   ÚpackageÚresourceÚreturnc           
      C   sþ   t  |¡}t  | ¡} t  | ¡}|dur| |¡S tj | jj	p d¡}tj 
|¡}tj ||¡}zt|dd�W S  ty~   tt| jjƒ}d}t| jjdƒrfttƒ� | |¡}W d  ƒ n1 saw   Y  |du rx| jj}d ||¡}	t|	ƒ‚t|ƒ Y S w )zDReturn a file-like object opened for binary reading of the resource.Nznon-existent fileÚrb)ÚmodeÚget_dataz{!r} resource not found in {!r})r   Únormalize_pathÚget_packageÚget_resource_readerÚopen_resourceÚosÚpathÚabspathÚ__spec__ÚoriginÚdirnameÚjoinÚopenÚOSErrorr   r   ÚloaderÚhasattrr   r   ÚnameÚformatÚFileNotFoundErrorr   )
r   r   ÚreaderÚabsolute_package_pathÚpackage_pathÚ	full_pathr)   ÚdataÚpackage_nameÚmessage© r5   úJ/var/www/html/env/lib/python3.10/site-packages/importlib_resources/_py3.pyÚopen_binary   s6   




ÿ
ÿÿòr7   úutf-8ÚstrictÚencodingÚerrorsc                 C   s   t t| |ƒ||d�S )zBReturn a file-like object opened for text reading of the resource.)r:   r;   )r   r7   )r   r   r:   r;   r5   r5   r6   Ú	open_text8   s   ÿr<   c                 C   s6   t | |ƒ�}| ¡ W  d  ƒ S 1 sw   Y  dS )z+Return the binary contents of the resource.N)r7   Úread)r   r   Úfpr5   r5   r6   Úread_binaryA   s   $ÿr?   c                 C   s:   t | |||ƒ�}| ¡ W  d  ƒ S 1 sw   Y  dS )z‹Return the decoded string of the resource.

    The decoding-related arguments have the same semantics as those of
    bytes.decode().
    N)r<   r=   )r   r   r:   r;   r>   r5   r5   r6   Ú	read_textG   s   	$ÿr@   zContextManager[Path]c                 C   s:   t  t  | ¡¡}|rt||ƒS t  t  | ¡ t  |¡¡¡S )ak  A 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).
    )r   r   r   Ú_path_from_readerÚas_fileÚfilesÚjoinpathr   )r   r   r.   r5   r5   r6   r!   T   s   
ÿÿÿýr!   c                 c   sŽ   � t  |¡}ttƒ� t|  |¡ƒV  	 W d   ƒ d S 1 sw   Y  |  |¡}t j|j|d��}|V  W d   ƒ d S 1 s@w   Y  d S )N)Úsuffix)	r   r   r   r-   r	   Úresource_pathr   Ú	_tempfiler=   )r.   r   Únorm_resourceÚopener_readerÚresr5   r5   r6   rA   h   s   €

 þ
"ÿrA   r+   c                 C   sZ   t  | ¡} t  |¡ t  | ¡}|dur| |¡S tt| ƒƒ}||vr$dS t  | ¡|  ¡ S )zYTrue if `name` is a resource inside `package`.

    Directories are *not* resources.
    NF)	r   r   r   r   Úis_resourceÚsetÚcontentsÚfrom_packageÚis_file)r   r+   r.   Úpackage_contentsr5   r5   r6   rK   s   s   



rK   c                 C   sh   t  | ¡} t  | ¡}|dur| ¡ S | jjdu p| jjdk}|s$| jjs&dS tdd„ t  | ¡ 	¡ D ƒƒS )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.
    NÚ	namespacer5   c                 s   s   � | ]}|j V  qd S )N)r+   )Ú.0Úitemr5   r5   r6   Ú	<genexpr>–   s   € zcontents.<locals>.<genexpr>)
r   r   r   rM   r#   r$   Úhas_locationÚlistrN   Úiterdir)r   r.   rQ   r5   r5   r6   rM   ƒ   s   


þrM   )r8   r9   )*r    ÚsysÚ r   Ú
contextlibr   r   Úimportlib.abcr   Úior   r   Úpathlibr	   Útypesr
   Útypingr   r   r   r   r   r   Ú	typing.ior   r   r   ÚstrÚPackageÚversion_infoÚPathLikeÚResourcer7   r<   Úbytesr?   r@   r!   rA   ÚboolrK   rM   r5   r5   r5   r6   Ú<module>   sf    
"ýÿþý
ý	ýÿþý
ýÿÿ
þ

