Mercurial > hg > pyloader
comparison pyloader/factory.py @ 19:8987867698ee
a bit more stubbing of .ini parsing
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 30 May 2011 10:55:55 -0700 |
parents | d303a5883991 |
children | 057ccfe310b2 |
comparison
equal
deleted
inserted
replaced
18:d303a5883991 | 19:8987867698ee |
---|---|
2 abstract factories | 2 abstract factories |
3 """ | 3 """ |
4 | 4 |
5 import loader | 5 import loader |
6 import os | 6 import os |
7 from ConfigParser import InterpolationMissingOptionError | |
8 from ConfigParser import InterpolationSyntaxError | |
7 from ConfigParser import SafeConfigParser as ConfigParser | 9 from ConfigParser import SafeConfigParser as ConfigParser |
8 | 10 |
9 __all__ = ['CircularReferenceError', 'PyFactory', 'IniFactory'] | 11 __all__ = ['CircularReferenceError', 'PyFactory', 'IniFactory'] |
10 | 12 |
11 class CircularReferenceError(Exception): | 13 class CircularReferenceError(Exception): |
106 # sanity check | 108 # sanity check |
107 assert ':' in section, "No : in section: %s" % section | 109 assert ':' in section, "No : in section: %s" % section |
108 name, path = section.split(':', 1) | 110 name, path = section.split(':', 1) |
109 sect = config[name] = dict(path=path) | 111 sect = config[name] = dict(path=path) |
110 for option in parser.options(section): | 112 for option in parser.options(section): |
111 pass | 113 |
114 if option in parser.defaults(): | |
115 # don't include the defaults | |
116 continue | |
117 try: | |
118 value = parser.get(section, option) | |
119 except (InterpolationMissingOptionError, InterpolationSyntaxError): | |
120 value = parser.get(section, option, raw=True) | |
121 | |
112 | 122 |
113 | 123 |