68 |
# |
# |
69 |
def loadApplicationConfig(self, configFilename="gnue.conf", homeConfigDir=".gnue", section="DEFAULT", defaults = None): |
def loadApplicationConfig(self, configFilename="gnue.conf", homeConfigDir=".gnue", section="DEFAULT", defaults = None): |
70 |
|
|
71 |
GDebug.printMesg(1,'Reading configuration info from %s section %s' %(configFilename,section)) |
GDebug.printMesg(1,'Reading configuration info from %s section %s' % (configFilename, section)) |
72 |
|
|
73 |
# |
# |
74 |
# Create parser and populate it if it doesn't exist |
# Create parser and populate it if it doesn't exist |
101 |
# |
# |
102 |
try: |
try: |
103 |
parser.read(fileLocations) |
parser.read(fileLocations) |
104 |
|
GDebug.printMesg(1,'Configuration files were read in this order: %s' % \ |
105 |
|
(fileLocations) ) |
106 |
except DuplicateSectionError: |
except DuplicateSectionError: |
107 |
raise InvalidFormatError, _('The file has duplicate source definitions.') |
raise InvalidFormatError, _('The file has duplicate source definitions.') |
108 |
except MissingSectionHeaderError: |
except MissingSectionHeaderError: |
149 |
def gConfig(self, varName, configFilename=None, section=None): |
def gConfig(self, varName, configFilename=None, section=None): |
150 |
if not configFilename: configFilename = self._defaultConfigFilename |
if not configFilename: configFilename = self._defaultConfigFilename |
151 |
if not section: section = self._defaultSection |
if not section: section = self._defaultSection |
|
|
|
152 |
try: |
try: |
153 |
return self._loadedConfigs[configFilename].get(section,varName) |
return self._loadedConfigs[configFilename].get(section,varName) |
154 |
except NoSectionError: |
except NoSectionError: |
165 |
def gConfigDict(self, configFilename=None, section=None): |
def gConfigDict(self, configFilename=None, section=None): |
166 |
if not configFilename: configFilename = self._defaultConfigFilename |
if not configFilename: configFilename = self._defaultConfigFilename |
167 |
if not section: section = self._defaultSection |
if not section: section = self._defaultSection |
168 |
|
|
169 |
options = {} |
options = {} |
170 |
for option in self._loadedConfigs[configFilename].options(section): |
for option in self._loadedConfigs[configFilename].options(section): |
171 |
options[option] = self._loadedConfigs[configFilename].get(section,string.lower(option)) |
options[option] = self._loadedConfigs[configFilename].get(section,string.lower(option)) |