ó
‹²,]c           @   sÎ   d  Z  d d l Z d d l j Z d d l Z d d l Z d d l m Z d d l	 m
 Z
 e
 rn d d l Z n d d l Z d Z d Z e d Z e d „ Z d	 „  Z d
 „  Z d „  Z d d d „  ƒ  YZ d S(   s5   
Spyder third-party plugins configuration management
iÿÿÿÿN(   t   get_conf_path(   t   PY2t   pluginst   spyder_t   io_c         C   ss   t  j t ƒ  t ƒ } t  j | ƒ s4 t j | ƒ n  g  g  } } x+ | g t j D] } t	 | |  | | ƒ qR W| S(   s7   Import modules from plugins package and return the list(
   t   ospt   joinR    t   USER_PLUGIN_DIRt   isdirt   ost   makedirst   syst   patht   _get_spyderplugins(   t   iot   user_plugin_patht   modlistt   modnamest   plugin_path(    (    s2   lib/python2.7/site-packages/spyder/otherplugins.pyt   get_spyderplugins_mods   s    c         C   s·   t  j |  ƒ s d Sx t j |  ƒ D]Œ } | j t ƒ s> q# n  | | j t ƒ k rY q# n  d d d d d g } t g  | D] } | j | ƒ ^ qx ƒ rœ q# n  t	 | |  | | ƒ q# Wd S(   sD   Scan the directory `plugin_path` for plugin packages and loads them.Ns	   dist-infos   egg.infos   egg-infos   egg-linkt   kernels(
   R   R   R	   t   listdirt
   startswitht   PLUGIN_PREFIXt	   IO_PREFIXt   anyt   endswitht   _import_plugin(   R   t   is_ioR   R   t   namet   forbidden_suffixest   s(    (    s2   lib/python2.7/site-packages/spyder/otherplugins.pyR   .   s    	(c         C   sû   |  | k r d Sy§ t  ƒ  } t j | |  d ƒ | _ | t j |  <t j t j | |  ƒ ƒ rn t |  | ƒ } n d } | r¶ t	 | d t
 ƒ r¶ | t j |  <| j | ƒ | j |  ƒ n  Wn= t k
 rö t j j d j |  ƒ ƒ t j d t j ƒ n Xd S(   sq   Import the plugin `module_name` from `plugin_path`, add it to `modlist`
    and adds its name to `modnames`.
    Nt   localet   PLUGIN_CLASSs0   ERROR: 3rd party plugin import failed for `{0}`
t   file(   t   _ModuleMockR   R   t
   LOCALEPATHR   t   modulesR   t   _import_module_from_patht   Nonet   getattrt   Falset   appendt	   Exceptiont   stderrt   writet   formatt	   tracebackt	   print_exc(   t   module_nameR   R   R   t   mockt   module(    (    s2   lib/python2.7/site-packages/spyder/otherplugins.pyR   H   s"    	
c         C   s‘   d } ys t rB t j |  | g ƒ } | rx t j |  | Œ } qx n6 t j j j |  | g ƒ } | rx | j	 j |  ƒ } n  Wn t
 k
 rŒ n X| S(   sV   Imports `module_name` from `plugin_path`.

    Return None if no module is found.
    N(   R'   R   t   impt   find_modulet   load_modulet	   importlibt	   machineryt
   PathFindert	   find_spect   loaderR+   (   R1   R   R3   t   infot   spec(    (    s2   lib/python2.7/site-packages/spyder/otherplugins.pyR&   e   s    R#   c           B   s   e  Z d  Z RS(   s×   This mock module is added to sys.modules on plugin load to add the
    location of the LOCALEDATA so that the module loads succesfully.
    Once loaded the module is replaced by the actual loaded module object.
    (   t   __name__t
   __module__t   __doc__(    (    (    s2   lib/python2.7/site-packages/spyder/otherplugins.pyR#   |   s   (    (   R@   R	   t   os.pathR   R   R   R/   t   spyder.config.baseR    t   spyder.py3compatR   R4   R7   R   R   R   R)   R   R   R   R&   R#   (    (    (    s2   lib/python2.7/site-packages/spyder/otherplugins.pyt   <module>	   s"   
			