[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9818 - trunk/gnue-common/src/apps
From: |
johannes |
Subject: |
[gnue] r9818 - trunk/gnue-common/src/apps |
Date: |
Wed, 21 Nov 2007 03:11:36 -0600 (CST) |
Author: johannes
Date: 2007-11-21 03:11:35 -0600 (Wed, 21 Nov 2007)
New Revision: 9818
Modified:
trunk/gnue-common/src/apps/RuntimeSettings.py
Log:
Reindentation
Modified: trunk/gnue-common/src/apps/RuntimeSettings.py
===================================================================
--- trunk/gnue-common/src/apps/RuntimeSettings.py 2007-11-21 09:02:58 UTC
(rev 9817)
+++ trunk/gnue-common/src/apps/RuntimeSettings.py 2007-11-21 09:11:35 UTC
(rev 9818)
@@ -35,86 +35,87 @@
# TODO: user-settable configuration data.
if not globals().has_key('location'):
- location = None
+ location = None
def init(configFilename="default.ini", homeConfigDir=".gnue"):
- global location, config
- if os.environ.has_key('HOME'):
+ 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.path.join(os.environ['HOME'], homeConfigDir))
+ config = ConfigParser.ConfigParser()
+ config.read(location)
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
+ config = None
- try:
- config = ConfigParser.ConfigParser()
- config.read(location)
- except:
- config = None
-
def registerInstance(instance):
- instance._runtimes = []
+ instance._runtimes = []
def get(section, setting, default):
- # Backwards compatability
- if location == None:
- init()
- try:
- return config.get(section, setting)
- except:
- return default
+ # Backwards compatability
+ if location == None:
+ init()
+ try:
+ return config.get(section, setting)
+ except:
+ return default
def getint(section, setting, default):
- # Backwards compatability
- if location == None:
- init()
- try:
- return config.getint(section, setting)
- except:
- return default
+ # Backwards compatability
+ if location == None:
+ init()
+ try:
+ return config.getint(section, setting)
+ except:
+ return default
#
# Save the runtime settings
#
def saveRuntimeSettings(instance):
- from gnue.common.apps.GDebug import _DEBUG_LEVELS
- if location:
- try:
- fh = open(location,'w')
- for h in instance._runtimes:
- try:
- section, hash = h.saveRuntimeSettings()
- except:
- print o(u_("Warning: Unable to save all session data to %s") %
- location)
+ from gnue.common.apps.GDebug import _DEBUG_LEVELS
+ if location:
+ try:
+ fh = open(location,'w')
+ for h in instance._runtimes:
+ try:
+ section, hash = h.saveRuntimeSettings()
+ except:
+ print o( \
+ u_("Warning: Unable to save all session data to %s") %
+ location)
+ if _DEBUG_LEVELS != [0]:
+ raise
+ if len(hash.keys()):
+ if not config.has_section(section):
+ config.add_section(section)
+ for key in hash.keys():
+ config.set(section, key, "%s" % hash[key])
+
+ config.write(fh)
+ fh.close()
+ except:
+ print o(u_("\nWarning: Unable to save session data to %s\n") \
+ % location)
if _DEBUG_LEVELS != [0]:
- raise
- if len(hash.keys()):
- if not config.has_section(section):
- config.add_section(section)
- for key in hash.keys():
- config.set(section, key, "%s" % hash[key])
+ raise
- config.write(fh)
- fh.close()
- except:
- print o(u_("\nWarning: Unable to save session data to %s\n") % location)
- if _DEBUG_LEVELS != [0]:
- raise
-
#
# Any object (class) that has settings it wants saved should
# register with this method. The object should define a
# getRuntimeSettings() method.
#
def registerRuntimeSettingHandler(instance, object):
- instance._runtimes.append(object)
-
-
-
+ instance._runtimes.append(object)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9818 - trunk/gnue-common/src/apps,
johannes <=