commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r5017 - trunk/gnue-common/src/apps


From: jamest
Subject: r5017 - trunk/gnue-common/src/apps
Date: Tue, 23 Dec 2003 22:14:51 -0600 (CST)

Author: jamest
Date: 2003-12-23 22:14:51 -0600 (Tue, 23 Dec 2003)
New Revision: 5017

Modified:
   trunk/gnue-common/src/apps/RuntimeSettings.py
Log:
removed hard coded .gnue/gnue-des from the runtime settings system


Modified: trunk/gnue-common/src/apps/RuntimeSettings.py
===================================================================
--- trunk/gnue-common/src/apps/RuntimeSettings.py       2003-12-24 02:14:47 UTC 
(rev 5016)
+++ trunk/gnue-common/src/apps/RuntimeSettings.py       2003-12-24 04:14:51 UTC 
(rev 5017)
@@ -34,30 +34,36 @@
 # TODO: This is, after all, session-specific information and not
 # TODO: user-settable configuration data.
 
+if not globals().has_key('location'):
+  location = None
 
-if os.environ.has_key('HOME'):
+def init(configFilename="default.ini", homeConfigDir=".gnue"):
+  global location, config 
+  if os.environ.has_key('HOME'):
+    try:
+      os.makedirs(os.path.join(os.environ['HOME'], homeConfigDir))
+    except:
+      pass
+    location = os.path.join(os.environ['HOME'], homeConfigDir ,configFilename)
+  elif sys.platform[:3] in ('win','mac'):
+    location = 
os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])),configFilename)
+  else:
+    location = configFilename
+
   try:
-    os.makedirs(os.environ['HOME']+'/.gnue')
+    config = ConfigParser.ConfigParser()
+    config.read(location)
   except:
-    pass
-  location = os.environ['HOME']+'/.gnue/gnue-des.ini'
-elif sys.platform[:3] in ('win','mac'):
-  location = 
os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])),'gnue-des.ini')
-else:
-  location = 'gnue-des.ini'
+    config = None
 
-try:
-  config = ConfigParser.ConfigParser()
-  config.read(location)
-except:
-  config = None
-
-
 def registerInstance(instance):
   instance._runtimes = []
 
 
 def get(section, setting, default):
+  # Backwards compatability
+  if location == None:
+    init()
   try:
     return config.get(section, setting)
   except:
@@ -65,12 +71,14 @@
 
 
 def getint(section, setting, default):
+  # Backwards compatability
+  if location == None:
+    init()
   try:
     return config.getint(section, setting)
   except:
     return default
 
-
 #
 # Save the runtime settings
 #





reply via email to

[Prev in Thread] Current Thread [Next in Thread]