
    G@d                         d Z ddlZddlZddlZddlmZ ddlZddlZddl	m
Z
 ddlmZ  ej        e          ZdZdZedz   Zdd	Zd
 Zd Zd Z G d d          ZdS )z6
Spyder third-party plugins configuration management.
    N)get_conf_path)to_text_stringpluginsspyder_io_Fc                     t          j        t                      t                    }t          j        |          st          j        |           g g }}|gt          j        z   D ]}t          || ||           |S )z7Import modules from plugins package and return the list)
ospjoinr   USER_PLUGIN_DIRisdirosmakedirssyspath_get_spyderplugins)iouser_plugin_pathmodlistmodnamesplugin_paths        3lib/python3.11/site-packages/spyder/otherplugins.pyget_spyderplugins_modsr      s~     xAA9%&& &
$%%%BXG ))CH4 ? ?;Hg>>>>N    c                 6   t          j        |           sdS t          j        |           D ]l                    t
                    s|r                    t                    s:g d}t          fd|D                       rZt          | ||           mdS )zDScan the directory `plugin_path` for plugin packages and loads them.N)z	dist-infozegg.infozegg-infozegg-linkkernelsboilerplatec                 :    g | ]}                     |          S  )endswith).0snames     r   
<listcomp>z&_get_spyderplugins.<locals>.<listcomp>A   s%    ===Qa  ===r   )	r	   r   r   listdir
startswithPLUGIN_PREFIX	IO_PREFIXany_import_plugin)r   is_ior   r   forbidden_suffixesr"   s        @r   r   r   .   s    9[!! 
;'' = = }-- 	  	33 	8 8 8====*<===>> 	 	t[(G<<<<%= =r   c                 j   | |v rdS 	 t                      }t          j        || d          |_        |t          j        | <   t          j        t          j        ||                     rt          | |          }nd}|rLt          |dd          r=|t          j        | <   |	                    |           |	                    |            dS dS dS # t          $ r\}t          j                            d                    |                      t          j        t          j                   Y d}~dS d}~ww xY w)zqImport the plugin `module_name` from `plugin_path`, add it to `modlist`
    and adds its name to `modnames`.
    NlocalePLUGIN_CLASSFz0ERROR: 3rd party plugin import failed for `{0}`
)file)_ModuleMockr	   r
   
LOCALEPATHr   modulesr   _import_module_from_pathgetattrappend	Exceptionstderrwriteformat	traceback	print_exc)module_namer   r   r   mockmodulees          r   r)   r)   H   sU    h- }}(;XFF#'K 9SXk;7788 	-k;GGFFF  	)gfne<< 	)'-CK$NN6"""OOK(((((	) 	) 	) 	)  - - -
 ##)6+#6#6	8 	8 	8,,,,,,,,,,-s   B>C 
D2AD--D2c                 <   d}	 t           j        j                            | |g          }|r|j                            |           }nU# t          $ rH}d                    | t          |                    }t          
                    |           Y d}~nd}~ww xY w|S )zVImports `module_name` from `plugin_path`.

    Return None if no module is found.
    Nz0plugin: '{module_name}' load failed with `{err}`)r<   err)	importlib	machinery
PathFinder	find_specloaderload_moduler6   r9   r   loggerdebug)r<   r   r>   specrA   debug_messages         r   r3   r3   e   s    
 F$"-77M   	:[,,[99F $ $ $#V(6s(;(; $ = = 	 	]########	$ Ms   AA 
B>BBc                       e Zd ZdZdS )r0   zThis 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.
    N)__name__
__module____qualname____doc__r   r   r   r0   r0   {   s          	Dr   r0   )F)rP   rB   loggingr   os.pathr   r	   r   r:   spyder.config.baser   spyder.py3compatr   	getLoggerrM   rH   r   r&   r'   r   r   r)   r3   r0   r   r   r   <module>rV      s   
      				       



     - , , , , , + + + + + + 
	8	$	$E!	   = = =4- - -:  ,	 	 	 	 	 	 	 	 	 	r   