aboutsummaryrefslogtreecommitdiffstats
path: root/config.py
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2010-11-20 22:54:01 +0100
committerThibaut Horel <thibaut.horel@gmail.com>2010-11-20 22:54:01 +0100
commit374b2adb8a7ee55c5cad87955add772096f73999 (patch)
treebffb6cb3018e74b7a43b1c4b69b2ecd30ac871ea /config.py
parentf3fbfe116584393f5b373d98541c803c695f6ffb (diff)
downloadalias-374b2adb8a7ee55c5cad87955add772096f73999.tar.gz
Add config file feature.
New -c switch to specify a config file on the command line. See config.ini.sample for an example of a config file. The configuration options can then be shared across modules : just import config module.
Diffstat (limited to 'config.py')
-rw-r--r--config.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/config.py b/config.py
new file mode 100644
index 0000000..d50d4d7
--- /dev/null
+++ b/config.py
@@ -0,0 +1,15 @@
+import ConfigParser
+
+filename = None
+
+class AliasConfigParser(ConfigParser.RawConfigParser):
+
+ def read(self, filenames):
+ ConfigParser.RawConfigParser.read(self, filenames)
+ self.name = self.get("component", "name")
+ self.root = self.get("component", "root")
+ self.host = self.get("component", "host")
+ self.secret = self.get("component", "secret")
+ self.port = self.getint("component", "port")
+
+config = AliasConfigParser()