[orca/570658] Do a deep copy of the static dictionary in formatting.py
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca/570658] Do a deep copy of the static dictionary in formatting.py
- Date: Sat, 23 May 2009 18:59:10 -0400 (EDT)
commit 54650cbc2b6dee0787eb153c3647f7ef4a21fb43
Author: Willie Walker <william walker sun com>
Date: Sat May 23 18:46:19 2009 -0400
Do a deep copy of the static dictionary in formatting.py
Without a deep copy, subclasses ended up modifying the original
dictionary. For example, Gecko's formatting.py was overriding
the formatting for the ALERT role, adding expandedEOCs to it.
Without a deep copy, it was overwriting the default formatting.py
entries.
---
src/orca/formatting.py | 7 +++++--
src/orca/scripts/apps/evolution/formatting.py | 4 +++-
.../apps/gnome-window-properties/formatting.py | 4 +++-
src/orca/scripts/apps/rhythmbox/formatting.py | 4 +++-
src/orca/scripts/toolkits/Gecko/formatting.py | 4 +++-
.../toolkits/J2SE-access-bridge/formatting.py | 4 +++-
6 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 8a5b665..59f6318 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -25,6 +25,8 @@ __date__ = "$Date:$"
__copyright__ = "Copyright (c) 2004-2009 Sun Microsystems Inc."
__license__ = "LGPL"
+import copy
+
import pyatspi
# pylint: disable-msg=C0301
@@ -188,14 +190,15 @@ class Formatting(dict):
def __init__(self, script):
dict.__init__(self)
self._script = script
- self.update(formatting)
+ self.update(copy.deepcopy(formatting))
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):
+ elif isinstance(self[key], basestring) \
+ and isinstance(val, basestring):
self[key] = val
else:
# exception or such like, we are trying to murge
diff --git a/src/orca/scripts/apps/evolution/formatting.py b/src/orca/scripts/apps/evolution/formatting.py
index 5957c09..cff931e 100644
--- a/src/orca/scripts/apps/evolution/formatting.py
+++ b/src/orca/scripts/apps/evolution/formatting.py
@@ -27,6 +27,8 @@ __license__ = "LGPL"
# pylint: disable-msg=C0301
+import copy
+
import orca.formatting
formatting = {
@@ -45,4 +47,4 @@ formatting = {
class Formatting(orca.formatting.Formatting):
def __init__(self, script):
orca.formatting.Formatting.__init__(self, script)
- self.update(formatting)
+ self.update(copy.deepcopy(formatting))
diff --git a/src/orca/scripts/apps/gnome-window-properties/formatting.py b/src/orca/scripts/apps/gnome-window-properties/formatting.py
index 815d461..5538aee 100644
--- a/src/orca/scripts/apps/gnome-window-properties/formatting.py
+++ b/src/orca/scripts/apps/gnome-window-properties/formatting.py
@@ -25,6 +25,8 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
+import copy
+
import pyatspi
import orca.formatting
@@ -40,4 +42,4 @@ formatting = {
class Formatting(orca.formatting.Formatting):
def __init__(self, script):
orca.formatting.Formatting.__init__(self, script)
- self.update(formatting)
+ self.update(copy.deepcopy(formatting))
diff --git a/src/orca/scripts/apps/rhythmbox/formatting.py b/src/orca/scripts/apps/rhythmbox/formatting.py
index 4d1e33b..c3e82d7 100644
--- a/src/orca/scripts/apps/rhythmbox/formatting.py
+++ b/src/orca/scripts/apps/rhythmbox/formatting.py
@@ -25,6 +25,8 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
+import copy
+
import pyatspi
import orca.formatting
@@ -47,4 +49,4 @@ formatting = {
class Formatting(orca.formatting.Formatting):
def __init__(self, script):
orca.formatting.Formatting.__init__(self, script)
- self.update(formatting)
+ self.update(copy.deepcopy(formatting))
diff --git a/src/orca/scripts/toolkits/Gecko/formatting.py b/src/orca/scripts/toolkits/Gecko/formatting.py
index 332154d..7f8492a 100644
--- a/src/orca/scripts/toolkits/Gecko/formatting.py
+++ b/src/orca/scripts/toolkits/Gecko/formatting.py
@@ -25,6 +25,8 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
+import copy
+
import pyatspi
import orca.formatting
@@ -67,7 +69,7 @@ class Formatting(orca.formatting.Formatting):
def __init__(self, script):
orca.formatting.Formatting.__init__(self, script)
- self.update(formatting)
+ self.update(copy.deepcopy(formatting))
# This is a copy of the default formatting, which we will
# use for ARIA widgets.
#
diff --git a/src/orca/scripts/toolkits/J2SE-access-bridge/formatting.py b/src/orca/scripts/toolkits/J2SE-access-bridge/formatting.py
index fe611ac..f8c2095 100644
--- a/src/orca/scripts/toolkits/J2SE-access-bridge/formatting.py
+++ b/src/orca/scripts/toolkits/J2SE-access-bridge/formatting.py
@@ -25,6 +25,8 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
+import copy
+
import pyatspi
import orca.formatting
@@ -46,4 +48,4 @@ formatting = {
class Formatting(orca.formatting.Formatting):
def __init__(self, script):
orca.formatting.Formatting.__init__(self, script)
- self.update(formatting)
+ self.update(copy.deepcopy(formatting))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]