MINI MINI MANI MO
3
  \*                 @   s  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlm
Z
 dd
lmZ ddlZddlZddlZddlZdd Zd!ddZd"ddZedd Zdd Zdd Zdd ZG dd dejZG dd  d ejZdS )#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    )contextmanagerNc             C   s^   | j ds| S |s&tdt|  dd}x| D ]}|dkr>P |d7 }q0W t| |d ||S )z2Resolve a relative module name to an absolute one..zno package specified for z% (required for relative module names)r   r   N)
startswith
ValueErrorreprr   )namepackagelevel	character r   &/usr/lib64/python3.6/importlib/util.pyresolve_name   s    
r   c             C   sx   | t jkrt| |S t j|  }|dkr*dS y
|j}W n$ tk
rX   tdj| dY nX |dkrptdj| |S dS )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)sysmodulesr   __spec__AttributeErrorr   format)r   pathmodulespecr   r   r   _find_spec_from_path#   s    
r!   c             C   s   | j drt| |n| }|tjkrZ|jdd }|rNt|dgd}t||jS t|dS n`tj| }|dkrpdS y
|j}W n$ t	k
r   t
dj| dY nX |dkrt
dj| |S dS )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   __path__)fromlistNz{}.__spec__ is not setz{}.__spec__ is None)r   r   r   r   
rpartition
__import__r   r"