
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    ¡ê,a@%  ã                	   @   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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 d dlmZ dddddddddg	Zee ef Z!ee e j"f Z#edœdd„Z$e dœdd„Z%eeej& dœdd„Z'dd „ Z(e!e#ed!œd"d„Z)d-e!e#e e ed%œd&d„Z*e!e#e+d!œd'd„Z,d.e!e#e e e d%œd(d„Z-ee!e#ee d!œd)d„ƒZ.e!e e/d*œd+d„Z0e!ee  dœd,d„Z1dS )/é    Né   )Úabc)ÚcontextmanagerÚsuppress)Úimport_module)ÚResourceLoader)ÚBytesIOÚTextIOWrapper)ÚPath)Ú
ModuleType)ÚIterableÚIteratorÚOptionalÚSetÚUnion)Úcast)ÚBinaryIOÚTextIO)ÚZipImportErrorÚPackageÚResourceÚcontentsÚis_resourceÚopen_binaryÚ	open_textÚpathÚread_binaryÚ	read_text)Úreturnc                 C   s\   t | dƒr0| jjdkr*td | jj¡ƒ‚qX| S n(t| ƒ}|jjdkrTtd | ¡ƒ‚n|S dS )z»Take a package name or module object and return the module.

    If a name, the module is imported.  If the passed or imported module
    object is not a package, raise an exception.
    Ú__spec__Nz{!r} is not a package)Úhasattrr   Úsubmodule_search_locationsÚ	TypeErrorÚformatÚnamer   )ÚpackageÚmodule© r'   ú8/opt/alt/python38/lib64/python3.8/importlib/resources.pyÚ_get_package"   s    
ÿr)   c                 C   s,   t j | ¡\}}|r$td | ¡ƒ‚n|S d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 nameN)Úosr   ÚsplitÚ
ValueErrorr#   )r   ÚparentÚ	file_namer'   r'   r(   Ú_normalize_path6   s    r/   )r%   r   c                 C   s,   | j }t|jdƒr(ttj|j |j¡ƒS d S )NÚget_resource_reader)r   r    Úloaderr   Úresources_abcÚResourceReaderr0   r$   )r%   Úspecr'   r'   r(   Ú_get_resource_readerB   s    ÿr5   c                 C   s&   | j jd ks| j js"td| ›�ƒ‚d S )NzPackage has no location )r   ÚoriginÚhas_locationÚFileNotFoundError)r%   r'   r'   r(   Ú_check_locationP   s    r9   )r%   Úresourcer   c           
      C   sô   t |ƒ}t| ƒ} t| ƒ}|dk	r*| |¡S t| ƒ tj | jj	¡}tj 
|¡}tj ||¡}zt|dd�W S  tk
rî   tt| jjƒ}d}t| jjdƒr¸ttƒ� | |¡}W 5 Q R X |dkrÞ| jj}d ||¡}	t|	ƒ‚nt|ƒ Y S Y nX dS )zDReturn a file-like object opened for binary reading of the resource.NÚrb)ÚmodeÚget_dataú{!r} resource not found in {!r})r/   r)   r5   Úopen_resourcer9   r*   r   Úabspathr   r6   ÚdirnameÚjoinÚopenÚOSErrorr   r   r1   r    r   r=   r$   r#   r8   r   )
r%   r:   ÚreaderÚabsolute_package_pathÚpackage_pathÚ	full_pathr1   ÚdataÚpackage_nameÚmessager'   r'   r(   r   U   s2    

 ÿ
úutf-8Ústrict)r%   r:   ÚencodingÚerrorsr   c                 C   s
  t |ƒ}t| ƒ} t| ƒ}|dk	r2t| |¡||ƒS t| ƒ tj | j	j
¡}tj |¡}tj ||¡}zt|d||d�W S  tk
�r   tt| j	jƒ}d}	t| j	jdƒrÆttƒ� | |¡}	W 5 Q R X |	dkrì| j	j}
d ||
¡}t|ƒ‚ntt|	ƒ||ƒ Y S Y nX dS )zBReturn a file-like object opened for text reading of the resource.NÚr)r<   rN   rO   r=   r>   )r/   r)   r5   r	   r?   r9   r*   r   r@   r   r6   rA   rB   rC   rD   r   r   r1   r    r   r=   r$   r#   r8   r   )r%   r:   rN   rO   rE   rF   rG   rH   r1   rI   rJ   rK   r'   r'   r(   r   t   s2    
 ÿ
c              
   C   s:   t |ƒ}t| ƒ} t| |ƒ�}| ¡ W  5 Q R £ S Q R X dS )z+Return the binary contents of the resource.N)r/   r)   r   Úread)r%   r:   Úfpr'   r'   r(   r   –   s    c              
   C   s>   t |ƒ}t| ƒ} t| |||ƒ�}| ¡ W  5 Q R £ S Q R X 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   rQ   )r%   r:   rN   rO   rR   r'   r'   r(   r   ž   s    	c           	      c   s  t |ƒ}t| ƒ} t| ƒ}|dk	rNzt| |¡ƒV  W dS  tk
rJ   Y qVX nt| ƒ d}| jjdk	r|t| jjƒj	}|| }|dk	r”| 
¡ r”|V  nxt| |ƒ�}| ¡ }W 5 Q R X t ¡ \}}z$t ||¡ t |¡ t|ƒV  W 5 zt |¡ W n tk
�r   Y nX X d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).
    N)r/   r)   r5   r
   Úresource_pathr8   r9   r   r6   r-   Úexistsr   rQ   ÚtempfileZmkstempr*   ÚremoveÚwriteÚclose)	r%   r:   rE   Z	file_pathÚpackage_directoryrR   rI   ÚfdZraw_pathr'   r'   r(   r   ­   s6    

)r%   r$   r   c              	   C   s|   t | ƒ} t|ƒ t| ƒ}|dk	r*| |¡S ztt| ƒƒ}W n ttfk
rT   Y dS X ||krbdS t| j	j
ƒj| }| ¡ S )zYTrue if 'name' is a resource inside 'package'.

    Directories are *not* resources.
    NF)r)   r/   r5   r   Úsetr   ÚNotADirectoryErrorr8   r
   r   r6   r-   Úis_file)r%   r$   rE   Zpackage_contentsr   r'   r'   r(   r   Ü   s    
c                 C   sT   t | ƒ} t| ƒ}|dk	r | ¡ S | jjdks4| jjs8dS t| jjƒj}t 	|¡S 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.
    Nr'   )
r)   r5   r   r   r6   r7   r
   r-   r*   Úlistdir)r%   rE   rY   r'   r'   r(   r   ó   s    )rL   rM   )rL   rM   )2r*   rU   Ú r   r2   Ú
contextlibr   r   Ú	importlibr   Úimportlib.abcr   Úior   r	   Úpathlibr
   Útypesr   Útypingr   r   r   r   r   r   Z	typing.ior   r   Z	zipimportr   Ú__all__Ústrr   ÚPathLiker   r)   r/   r3   r5   r9   r   r   Úbytesr   r   r   Úboolr   r   r'   r'   r'   r(   Ú<module>   sh   ÷ ÿ!  ý ý"
  ý ý.