Mercurial > hg > pyloader
comparison pyloader/factory.py @ 16:edecb6fbd5a7
further stubbing of ini factory
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 May 2011 19:00:43 -0700 |
parents | 0bea5297c156 |
children | d303a5883991 |
comparison
equal
deleted
inserted
replaced
15:0bea5297c156 | 16:edecb6fbd5a7 |
---|---|
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 SafeConfigParser as ConfigParser | |
7 | 8 |
8 __all__ = ['CircularReferenceError', 'PyFactory', 'IniFactory'] | 9 __all__ = ['CircularReferenceError', 'PyFactory', 'IniFactory'] |
9 | 10 |
10 class CircularReferenceError(Exception): | 11 class CircularReferenceError(Exception): |
11 """factory has detected a circular reference""" | 12 """factory has detected a circular reference""" |
86 def __init__(self, inifile, main=''): | 87 def __init__(self, inifile, main=''): |
87 assert os.path.exists(inifile), "File not found: %s" % inifile | 88 assert os.path.exists(inifile), "File not found: %s" % inifile |
88 | 89 |
89 def read(self): | 90 def read(self): |
90 """reads configuration from an .ini file""" | 91 """reads configuration from an .ini file""" |
92 | |
93 here = os.path.dirname(os.path.abspath(self.inifile)) | |
94 | |
95 # read configuration | |
96 defaults={'here': here, | |
97 'this': os.path.abspath(self.inifile)} | |
98 parser = ConfigParser(defaults=defaults) | |
99 parser.optionxform = str # use whole case | |
100 parser.read(self.inifile) | |
101 |