+
    di                     x    ] tR .t^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
 Rt]]J d   ]M]t ! R R 4      tR# )PluginManagerN)Plugin c                   V   a  ] tR t^"t o RtR tR t]R 4       tR t	R t
R
R ltR	tV tR# )r   z}Find and load plugins.

Plugins are stored in files named '*_plugin.py' in the list of directories
given to the constructor.
c                    Wn         \        V\        4      '       d$   \        R P	                  \        V4      4      4      h\        V4      V n        RV n        R# )zExpected sequence, got {}N)	_app
isinstance	STR_TYPES	TypeErrorformattypelist_plugin_dirs_plugins)selfappplugin_dirss   &&&</usr/lib/python3/dist-packages/janitor/plugincore/manager.py__init__PluginManager.__init__)   sL    	 k9--+2243DE  !-    c           	   #  R  "   V P                    F  p \        P                  ! V4       Uu. uF  pVP                  R4      '       g   K  VNK   	  pp\        P                  ! RP                  T\        P                  T4      4      4       \        T4       F$  p\        P                  P                  Y4      x  K&  	  K  	  R# u upi   \         dR   pTP
                  \
        P                  8w  d   h \        P                  ! RP                  T4      4        Rp?EK  Rp?ii ; i5i)z4Return all filenames in which plugins may be stored.z
_plugin.pyzNo such plugin directory: {}NzPlugin modules in {}: {})r   oslistdirendswithOSErrorerrnoENOENTloggingdebugr   SPACEjoinsortedpath)r   dirnamefilename	basenameserrors   &    r   get_plugin_filesPluginManager.get_plugin_files4   s      ((G
 %'JJw$7$7((6 H$7   MM*11UZZ	2 #9-ggll755 .% )
  ;;%,,.<CCGLM	sG   D'CC	CCA2D'CD$ADD'D$$D'c              #  D   "   V P                  4        F  pVx  K	  	  R # 5iN)r(   )r   r%   s   & r   plugin_filesPluginManager.plugin_filesL   s     --/HN 0s    c           	   #    "   R p\         P                  ! W4       UUu. uF  w  r4VNK	  	  ppp\        P                  ! RP	                  V\
        P                  R V 4       4      4      4       V F  pV! 4       x  K  	  R# u uppi 5i)z-Find and instantiate all plugins in a module.c                 ~    \         P                  ! V 4      ;'       d!    \        V \        4      ;'       d	    V \        J# r+   )inspectisclass
issubclassr   )targets   &r   	is_plugin.PluginManager._find_plugins.<locals>.is_pluginT   s;     ' ) )vv.) )&(r   zPlugins in {}: {}c              3   8   "   T F  p\        V4      x  K  	  R # 5ir+   )str).0plugins   & r   	<genexpr>.PluginManager._find_plugins.<locals>.<genexpr>a   s     "L^63v;;^s   N)r0   
getmembersr   r   r   r    r!   )r   moduler4   namememberplugin_classesplugin_classs   &&     r   _find_pluginsPluginManager._find_pluginsQ   s     	 (/'9'9&'L
'L|tF'L 	 
 	&&

"L^"LL	

 +L.  +
s   B	BAB	c           
     j   \         P                  ! RP                  V4      4       \        P                  P                  \        P                  P                  V4      4      w  r#V\        P                  9   d   \        P                  V,          # \        VR4      ;_uu_ 4       p \        P                  ! W$VRR\        P                  34      pVuuRRR4       #   \         d9   p\         P                  ! RP                  Y&4      4        Rp?RRR4       R# Rp?ii ; i  + '       g   i     R# ; i)zLoad a module from a filename.zLoading module from file {}rz.pyNzFailed to load plugin '{}' ({}))r   r   r   r   r#   splitextbasenamesysmodulesopenimpload_module	PY_SOURCE	Exceptionwarning)r   r%   module_nameignorefpr=   r'   s   &&     r   _load_modulePluginManager._load_moduleg   s    3::8DE& !gg..rww/?/?/IJ#++%;;{++(C  BXsCMM/J  ! 
  5<<#
  ! 
 !  s6   $D!&)CD!D&%DD!DD!!D2	Nc                Z   Vf   . pV P                   f   . V n         \        V P                  4      p\        V4      p\	        V4       Fq  w  rVVe
   V! WeV4       V P                  V4      pV P                  V4       F9  pVP                  V P                  4       V P                   P                  V4       K;  	  Ks  	  V P                    Uu. uF/  pVP                  V8X  g   WP                  9   g
   VR8X  g   K-  VNK1  	  p	p\        P                  ! RP                  W4      4       V	# u upi )a  Return all plugins that have been found.

Loaded plugins are cached, so they will only be loaded once.

`condition` is matched against each plugin to determine whether it
will be returned or not.  A `condition` of the string '*' matches all
plugins.  The default condition matches all default plugins, since by
default, plugins have a condition of the empty list.

If `condition` matches the plugin's condition exactly, the plugin is
returned.  The plugin's condition can also be a sequence, and if
`condition` is in that sequence, the plugin is returned.

Note that even though loaded plugins are cached, calling
`get_plugin()` with different a `condition` can return a different set
of plugins.

If `callback` is specified, it is called after each plugin has
been found, with the following arguments: filename, index of
filename in list of files to be examined (starting with 0), and
total number of files to be examined. The purpose of this is to
allow the callback to inform the user in case things take a long
time.
*z#plugins for condition '{}' are '{}')r   r   r,   len	enumeraterS   rB   set_applicationr   append	conditionr   r   r   )
r   r[   callback	filenamestotalir%   r=   r9   pluginss
   &&&       r   get_pluginsPluginManager.get_plugins   s   6 I == DMT../I	NE(3'X%0**84"008F**4995MM((0 9	  4 --
'  I- 0 00# F' 	 
 	188L	
 
s   
*D(9D()r   r   r   )NN)__name__
__module____qualname____firstlineno____doc__r   r(   propertyr,   rB   rS   ra   __static_attributes____classdictcell__)__classdict__s   @r   r   r   "   s=     	60  !,%N: :r   )r   __metaclass____all__r   rK   rH   r   r0   r   janitor.plugincore.pluginr   r    r7   bytesr	   r    r   r   <module>rq      sK     
 
 
 
    , 	%<CS	f fr   