Your IP : 3.17.78.184


Current Path : /opt/alt/python34/lib64/python3.4/importlib/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/importlib/__pycache__/util.cpython-34.pyo

�
e f;�@sdZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	d
dl
mZd
dlZd
dl
Z
d
dlZd
d�Zddd�Zddd�Zedd��Zdd�Zdd�Zdd�ZdS)z-Utility code for constructing importers, etc.�)�MAGIC_NUMBER)�cache_from_source)�
decode_source)�source_from_cache)�spec_from_loader)�spec_from_file_location)�
_resolve_name)�
_find_spec�)�contextmanagerNcCs||jd�s|S|s1tdj|���nd}x(|D] }|dkrTPn|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/python34/lib64/python3.4/importlib/util.py�resolve_names	
rcCs�|tjkrt||�Stj|}|dkr9dSy
|j}Wn'tk
rotdj|���Yn)X|dkr�tdj|���n|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



rcCs|jd�rt||�n|}|tjkr�|jd�d}|rqt|ddg�}t||j�St|d�Sn|tj|}|dkr�dSy
|j}Wn't	k
r�t
dj|���Yn)X|dkr�t
dj|���n|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.

    rr
�fromlist�__path__Nz{}.__spec__ is not setz{}.__spec__ is None)r
rrr�
rpartition�
__import__r	r rrrr)rr�fullname�parent_name�parentrrrrr�	find_spec@s"$


r&ccs�|tjk}tjj|�}|sRtt�|�}d|_|tj|<nzNy	|VWn>tk
r�|s�ytj|=Wq�tk
r�Yq�XnYnXWdd|_XdS)NTF)rr�get�type�__initializing__�	Exception�KeyError)r�	is_reloadrrrr�_module_to_loadhs		

r-cs%tj���fdd��}|S)zOSet __package__ on the returned module.

    This function is deprecated.

    cs{tjdtdd��||�}t|dd�dkrw|j|_t|d�sw|jjd�d|_qwn|S)Nz7The import system now takes care of this automatically.�
stacklevel��__package__r rr
)�warnings�warn�DeprecationWarning�getattr�__name__r0�hasattrr!)�args�kwargsr)�fxnrr�set_package_wrapper�s	
z(set_package.<locals>.set_package_wrapper)�	functools�wraps)r9r:r)r9r�set_package�s!
r=cs%tj���fdd��}|S)zNSet __loader__ on the returned module.

    This function is deprecated.

    csPtjdtdd��|||�}t|dd�dkrL||_n|S)Nz7The import system now takes care of this automatically.r.r/�
__loader__)r1r2r3r4r>)�selfr7r8r)r9rr�set_loader_wrapper�s	
z&set_loader.<locals>.set_loader_wrapper)r;r<)r9r@r)r9r�
set_loader�s!rAcs;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.r.r/cs�t|��y}||_y|j|�}Wnttfk
rEYn)X|rX||_n|jd�d|_�||||�SWdQXdS)Nrr
)r-r>�
is_package�ImportErrorrr0r!)r?r#r7r8rrB)r9rr�module_for_loader_wrapper�s	z4module_for_loader.<locals>.module_for_loader_wrapper)r1r2r3r;r<)r9rDr)r9r�module_for_loader�s	
!rE)�__doc__�
_bootstraprrrrrrrr	�
contextlibrr;rr1rrr&r-r=rArErrrr�<module>s&(

?>