summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-13 00:58:16 +0100
committermathieui <mathieui@mathieui.net>2011-11-13 00:58:16 +0100
commit1efdfcd5667ac2769c1992879fd102c441cc9894 (patch)
tree923ae97c1b64e517424c9f80d6310c98a0dee2ae /src
parentaac980cd4c55c5e49ee2f571f808a48ed349550a (diff)
downloadpoezio-1efdfcd5667ac2769c1992879fd102c441cc9894.tar.gz
poezio-1efdfcd5667ac2769c1992879fd102c441cc9894.tar.bz2
poezio-1efdfcd5667ac2769c1992879fd102c441cc9894.tar.xz
poezio-1efdfcd5667ac2769c1992879fd102c441cc9894.zip
Fix some incoherences and possible bugs with PluginConfig objects
Diffstat (limited to 'src')
-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):