summaryrefslogtreecommitdiff
path: root/src/plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugin.py')
-rw-r--r--src/plugin.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/plugin.py b/src/plugin.py
index 728dfe21..d64679a1 100644
--- a/src/plugin.py
+++ b/src/plugin.py
@@ -1,3 +1,26 @@
+import os
+from configparser import ConfigParser
+
+class PluginConfig(ConfigParser):
+ def __init__(self, filename):
+ ConfigParser.__init__(self)
+ self.__config_file__ = filename
+ self.read()
+
+ def read(self):
+ """Read the config file"""
+ ConfigParser.read(self, self.__config_file__)
+
+ def write(self):
+ """Write the config to the disk"""
+ try:
+ fp = open(self.__config_file__, 'w')
+ ConfigParser.write(self, fp)
+ fp.close()
+ return True
+ except IOError:
+ return False
+
class BasePlugin(object):
"""
Class that all plugins derive from. Any methods beginning with command_
@@ -5,9 +28,11 @@ class BasePlugin(object):
event handlers
"""
- def __init__(self, plugin_manager, core):
+ def __init__(self, plugin_manager, core, plugins_conf_dir):
self.core = core
self.plugin_manager = plugin_manager
+ conf = os.path.join(plugins_conf_dir, self.__module__+'.cfg')
+ self.config = PluginConfig(conf)
self.init()
def init(self):
@@ -17,6 +42,7 @@ class BasePlugin(object):
pass
def unload(self):
+
self.cleanup()
def add_command(self, name, handler, help, completion=None):