AlkantarClanX12

Your IP : 18.119.162.226


Current Path : /opt/alt/python39/lib64/python3.9/importlib/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/importlib/__pycache__/util.cpython-39.opt-1.pyc

a

R�f9,�@s,dZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddlm
Z
ddlmZd
dlmZd
dlZd
dlZd
dlZd
dlZd
dlZdd�Zdd�Zd$dd�Zd%dd�Zedd��Zdd�Zdd�Zdd�ZGd d!�d!ej�ZGd"d#�d#ej �Z!dS)&z-Utility code for constructing importers, etc.�)�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�)�contextmanagerNcCst�t|�S)zBReturn the hash of *source_bytes* as used in hash-based pyc files.)�_imp�source_hashr)�source_bytes�r�3/opt/alt/python39/lib64/python3.9/importlib/util.pyrsrcCs\|�d�s|S|s&tdt|��d���d}|D]}|dkr>qH|d7}q.t||d�||�S)z2Resolve a relative module name to an absolute one.�.zno package specified for z% (required for relative module names)r
rN)�
startswith�ImportError�reprr)�name�package�level�	characterrrr�resolve_names

rcCsv|tjvrt||�Stj|}|dur*dSz
|j}Wn"tyVtd�|��d�Yn0|durntd�|���|SdS)a�Return the spec for the specified module.

    First, sys.modules is checked to see if the module was already imported. If
    so, then sys.modules[name].__spec__ is returned. If that happens to be
    set to None, then ValueError is raised. If the module is not in
    sys.modules, then sys.meta_path is searched for a suitable spec with the
    value of 'path' given to the finders. None is returned if no spec could
    be found.

    Dotted names do not have their parent packages implicitly imported. You will
    most likely need to explicitly import all parent packages in the proper
    order for a submodule to get the correct spec.

    N�{}.__spec__ is not set�{}.__spec__ is None)�sys�modulesr�__spec__�AttributeError�
ValueError�format)r�path�module�specrrr�_find_spec_from_path*s



r(c	
Cs�|�d�rt||�n|}|tjvr�|�d�d}|r�t|dgd�}z
|j}Wq�ty�}z&td|�d|��|d�|�WYd}~q�d}~00nd}t	||�Stj|}|dur�dSz
|j
}Wn"ty�td	�|��d�Yn0|dur�td
�|���|SdS)a�Return the spec for the specified module.

    First, sys.modules is checked to see if the module was already imported. If
    so, then sys.modules[name].__spec__ is returned. If that happens to be
    set to None, then ValueError is raised. If the module is not in
    sys.modules, then sys.meta_path is searched for a suitable spec with the
    value of 'path' given to the finders. None is returned if no spec could
    be found.

    If the name is for submodule (contains a dot), the parent module is
    automatically imported.

    The name and package arguments work the same as importlib.import_module().
    In other words, relative module names (with leading dots) work.

    rr
�__path__)�fromlistz __path__ attribute not found on z while trying to find )rNrr)
rrrr �
rpartition�
__import__r)r"�ModuleNotFoundErrorrr!r#r$)	rr�fullname�parent_name�parent�parent_path�er&r'rrr�	find_specIs8

���


r3ccs�|tjv}tj�|�}|s6tt�|�}d|_|tj|<zLz
|VWn6tyx|stztj|=WntyrYn0Yn0Wd|_nd|_0dS)NTF)rr �get�type�__initializing__�	Exception�KeyError)r�	is_reloadr&rrr�_module_to_loadvs


r:cst����fdd��}|S)zOSet __package__ on the returned module.

    This function is deprecated.

    csVtjdtdd��|i|��}t|dd�durR|j|_t|d�sR|j�d�d|_|S)N�7The import system now takes care of this automatically.���
stacklevel�__package__r)rr
)�warnings�warn�DeprecationWarning�getattr�__name__r?�hasattrr+)�args�kwargsr&��fxnrr�set_package_wrapper�s�
z(set_package.<locals>.set_package_wrapper��	functools�wraps)rIrJrrHr�set_package�s	rNcst����fdd��}|S)zNSet __loader__ on the returned module.

    This function is deprecated.

    cs@tjdtdd��|g|�Ri|��}t|dd�dur<||_|S)Nr;r<r=�
