summaryrefslogtreecommitdiff
path: root/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'util.py')
-rw-r--r--util.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/util.py b/util.py
new file mode 100644
index 0000000..4596e8a
--- /dev/null
+++ b/util.py
@@ -0,0 +1,31 @@
1# vim: set filencoding=utf8
2"""
3Exchange Proxy Utility Functions
4
5@author: Mike Crute (mcrute@ag.com)
6@organization: American Greetings Interactive
7@date: February 15, 2010
8"""
9
10from collections import defaultdict
11from ConfigParser import ConfigParser
12
13
14def config_dict(config_file):
15 """
16 Load a ConfigParser config as a dictionary. Will also
17 attempt to do simple stuff like convert ints.
18 """
19 config = ConfigParser()
20 config.read(config_file)
21 output = defaultdict(dict)
22
23 for section in config.sections():
24 for key, value in config.items(section):
25 if value.isdigit():
26 value = int(value)
27
28 output[section][key] = value
29
30 return dict(output)
31