summaryrefslogtreecommitdiff
path: root/src/plugin.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-13 18:39:07 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-13 18:39:07 +0100
commit3ea5eb6163181ba016cfddcc616a171d7f309e76 (patch)
tree696fef8697181b96616d7953195c4324d1834cfa /src/plugin.py
parent35335ccb5b0ef743228ac25bffcc16ffc090ad55 (diff)
parentc4f7d9b98a229ad52e834313ab93f0f9ebc77884 (diff)
downloadpoezio-3ea5eb6163181ba016cfddcc616a171d7f309e76.tar.gz
poezio-3ea5eb6163181ba016cfddcc616a171d7f309e76.tar.bz2
poezio-3ea5eb6163181ba016cfddcc616a171d7f309e76.tar.xz
poezio-3ea5eb6163181ba016cfddcc616a171d7f309e76.zip
Merge branch 'master' of http://git.louiz.org/poezio
Diffstat (limited to 'src/plugin.py')
-rw-r--r--src/plugin.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/plugin.py b/src/plugin.py
index 4dd88697..92adbc4b 100644
--- a/src/plugin.py
+++ b/src/plugin.py
@@ -1,24 +1,27 @@
import os
-from configparser import ConfigParser
+from configparser import RawConfigParser
import config
import inspect
import traceback
class PluginConfig(config.Config):
- def __init__(self, filename):
- ConfigParser.__init__(self)
- self.__config_file__ = filename
+ def __init__(self, filename, module_name):
+ self.file_name = filename
+ self.module_name = module_name
+ RawConfigParser.__init__(self, None)
self.read()
def read(self):
"""Read the config file"""
- ConfigParser.read(self, self.__config_file__)
+ RawConfigParser.read(self, self.file_name)
+ if not self.has_section(self.module_name):
+ self.add_section(self.module_name)
def write(self):
"""Write the config to the disk"""
try:
- fp = open(self.__config_file__, 'w')
- ConfigParser.write(self, fp)
+ fp = open(self.file_name, 'w')
+ RawConfigParser.write(self, fp)
fp.close()
return True
except IOError:
@@ -59,7 +62,7 @@ class BasePlugin(object, metaclass=SafetyMetaclass):
SafetyMetaclass.core = core
self.plugin_manager = plugin_manager
conf = os.path.join(plugins_conf_dir, self.__module__+'.cfg')
- self.config = PluginConfig(conf)
+ self.config = PluginConfig(conf, self.__module__)
self.init()
def init(self):