File: //lib64/python3.9/importlib/__pycache__/util.cpython-39.opt-2.pyc
a
    �DOg9,  �                   @   s(  d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d d	lmZ d d
lmZ d dlm
Z
 dd
lmZ ddlZddlZddlZddlZddlZdd� Zdd� Zd#dd�Zd$dd�Zedd� �Zdd� Zdd� Zdd� ZG dd � d ej�ZG d!d"� d"ej�Z dS )%�   )�abc)�module_from_spec)�
_resolve_name)�spec_from_loader)�
_find_spec)�MAGIC_NUMBER)�_RAW_MAGIC_NUMBER)�cache_from_source)�
decode_source)�source_from_cache)�spec_from_file_location�    )�contextmanagerNc                 C   s   t �t| �S �N)�_imp�source_hashr   )�source_bytes� r   �&/usr/lib64/python3.9/importlib/util.pyr      s    r   c                 C   s\   | � d�s| S |s&tdt| �� d���d}| D ]}|dkr> qH|d7 }q.t| |d � ||�S )N�.zno package specified for z% (required for relative module names)r
   r   )�
startswith�ImportError�reprr   )�name�package�level�	characterr   r   r   �resolve_name   s    
r   c                 C   sv   | t jvrt| |�S t j|  }|d u r*d S z
|j}W n" tyV   td�| ��d �Y n0 |d u rntd�| ���|S d S )N�{}.__spec__ is not set�{}.__spec__ is None)�sys�modulesr   �__spec__�AttributeError�
ValueError�format)r   �path�module�specr   r   r   �_find_spec_from_path*   s    
r)   c           	   
   C   s�   | � d�rt| |�n| }|tjvr�|�d�d }|r�t|dgd�}z
|j}W q� ty� } z&td|�d|��|d�|�W Y d }~q�d }~0 0 nd }t	||�S tj| }|d u r�d S z
|j
}W n" ty�   td�| ��d �Y n0 |d u r�td	�| ���|S d S )
Nr   r
   �__path__)�fromlistz __path__ attribute not found on z while trying to find )r   r   r   )
r   r   r    r!   �
rpartition�
__import__r*   r#   �ModuleNotFoundErrorr   r"