orca r4238 - in branches/phase2: . src/orca
- From: wwalker svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r4238 - in branches/phase2: . src/orca
- Date: Wed, 17 Sep 2008 20:46:05 +0000 (UTC)
Author: wwalker
Date: Wed Sep 17 20:46:05 2008
New Revision: 4238
URL: http://svn.gnome.org/viewvc/orca?rev=4238&view=rev
Log:
More work on settings.
Modified:
branches/phase2/logging.conf
branches/phase2/src/orca/orca.py
branches/phase2/src/orca/plugin.py
branches/phase2/src/orca/script.py
branches/phase2/src/orca/settings.py
Modified: branches/phase2/logging.conf
==============================================================================
--- branches/phase2/logging.conf (original)
+++ branches/phase2/logging.conf Wed Sep 17 20:46:05 2008
@@ -7,7 +7,7 @@
########################################################################
[loggers]
-keys: root
+keys: root,orca
#keys: root,orca,script_manager,braille
[logger_root]
Modified: branches/phase2/src/orca/orca.py
==============================================================================
--- branches/phase2/src/orca/orca.py (original)
+++ branches/phase2/src/orca/orca.py Wed Sep 17 20:46:05 2008
@@ -208,15 +208,21 @@
try:
return _userSettings.getSettings(defaultSettings)
except:
- log.debug("No user settings. Creating empty one backed by default.")
+ log.exception("exception handled while getting user settings:")
return settings.Settings(defaultSettings)
def _start(commandLineSettings):
"""Starts Orca.
"""
- # TODO: override commandLineSettings
- defaultSettings = settings.getSettings()
+ log.debug("Command line settings:\n%s", commandLineSettings)
+ defaultSettings = settings.getSettings(None, commandLineSettings)
+ log.debug("Default settings:\n%s", defaultSettings)
+
+ sys.path.insert(0, defaultSettings.userPrefsDir)
+ sys.path.insert(0, '') # current directory
userSettings = loadUserSettings(defaultSettings)
+ log.debug("User settings:\n%s", userSettings)
+
script_manager.ScriptManager(userSettings)
log.debug("pyatspi.Registry.start()")
pyatspi.Registry.start()
@@ -279,8 +285,6 @@
try:
os.chdir(userPrefsDir)
commandLineSettings.userPrefsDir = userPrefsDir
- sys.path.insert(0, userPrefsDir)
- sys.path.insert(0, '') # current directory
except:
log.exception("handled exception with user-prefs-dir:")
Modified: branches/phase2/src/orca/plugin.py
==============================================================================
--- branches/phase2/src/orca/plugin.py (original)
+++ branches/phase2/src/orca/plugin.py Wed Sep 17 20:46:05 2008
@@ -46,9 +46,9 @@
"""Get the name of the module that would hold the user
settings for this plugin.
"""
- name = self._script.getSettingsModuleName()
+ name = self._script.getSettingsModuleName().strip(".settings.py")
if name and len(name):
- name = name + __name__.strip("orca")
+ name += __name__.strip("orca") + ".settings.py"
return name
def _completeInit(self):
Modified: branches/phase2/src/orca/script.py
==============================================================================
--- branches/phase2/src/orca/script.py (original)
+++ branches/phase2/src/orca/script.py Wed Sep 17 20:46:05 2008
@@ -109,6 +109,7 @@
log.exception("handled exception creating plugin:")
self._completeInit()
+ log.debug("%s settings:\n%s" % (self, self._settings))
def getSettingsModuleName(self):
"""Get the name of the user settings module for this script.
@@ -116,7 +117,7 @@
name = script_manager.ScriptManager.getScriptModuleName(
self.application)
if name and len(name):
- name = "script_settings." + name
+ name = "script_settings." + name + ".settings.py"
return name
def _loadSettings(self, userSettings):
Modified: branches/phase2/src/orca/settings.py
==============================================================================
--- branches/phase2/src/orca/settings.py (original)
+++ branches/phase2/src/orca/settings.py Wed Sep 17 20:46:05 2008
@@ -637,6 +637,10 @@
if not self.override and self.delegate:
self.override = self.delegate.override
+ def __str__(self):
+ import pprint
+ return pprint.pformat(self)
+
def __getitem__(self, key):
"""Returns the settings value for the given key."""
try:
@@ -651,7 +655,7 @@
raise KeyError(key)
def __getattribute__(self, name):
- if name in ["delegate", "override"]:
+ if name in ["iteritems", "items", "delegate", "override"]:
return dict.__getattribute__(self, name)
else:
return self[name]
@@ -662,11 +666,11 @@
else:
self[name] = value
-def getSettings():
+def getSettings(delegate=None, override=None):
"""Returns a Settings object that holds the global settings
set in this module.
"""
- moduleSettings = Settings()
+ moduleSettings = Settings(delegate, override)
for key in globals().keys():
if not key.startswith("_") \
and not key in ["Settings", "getSettings"]:
@@ -682,11 +686,15 @@
overrideSettings = Settings()
overrideSettings.forceThis = 4
+ print "Override settings:\n%s" % overrideSettings
+
parentSettings = Settings(None, overrideSettings)
parentSettings.parentSetting1 = 1
parentSettings.parentSetting2 = 2
parentSettings.forceThis = 22
+ print "Parent settings:\n%s" % overrideSettings
+
print "Should be 4:", parentSettings.forceThis
print "Should be 1 2:", \
parentSettings.parentSetting1, \
@@ -697,6 +705,11 @@
childSettings["forceThis"] = 23
print "Should be 4:", childSettings["forceThis"]
+ print "Should be 4:", childSettings.forceThis
+
+ childSettings.forceThis = 23
+ print "Should be 4:", childSettings["forceThis"]
+ print "Should be 4:", childSettings.forceThis
print "Should be 1 2:", \
childSettings.parentSetting1, \
@@ -707,7 +720,9 @@
childSettings.parentSetting1, \
childSettings.parentSetting2
- print getSettings()
+ print "Child settings:\n%s" % overrideSettings
+
+ print "Default settings:\n%s" % getSettings(None, None)
print "This exception is expected:"
print childSettings.foo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]