[orca/570658] overriding the dict.update, for our formatting.py, because we need to murge trees.



commit 002040a1e2f71c4c62c7479f7dbc37742b2657cb
Author: Mesar Hameed <mhameed src gnome org>
Date:   Thu May 14 17:40:20 2009 +0100

    overriding the dict.update, for our formatting.py, because we need to murge trees.
---
 src/orca/formatting.py                             |   15 ++++++
 .../apps/gnome-window-properties/formatting.py     |   48 ++++++++++++++++++++
 2 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 8bc2465..fafc0bb 100755
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -196,3 +196,18 @@ class Formatting(dict):
         else:
             format = roleDict['unfocused']
         return format
+
+    def update(self, newDict):
+        for key, val in newDict.iteritems():
+            if self.has_key(key):
+                if isinstance(self[key], dict) and isinstance(val, dict): 
+                    self[key].update(val)
+                elif isinstance(self[key], basestring) and isinstance(val, basestring): 
+                    self[key] = val
+                else:
+                    # exception or such like, we are trying to murge
+                    # incompatible trees.
+                    # throw an exception?
+                    print("an error has occured, cant murge dicts.")
+            else:
+                self[key] = val
diff --git a/src/orca/scripts/apps/gnome-window-properties/formatting.py b/src/orca/scripts/apps/gnome-window-properties/formatting.py
new file mode 100755
index 0000000..7950be4
--- /dev/null
+++ b/src/orca/scripts/apps/gnome-window-properties/formatting.py
@@ -0,0 +1,48 @@
+# Orca
+#
+# Copyright 2006-2008 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+"""Custom formatting for gnome-window-properties."""
+
+__id__ = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+import pyatspi
+
+import orca.formatting as defaultFormatting
+
+scriptFormatting = {
+    'speech': {
+        pyatspi.ROLE_ALERT: {
+            'unfocused': 'foobar + unrelatedLabels'
+            },
+    }
+}
+
+class Formatting(defaultFormatting.Formatting):
+
+    def __init__(self, script):
+        defaultFormatting.Formatting.__init__(self, script)
+        self.update(scriptFormatting)
+
+
+f = Formatting(None)
+print f



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