ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/importlib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/importlib/__pycache__/util.cpython-35.opt-1.pyc



C�MaS*�@s�dZddlmZddlmZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZdd	lmZdd
lm
Z
ddlmZdd
lmZddlZddlZddlZddlZdd�Zddd�Zddd�Zedd��Zdd�Zdd�Zdd�ZGdd�dej�ZGdd �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�_BACKCOMPAT_MAGIC_NUMBER)�cache_from_source)�
decode_source)�source_from_cache)�spec_from_file_location�)�contextmanagerNcCsv|jd�s|S|s.tdj|���d}x%|D]}|dkrNP|d7}q;Wt||d�||�S)z2Resolve a relative module name to an absolute one.�.z,{!r} is not a relative name (no leading dot)r
rN)�
startswith�
ValueError�formatr)�name�package�level�	character�r�3/opt/alt/python35/lib64/python3.5/importlib/util.py�resolve_names	
rcCs�|tjkrt||�Stj|}|dkr9dSy
|j}Wn*tk
rrtdj|��d�Yn&X|dkr�tdj|���|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__�AttributeErrorrr)r�path�module�specrrr�_find_spec_from_path#s



r!cCs|jd�rt||�n|}|tjkr�|jd�d}|rqt|ddg�}t||j�St|d�Sn|tj|}|dkr�dSy
|j}Wn*t	k
r�t
dj|��d�Yn&X|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
�fromlist�__path__Nz{}.__spec__ is not setz{}.__spec__ is None)rrrr�
rpartition�
__import__rr#rrrr)rr�fullname�parent_name�parentrr rrr�	find_specBs"$


r)ccs�|tjk}tjj|�}|sOtt�|�}d|_|tj|<zKy	|VWn;tk
r�|s�ytj|=Wntk
r�YnXYnXWdd|_XdS)NTF)rr�get�type�__initializing__�	Exception�KeyError)r�	is_reloadrrrr�_module_to_loadjs	
	

r0cs%tj���fdd��}|S)zOSet __package__ on the returned module.

    This function is deprecated.

    csutjdtdd��||�}t|dd�dkrq|j|_t|d�sq|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@cs%tj���fdd��}|S)zNSet __loader__ on the returned module.

    This function is deprecated.

    csMtjdtdd��|||�}t|dd�dkrI||_|S)Nz7The import system now takes care of this automatically.r1r2�
__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�s!rDcs;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.r1r2cs�t|��y}||_y|j|�}Wnttfk
rEYn)X|rX||_n|jd�d|_�||||�SWdQRXdS)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@seZdZdZdS)�_Modulez>A subclass of the module type to allow __class__ manipulation.N)r8�
__module__�__qualname__�__doc__rrrrrI�srIc@s.eZdZdZdd�Zdd�ZdS)�_LazyModulezKA subclass of the module type which triggers loading upon attribute access.c	Cs	t|_|jj}|jj}|j}i}x]|j�D]O\}}||krb|||<q=t||�t||�kr=|||<q=W|jjj	|�|t
jkr�t|�tt
j|�kr�d}t|j
|���|jj|�t||�S)z8Trigger the load of the module and return the attribute.zDmodule object for {!r} substituted in sys.modules during a lazy load)rI�	__class__rr�loader_state�__dict__�items�id�loader�exec_modulerrrr�updater7)	rB�attr�
original_name�
attrs_then�	attrs_now�
attrs_updated�key�value�msgrrr�__getattribute__�s"		
 z_LazyModule.__getattribute__cCs|j|�t||�dS)z/Trigger the load and then perform the deletion.N)r^�delattr)rBrVrrr�__delattr__�s
z_LazyModule.__delattr__N)r8rJrKrLr^r`rrrrrM�s"rMc@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)NrTz loader must define exec_module())r9�	TypeError)rSrrr�__check_eager_loaderszLazyLoader.__check_eager_loadercs �j����fdd�S)z>Construct a callable which returns the eager loader made lazy.cs��||��S)Nr)r:r;)�clsrSrr�<lambda>sz$LazyLoader.factory.<locals>.<lambda>)�_LazyLoader__check_eager_loader)rdrSr)rdrSr�factorys
zLazyLoader.factorycCs|j|�||_dS)N)rfrS)rBrSrrr�__init__s
zLazyLoader.__init__cCs
t|j�S)z9Create a module which can have its __class__ manipulated.)rIr)rBr rrr�
create_moduleszLazyLoader.create_modulecCs=|j|j_|j|_|jj�|j_t|_dS)zMake the module load lazily.N)rSrrArP�copyrOrMrN)rBrrrrrTszLazyLoader.exec_moduleN)r8rJrKrL�staticmethodrf�classmethodrgrhrirTrrrrrasra)!rL�r�
_bootstraprrrr�_bootstrap_externalrrr	r
rr�
contextlibrr>r�typesr4rr!r)r0r@rDrH�
ModuleTyperIrM�Loaderrarrrr�<module>s2('.

Zerion Mini Shell 1.0