summaryrefslogtreecommitdiff
path: root/src/plugin_manager.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-09-24 23:10:55 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-09-24 23:10:55 +0200
commiteb096892a9ab3429ba0dcb9654a356afcd01932d (patch)
tree417999d8be157a54822bc391f6d55edfa099cf18 /src/plugin_manager.py
parent9a8d0bd5bfbbb850fb0233f2ae384dfd57ff3d44 (diff)
downloadpoezio-eb096892a9ab3429ba0dcb9654a356afcd01932d.tar.gz
poezio-eb096892a9ab3429ba0dcb9654a356afcd01932d.tar.bz2
poezio-eb096892a9ab3429ba0dcb9654a356afcd01932d.tar.xz
poezio-eb096892a9ab3429ba0dcb9654a356afcd01932d.zip
Completion for load and unload commands
Diffstat (limited to 'src/plugin_manager.py')
-rw-r--r--src/plugin_manager.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/plugin_manager.py b/src/plugin_manager.py
index 8301f5f8..2a7a116f 100644
--- a/src/plugin_manager.py
+++ b/src/plugin_manager.py
@@ -40,7 +40,7 @@ class PluginManager(object):
imp.release_lock()
except Exception as e:
import traceback
- self.core.information(_("Could not load plugin: ") + traceback.format_exc())
+ self.core.information(_("Could not load plugin: ") + traceback.format_exc(), 'Error')
return
finally:
if imp.lock_held():
@@ -84,3 +84,22 @@ class PluginManager(object):
self.core.xmpp.del_event_handler(event_name, handler)
eh = self.event_handlers[module_name]
eh = list(filter(lambda e : e != (event_name, handler), eh))
+
+ def completion_load(self, the_input):
+ """
+ completion function that completes the name of the plugins, from
+ all .py files in plugins_dir
+ """
+ try:
+ names = os.listdir(plugins_dir)
+ except OSError as e:
+ self.core.information(_('Completion failed: %s' % e), 'Error')
+ return
+ plugins_files = [name[:-3] for name in names if name.endswith('.py')]
+ return the_input.auto_completion(plugins_files, '')
+
+ def completion_unload(self, the_input):
+ """
+ completion function that completes the name of the plugins that are loaded
+ """
+ return the_input.auto_completion(list(self.plugins.keys()), '')