AlkantarClanX12

Your IP : 3.145.112.23


Current Path : /proc/thread-self/root/lib64/python3.6/importlib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/lib64/python3.6/importlib/__pycache__/util.cpython-36.pyc

3


 \�*�@sdZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddlm
Z
dd
lmZddlZddlZddlZddlZdd�Zd!dd�Zd"dd�Zedd��Zdd�Zdd�Zdd�ZGdd�dej�ZGdd �d ej�ZdS)#z-Utility code for constructing importers, etc.�)�abc)�module_from_spec)�
_resolve_name)�spec_from_loader)�
_find_spec)�MAGIC_NUMBER)�cache_from_source)�
decode_source)�source_from_cache)�spec_from_file_location�)�contextmanagerNcCs^|jd�s|S|s&tdt|��d���d}x|D]}|dkr>P|d7}q0Wt||d�||�S)z2Resolve a relative module name to an absolute one.�.zno package specified for z% (required for relative module names)rrN)�
startswith�
ValueError�reprr)�name�package�level�	character�r�&/usr/lib64/python3.6/importlib/util.py�resolve_names

rcCsx|tjkrt||�Stj|}|dkr*dSy
|j}Wn$tk
rXtdj|��d�YnX|dkrptdj|���|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.

    Nz{}.__spec__ is not setz{}.__spec__ is None)�sys�modulesr�__spec__�AttributeErrorr�format)r�path�module�specrrr�_find_spec_from_path#s



r!cCs�|jd�rt||�n|}|tjkrZ|jd�d}|rNt|dgd�}t||j�St|d�Sn`tj|}|dkrpdSy
|j}Wn$t	k
r�t
dj|��d�YnX|dkr�t
dj|���|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__)�fromlistNz{}.__spec__ is not setz{}.__spec__ is None)rrrr�
rpartition�
__import__rr"rrrr)rr�fullname�parent_name�parentrr rrr�	find_specBs"


r)ccs�|tjk}tjj|�}|s6tt�|�}d|_|tj|<zJy
|VWn:tk
r||sxytj|=Wntk
rvYnXYnXWdd|_XdS)NTF)rr�get�type�__initializing__�	Exception�KeyError)r�	is_reloadrrrr�_module_to_loadjs


r0cstj���fdd��}|S)zOSet __package__ on the returned module.

    This function is deprecated.

    csRtjdtdd��||�}t|dd�dkrN|j|_t|d�sN|jjd�d|_|S)Nz7The import system now takes care of this automatically.�)�
stacklevel�__package__r"rr)�warnings�warn�DeprecationWarning�getattr�__name__r3�hasattrr$)�args�kwargsr)�fxnrr�set_package_wrapper�s


z(set_package.<locals>.set_package_wrapper)�	functools�wraps)r<r=r)r<r�set_package�s
r@cstj���fdd��}|S)zNSet __loader__ on the returned module.

    This function is deprecated.

    cs:tjdtdd��|f|�|�}t|dd�dkr6||_|S)Nz7The import system now takes care of this automatically.r1)r2�
__loader__)r4r5r6r7rA)�selfr:r;r)r<rr�set_loader_wrapper�s
z&set_loader.<locals>.set_loader_wrapper)r>r?)r<rCr)r<r�
set_loader�srDcs*tjdtdd�tj���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.

    z7The import system now takes care of this automatically.r1)r2cspt|��^}||_y|j|�}Wnttfk
r6YnX|rD||_n|jd�d|_�||f|�|�SQRXdS)Nrr)r0rA�
is_package�ImportErrorrr3r$)rBr&r:r;rrE)r<rr�module_for_loader_wrapper�s
z4module_for_loader.<locals>.module_for_loader_wrapper)r4r5r6r>r?)r<rGr)r<r�module_for_loader�s
rHc@s eZdZdZdd�Zdd�ZdS)�_LazyModulezKA subclass of the module type which triggers loading upon attribute access.c	Cs�tj|_|jj}|jjd}|jjd}|j}i}xF|j�D]:\}}||krV|||<q<t||�t||�kr<|||<q<W|jj	j
|�|tjkr�t|�ttj|�kr�t
d|�d���|jj|�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�
ModuleTyperKrr�loader_staterJ�items�id�loader�exec_modulerrr�updater7)	rB�attr�
original_name�
attrs_then�
original_type�	attrs_now�
attrs_updated�key�valuerrr�__getattribute__�s"

z_LazyModule.__getattribute__cCs|j|�t||�dS)z/Trigger the load and then perform the deletion.N)r\�delattr)rBrTrrr�__delattr__�s
z_LazyModule.__delattr__N)r8�
__module__�__qualname__�__doc__r\r^rrrrrI�s#rIc@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)NrRz loader must define exec_module())r9�	TypeError)rQrrr�__check_eager_loaders
zLazyLoader.__check_eager_loadercs�j����fdd�S)z>Construct a callable which returns the eager loader made lazy.cs��||��S)Nr)r:r;)�clsrQrr�<lambda>sz$LazyLoader.factory.<locals>.<lambda>)�_LazyLoader__check_eager_loader)rerQr)rerQr�factorys
zLazyLoader.factorycCs|j|�||_dS)N)rgrQ)rBrQrrr�__init__
s
zLazyLoader.__init__cCs|jj|�S)N)rQ�
create_module)rBr rrrrjszLazyLoader.create_modulecCs@|j|j_|j|_i}|jj�|d<|j|d<||j_t|_dS)zMake the module load lazily.rJrKN)rQrrArJ�copyrKrNrI)rBrrNrrrrRs

zLazyLoader.exec_moduleN)r8r_r`ra�staticmethodrg�classmethodrhrirjrRrrrrrb�srb)N)N)ra�r�
_bootstraprrrr�_bootstrap_externalrrr	r
r�
contextlibr
r>rrLr4rr!r)r0r@rDrHrMrI�Loaderrbrrrr�<module>s0

('/