1111from typing import Tuple , Dict , Any , Type , Set , List , Optional , Callable
1212
1313from errbot .flow import BotFlow , Flow
14- from errbot .repo_manager import BotRepoManager , check_dependencies
14+ from errbot .repo_manager import check_dependencies
1515from errbot .storage .base import StoragePluginBase
1616from .botplugin import BotPlugin
1717from .plugin_info import PluginInfo
2121from .core_plugins .wsview import route
2222from .storage import StoreMixin
2323
24+ PluginInstanceCallback = Callable [[str , Type [BotPlugin ]], BotPlugin ]
25+
2426log = logging .getLogger (__name__ )
2527
2628CORE_PLUGINS = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'core_plugins' )
@@ -131,11 +133,10 @@ class BotPluginManager(StoreMixin):
131133
132134 def __init__ (self ,
133135 storage_plugin : StoragePluginBase ,
134- repo_manager : BotRepoManager ,
135136 extra_plugin_dir : Optional [str ],
136137 autoinstall_deps : bool ,
137138 core_plugins : Tuple [str , ...],
138- plugin_instance_callback : Callable [[ str , Type [ BotPlugin ]], BotPlugin ] ,
139+ plugin_instance_callback : PluginInstanceCallback ,
139140 plugins_callback_order : Tuple [Optional [str ], ...]):
140141 """
141142 Creates a Plugin manager
@@ -148,16 +149,15 @@ def __init__(self,
148149 :param plugins_callback_order: the order on which the plugins will be callbacked
149150 """
150151 super ().__init__ ()
151- self .autoinstall_deps = autoinstall_deps
152- self ._extra_plugin_dir = extra_plugin_dir
153- self ._plugin_instance_callback = plugin_instance_callback
154- self .core_plugins = core_plugins
152+ self .autoinstall_deps : bool = autoinstall_deps
153+ self ._extra_plugin_dir : str = extra_plugin_dir
154+ self ._plugin_instance_callback : PluginInstanceCallback = plugin_instance_callback
155+ self .core_plugins : Tuple [ str , ...] = core_plugins
155156 # Make sure there is a 'None' entry in the callback order, to include
156157 # any plugin not explicitly ordered.
157158 self .plugins_callback_order = plugins_callback_order
158159 if None not in self .plugins_callback_order :
159160 self .plugins_callback_order += (None ,)
160- self .repo_manager = repo_manager
161161 self .plugin_infos : Dict [str , PluginInfo ] = {}
162162 self .plugins : Dict [str , BotPlugin ] = {}
163163 self .flow_infos : Dict [str , PluginInfo ] = {}
@@ -255,7 +255,12 @@ def _load_plugins(self) -> Dict[Path, str]:
255255 self .flows , self .flow_infos , feedback )
256256 return feedback
257257
258- def _update_plugin_places (self , path_list ) -> Dict [Path , str ]:
258+ def update_plugin_places (self , path_list ) -> Dict [Path , str ]:
259+ """
260+ This updates where this manager is trying to find plugins and try to load newly found ones.
261+ :param path_list: the path list where to search for plugins.
262+ :return: the feedback for any specific path in case of error.
263+ """
259264 repo_roots = (CORE_PLUGINS , self ._extra_plugin_dir , path_list )
260265
261266 all_roots = collect_roots (repo_roots )
@@ -335,11 +340,6 @@ def set_plugin_configuration(self, name, obj):
335340 configs [name ] = obj
336341 self [CONFIGS ] = configs
337342
338- # this will load the plugins the admin has setup at runtime
339- def update_dynamic_plugins (self ):
340- """ It returns a dictionary of path -> error strings."""
341- return self ._update_plugin_places (self .repo_manager .get_all_repos_paths ())
342-
343343 def activate_non_started_plugins (self ):
344344 """
345345 Activates all plugins that are not activated, respecting its dependencies.
0 commit comments