[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src GConfig.py
From: |
James Thompson |
Subject: |
gnue/common/src GConfig.py |
Date: |
Thu, 02 May 2002 21:57:21 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/05/02 21:57:21
Modified files:
common/src : GConfig.py
Log message:
Removed hardcoded gnue references from config system
Start of more generic config handler
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GConfig.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
Patches:
Index: gnue/common/src/GConfig.py
diff -c gnue/common/src/GConfig.py:1.18 gnue/common/src/GConfig.py:1.19
*** gnue/common/src/GConfig.py:1.18 Thu May 2 17:20:33 2002
--- gnue/common/src/GConfig.py Thu May 2 21:57:20 2002
***************
*** 22,28 ****
# GConfig.py
#
# DESCRIPTION:
! # Class that loads the gnue.conf files so gnue apps can get
# default settings.
#
# NOTES:
--- 22,28 ----
# GConfig.py
#
# DESCRIPTION:
! # Class that loads the configuration files so gnue apps can get
# default settings.
#
# NOTES:
***************
*** 35,41 ****
from gnue.common import openResource
import GDebug
import copy
- ##import GImport
TRUE = 1
FALSE = 0
--- 35,40 ----
***************
*** 66,73 ****
class GConfig:
! def __init__(self, application):
!
self._application = application
_success = FALSE
--- 65,74 ----
class GConfig:
! def __init__(self, application, configFilename="gnue.conf",
homeConfigDir=".gnue"):
! self._applicationConfigInfo = {}
! self._defaultApplication = application
!
self._application = application
_success = FALSE
***************
*** 79,103 ****
etc_base = getInstalledBase('%s_etc' % application, 'common_etc')
locations = []
! # /usr/local/gnue/etc/gnue.conf
if etc_base:
! locations.append(os.path.join(etc_base,'gnue.conf'))
! # ~/.gnue/gnue.conf
try:
! locations.append(os.path.join(os.environ['HOME'], '.gnue','gnue.conf'))
except KeyError:
pass
! # /usr/local/gnue/etc/gnue.conf.fixed
if etc_base:
! locations.append(os.path.join(etc_base,'gnue.conf.fixed'))
# Now, try each file
for location in locations:
GDebug.printMesg(1,'Reading configuration file %s' % location)
try:
! self.readConfig(location)
_success = TRUE
except IOError:
GDebug.printMesg (1,'File not available')
--- 80,104 ----
etc_base = getInstalledBase('%s_etc' % application, 'common_etc')
locations = []
! # system config file
if etc_base:
! locations.append(os.path.join(etc_base,configFilename))
! # user config file
try:
! locations.append(os.path.join(os.environ['HOME'], homeConfigDir
,configFilename))
except KeyError:
pass
! # system fixed config file
if etc_base:
! locations.append(os.path.join(etc_base,configFilename+'.fixed'))
# Now, try each file
for location in locations:
GDebug.printMesg(1,'Reading configuration file %s' % location)
try:
! self.readConfigFile(location)
_success = TRUE
except IOError:
GDebug.printMesg (1,'File not available')
***************
*** 107,132 ****
if not _success:
if _error_type==None:
!
! #
! # TODO: Should we even abort?
! # TODO: If not, then at least
! # TODO: make this an exception
! #
! print _("The gnue.conf file appears to be missing\n\n") \
! +_("The file should be located in one of the following
locations\n")
! if etc_dir:
! print etc_dir + '/gnue.conf'
! print etc_dir + '/gnue.conf.fixed'
if os.environ.has_key('HOME'):
! print os.environ['HOME']+'/.gnue/gnue.conf'
! sys.exit(_("Missing GNUe config file"))
!
else:
raise Exception,_error_msg
! def readConfig(self,location):
global _OPTION
self._parser = ConfigParser()
--- 108,127 ----
if not _success:
if _error_type==None:
! sys.stderr.write(_("The configuration file appears to be missing\n")
+ \
! _("The file should be located in one of the
following locations\n"))
! if etc_base:
! sys.stderr.write(os.path.join(etc_base,configFilename)+'\n')
!
sys.stderr.write(os.path.join(etc_base,configFilename+'.fixed')+'\n')
if os.environ.has_key('HOME'):
! sys.stderr.write(os.path.join(os.environ['HOME'],
homeConfigDir,configFilename)+'\n')
! sys.stderr.write(_("We will bravely attempt to continue but
you"+'\n') + \
! _("may encounter issues running the software.\n"))
else:
raise Exception,_error_msg
! def readConfigFile(self,location):
global _OPTION
self._parser = ConfigParser()