Mercurial > hg > martINI
comparison martini/config.py @ 8:81aed4352851
make martini work with an ordered dictionary
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 24 Nov 2010 11:05:40 -0800 |
parents | 7c8f23eae311 |
children | 77c7556fa8e0 |
comparison
equal
deleted
inserted
replaced
7:7c8f23eae311 | 8:81aed4352851 |
---|---|
2 | 2 |
3 import os | 3 import os |
4 import sys | 4 import sys |
5 import urllib2 | 5 import urllib2 |
6 | 6 |
7 from odict import OrderedDict | |
7 from ConfigParser import ConfigParser | 8 from ConfigParser import ConfigParser |
8 from ConfigParser import InterpolationMissingOptionError | 9 from ConfigParser import InterpolationMissingOptionError |
9 from ConfigParser import MissingSectionHeaderError | 10 from ConfigParser import MissingSectionHeaderError |
10 from ConfigParser import NoOptionError | 11 from ConfigParser import NoOptionError |
11 from StringIO import StringIO | 12 from StringIO import StringIO |
27 | 28 |
28 class ConfigMunger(ConfigParser): | 29 class ConfigMunger(ConfigParser): |
29 """combine configuration from .ini files""" | 30 """combine configuration from .ini files""" |
30 | 31 |
31 def __init__(self, *conf, **kw): | 32 def __init__(self, *conf, **kw): |
32 ConfigParser.__init__(self, kw.get('defaults',{})) | 33 ConfigParser.__init__(self, defaults=kw.get('defaults',{}), |
34 dict_type=OrderedDict) | |
33 self.optionxform = str | 35 self.optionxform = str |
34 self.read(*conf) | 36 self.read(*conf) |
35 | 37 |
36 def __getitem__(self, section): | 38 def __getitem__(self, section): |
37 """ | 39 """ |