__loader__)r@rArBrCrO)�selfrFrGr&rHrr�set_loader_wrapper�s�z&set_loader.<locals>.set_loader_wrapperrK)rIrQrrHr�
set_loader�srRcs*tjdtdd�t����fdd��}|S)a*Decorator to handle selecting the proper module for loaders.

    The decorated function is passed the module to use instead of the module
    name. The module passed in to the function is either from sys.modules if
    it already exists or is a new module. If the module is new, then __name__
    is set the first argument to the method, __loader__ is set to self, and
    __package__ is set accordingly (if self.is_package() is defined) will be set
    before it is passed to the decorated function (if self.is_package() does
    not work for the module it will be set post-load).

    If an exception is raised and the decorator created the module it is
    subsequently removed from sys.modules.

    The decorator assumes that the decorated function takes the module name as
    the second argument.

    r;r<r=c
s�t|��p}||_z|�|�}Wnttfy4Yn0|rB||_n|�d�d|_�||g|�Ri|��Wd�S1s~0YdS)Nrr
)r:rO�
is_packagerr"r?r+)rPr.rFrGr&rSrHrr�module_for_loader_wrapper�s
z4module_for_loader.<locals>.module_for_loader_wrapper)r@rArBrLrM)rIrTrrHr�module_for_loader�s�rUc@s eZdZdZdd�Zdd�ZdS)�_LazyModulezKA subclass of the module type which triggers loading upon attribute access.c	Cs�tj|_|jj}|jjd}|jjd}|j}i}|��D]:\}}||vrT|||<q:t||�t||�kr:|||<q:|jj	�
|�|tjvr�t|�ttj|�kr�t
d|�d���|j�|�t||�S)z8Trigger the load of the module and return the attribute.�__dict__�	__class__zmodule object for z. substituted in sys.modules during a lazy load)�types�
ModuleTyperXr!r�loader_staterW�items�id�loader�exec_modulerr r#�updaterC)	rP�attr�
original_name�
attrs_then�
original_type�	attrs_now�
attrs_updated�key�valuerrr�__getattribute__�s"


z_LazyModule.__getattribute__cCs|�|�t||�dS)z/Trigger the load and then perform the deletion.N)ri�delattr)rPrarrr�__delattr__s
z_LazyModule.__delattr__N)rD�
__module__�__qualname__�__doc__rirkrrrrrV�s#rVc@s@eZdZdZedd��Zedd��Zdd�Zdd	�Z	d
d�Z
dS)
�
LazyLoaderzKA loader that creates a module which defers loading until attribute access.cCst|d�std��dS)Nr_z loader must define exec_module())rE�	TypeError)r^rrr�__check_eager_loaders
zLazyLoader.__check_eager_loadercs������fdd�S)z>Construct a callable which returns the eager loader made lazy.cs��|i|���S�Nr)rFrG��clsr^rr�<lambda>�z$LazyLoader.factory.<locals>.<lambda>)�_LazyLoader__check_eager_loaderrsrrsr�factorys
zLazyLoader.factorycCs|�|�||_dSrr)rwr^)rPr^rrr�__init__s
zLazyLoader.__init__cCs|j�|�Srr)r^�
create_module)rPr'rrrrzszLazyLoader.create_modulecCs@|j|j_|j|_i}|j��|d<|j|d<||j_t|_dS)zMake the module load lazily.rWrXN)r^r!rOrW�copyrXr[rV)rPr&r[rrrr_ s

zLazyLoader.exec_moduleN)rDrlrmrn�staticmethodrw�classmethodrxryrzr_rrrrro
s

ro)N)N)"rn�r�
_bootstraprrrr�_bootstrap_externalrrr	r
rr�
contextlibrrrLrrYr@rrr(r3r:rNrRrUrZrV�Loaderrorrrr�<module>s8

-
'/