[orca] Completion of the Python 3 migration
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Completion of the Python 3 migration
- Date: Wed, 20 Jun 2012 21:08:10 +0000 (UTC)
commit bb07ba216e8948ecb6929e817cfc8dec095ada6d
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Jun 20 17:07:09 2012 -0400
Completion of the Python 3 migration
README | 6 +-
configure.ac | 16 +-
src/orca/app_prefs.py | 2 +-
src/orca/braille.py | 41 +--
src/orca/braille_generator.py | 7 +-
src/orca/brlmon.py | 10 +-
src/orca/chat.py | 2 +-
src/orca/chnames.py | 338 ++++++++++----------
src/orca/debug.py | 8 +-
src/orca/event_manager.py | 24 +-
src/orca/flat_review.py | 33 +--
src/orca/formatting.py | 4 +-
src/orca/generator.py | 5 -
src/orca/input_event.py | 23 +-
src/orca/keybindings.py | 6 +-
src/orca/keynames.py | 16 +-
src/orca/liveregions.py | 4 -
src/orca/logger.py | 4 +-
src/orca/orca_console_prefs.py | 2 +-
src/orca/orca_gui_prefs.py | 19 +-
src/orca/phonnames.py | 8 +-
src/orca/pronunciation_dict.py | 7 +-
src/orca/punctuation_settings.py | 182 +++++------
src/orca/script.py | 5 -
src/orca/script_manager.py | 19 +-
src/orca/script_utilities.py | 228 ++++----------
src/orca/scripts/apps/acroread/script.py | 2 +-
src/orca/scripts/apps/evolution/script.py | 4 +-
src/orca/scripts/apps/gedit/script.py | 4 +-
src/orca/scripts/apps/gnome-terminal/script.py | 4 +-
src/orca/scripts/apps/packagemanager/script.py | 2 +-
src/orca/scripts/apps/soffice/script.py | 34 +--
src/orca/scripts/apps/soffice/script_utilities.py | 3 +-
src/orca/scripts/apps/soffice/speech_generator.py | 6 +-
src/orca/scripts/default.py | 114 +++----
src/orca/scripts/toolkits/CALLY/script.py | 7 +-
src/orca/scripts/toolkits/Gecko/bookmarks.py | 4 +-
src/orca/scripts/toolkits/Gecko/script.py | 67 +---
.../scripts/toolkits/Gecko/speech_generator.py | 2 +-
.../toolkits/Gecko/structural_navigation.py | 4 +-
.../scripts/toolkits/J2SE-access-bridge/script.py | 2 +-
src/orca/scripts/toolkits/WebKitGtk/script.py | 4 +-
.../scripts/toolkits/WebKitGtk/script_utilities.py | 6 +-
.../scripts/toolkits/WebKitGtk/speech_generator.py | 2 +-
src/orca/settings_manager.py | 2 -
src/orca/speech.py | 23 +--
src/orca/speech_generator.py | 26 +-
src/orca/speechdispatcherfactory.py | 25 +--
src/orca/speechserver.py | 3 +-
src/orca/text_attribute_names.py | 12 +-
50 files changed, 524 insertions(+), 857 deletions(-)
---
diff --git a/README b/README
index c7f602f..6192247 100644
--- a/README
+++ b/README
@@ -29,7 +29,7 @@ infrastructure and application bug fixes that help Orca work better.
Orca also has the following dependencies:
-* Python - Python platform (minimum version 2.7)
+* Python - Python platform (minimum version 3.2.3)
* pygobject-3.0 - Python bindings for the GObject library
* gtk+-3.0 - Gtk+ toolkit
* json-py - a JSON (http://json.org) reader and writer in Python
@@ -45,11 +45,11 @@ NOTE: If you have multiple versions of the python interpreter installed
on your machine, you should set the PYTHON environment variable when
configuring Orca. For example:
- PYTHON=/usr/bin/python2.7 ./autogen.sh
+ PYTHON=/usr/bin/python3.2 ./autogen.sh
or
- PYTHON=/usr/bin/python2.7 ./configure
+ PYTHON=/usr/bin/python3.2 ./configure
NOTE FOR BRLTTY USERS:
========================================================================
diff --git a/configure.ac b/configure.ac
index b4f4c61..71c972b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,9 +4,9 @@ m4_define([orca_micro_version], [3pre])
m4_define([orca_version],
[orca_major_version.orca_minor_version.orca_micro_version])
-m4_define(gtk_required_version, 3.1.91)
-m4_define(pygobject_required_version, 3.0.2)
-m4_define(atspi_required_version, 2.3.5)
+m4_define(gtk_required_version, 3.4)
+m4_define(pygobject_required_version, 3.2.2)
+m4_define(atspi_required_version, 2.5.2)
AC_INIT([orca],
[orca_version],
@@ -40,8 +40,8 @@ AC_PROG_INSTALL
dnl Check for python and python modules needed by Orca
dnl TODO: check for incompatibilities between Orca and liblouis
dnl per http://live.gnome.org/Orca/Braille
-AM_PATH_PYTHON(2.7)
-#AM_CHECK_PYMOD(gobject,,,[AC_MSG_ERROR(Could not find python module: gobject)])
+AM_PATH_PYTHON(3.2.3)
+
# Don't require the DISPLAY to be set - the gtk checking will fail
# if DISPLAY is not set, and we don't like that.
@@ -135,6 +135,12 @@ if test "x$wnck_available" = "xno" ; then
echo
echo "NOTE: Mouse review requires wnck, which was not found."
fi
+
+if test "x$speechd_available" = "xno" ; then
+echo
+echo "NOTE: Speech support requires speech-dispatcher >= 0.8."
+fi
+
echo
echo Use speech-dispatcher: $speechd_available
echo Use brltty: $brlapi_available
diff --git a/src/orca/app_prefs.py b/src/orca/app_prefs.py
index 116bb28..4313380 100644
--- a/src/orca/app_prefs.py
+++ b/src/orca/app_prefs.py
@@ -275,7 +275,7 @@ class OrcaPrefs:
if not factory:
return None
- elif isinstance(factory, basestring):
+ elif isinstance(factory, str):
return "'%s'" % factory
else:
return "'%s'" % factory.__name__
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 31de669..99f46a9 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -353,11 +353,6 @@ class Region:
self.expandOnCursor = expandOnCursor
- try:
- string = string.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
# The uncontracted string for the line.
#
self.rawLine = string.strip("\n")
@@ -397,7 +392,7 @@ class Region:
# Double check for ellipses.
#
- maskSize = len(self.string) + (2 * self.string.count(u'\u2026'))
+ maskSize = len(self.string) + (2 * self.string.count('\u2026'))
# Create an empty mask.
#
@@ -610,21 +605,6 @@ class Text(Region):
self.lineOffset = 0
try:
- string = string.decode("UTF-8")
- except UnicodeEncodeError:
- pass
- if label:
- try:
- label = label.decode("UTF-8")
- except UnicodeEncodeError:
- pass
- if eol:
- try:
- eol = eol.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
- try:
endOffset = endOffset - self.lineOffset
except TypeError:
pass
@@ -676,10 +656,6 @@ class Text(Region):
[string, caretOffset, lineOffset] = \
orca_state.activeScript.getTextLineAtCaret(self.accessible,
self.startOffset)
- try:
- string = string.decode("UTF-8")
- except:
- pass
cursorOffset = min(caretOffset - lineOffset, len(string))
@@ -952,7 +928,7 @@ class Line:
# The ultimate solution is to get i18n support into
# BrlTTY.]]]
#
- string += region.string.replace(u'\u2026', "...")
+ string += region.string.replace('\u2026', "...")
mask = region.getAttributeMask(getLinkMask)
attributeMask += mask
@@ -1386,21 +1362,11 @@ def refresh(panToCursor=True,
cursorCell += 1 # Normalize to 1-based offset
logLine = "BRAILLE LINE: '%s'" % string
- try:
- logLine = logLine.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
debug.println(debug.LEVEL_INFO, logLine)
log.info(logLine)
logLine = " VISIBLE: '%s', cursor=%d" % \
(string[startPos:endPos], cursorCell)
- try:
- logLine = logLine.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
debug.println(debug.LEVEL_INFO, logLine)
log.info(logLine)
@@ -1830,6 +1796,9 @@ def init(callback=None, tty=7):
_brlAPISourceId = GObject.io_add_watch(_brlAPI.fileDescriptor,
GObject.IO_IN,
_brlAPIKeyReader)
+ except NameError:
+ debug.println(debug.LEVEL_CONFIGURATION, "BrlApi is not defined")
+ return False
except:
debug.println(debug.LEVEL_CONFIGURATION,
"Could not initialize BrlTTY:")
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index a94fae4..4cc263e 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -387,7 +387,7 @@ class BrailleGenerator(generator.Generator):
def asString(self, content, delimiter=" "):
combined = ""
prior = None
- if isinstance(content, basestring):
+ if isinstance(content, str):
combined = content
elif content and isinstance(content, list):
# Strip off leading and trailing spaces.
@@ -397,11 +397,6 @@ class BrailleGenerator(generator.Generator):
while content and isinstance(content[-1], Space):
content = content[0:-1]
for element in content:
- try:
- element = element.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
if isinstance(element, Space) and prior:
combined += element.delimiter
prior = None
diff --git a/src/orca/brlmon.py b/src/orca/brlmon.py
index 43582bb..ec76392 100644
--- a/src/orca/brlmon.py
+++ b/src/orca/brlmon.py
@@ -44,8 +44,8 @@ class BrlDot(Gtk.Alignment):
"""A single braille dot."""
MARKUP_NORMAL = '<tt><small>%s</small></tt>'
- SYMBOL_LOWERED = u'\u25CB' # 'â'
- SYMBOL_RAISED = u'\u25CF' # 'â'
+ SYMBOL_LOWERED = '\u25CB' # 'â'
+ SYMBOL_RAISED = '\u25CF' # 'â'
def __init__(self, dotNumber, isRaised=False):
"""Create a new BrlDot.
@@ -213,12 +213,6 @@ class BrlMon(Gtk.Window):
"""
self.clear()
-
- try:
- string = string.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
length = min(len(string), len(self.cells))
for i in range(length):
isCursorCell = i == cursorCell - 1
diff --git a/src/orca/chat.py b/src/orca/chat.py
index 868deb9..72d40c7 100644
--- a/src/orca/chat.py
+++ b/src/orca/chat.py
@@ -753,7 +753,7 @@ class Chat:
elif self.isAutoCompletedTextEvent(event):
text = event.any_data
- if text.decode("UTF-8").isupper():
+ if text.isupper():
speech.speak(text,
self._script.voices[settings.UPPERCASE_VOICE])
else:
diff --git a/src/orca/chnames.py b/src/orca/chnames.py
index de542d7..65bee1b 100644
--- a/src/orca/chnames.py
+++ b/src/orca/chnames.py
@@ -177,540 +177,540 @@ chnames["~"] = _("tilde")
# Translators: this is the spoken character for the no break space
# character (e.g., " " in HTML -- U+00a0)
#
-chnames[u'\u00a0'] = _("no break space")
+chnames['\u00a0'] = _("no break space")
# Translators: this is the spoken word for the character 'Â' (U+00a1)
#
-chnames[u'\u00a1'] = _("inverted exclamation point")
+chnames['\u00a1'] = _("inverted exclamation point")
# Translators: this is the spoken word for the character 'Â' (U+00a2)
#
-chnames[u'\u00a2'] = _("cents")
+chnames['\u00a2'] = _("cents")
# Translators: this is the spoken word for the character 'Â' (U+00a3)
#
-chnames[u'\u00a3'] = _("pounds")
+chnames['\u00a3'] = _("pounds")
# Translators: this is the spoken word for the character 'Â' (U+00a4)
#
-chnames[u'\u00a4'] = _("currency sign")
+chnames['\u00a4'] = _("currency sign")
# Translators: this is the spoken word for the character 'Â' (U+00a5)
#
-chnames[u'\u00a5'] = _("yen")
+chnames['\u00a5'] = _("yen")
# Translators: this is the spoken word for the character 'Â' (U+00a6)
#
-chnames[u'\u00a6'] = _("broken bar")
+chnames['\u00a6'] = _("broken bar")
# Translators: this is the spoken word for the character 'Â' (U+00a7)
#
-chnames[u'\u00a7'] = _("section")
+chnames['\u00a7'] = _("section")
# Translators: this is the spoken word for the character 'Â' (U+00a8)
#
-chnames[u'\u00a8'] = _("umlaut")
+chnames['\u00a8'] = _("umlaut")
# Translators: this is the spoken word for the character 'Â' (U+00a9)
#
-chnames[u'\u00a9'] = _("copyright")
+chnames['\u00a9'] = _("copyright")
# Translators: this is the spoken word for the character 'Â' (U+00aa)
#
-chnames[u'\u00aa'] = _("superscript a")
+chnames['\u00aa'] = _("superscript a")
# Translators: this is the spoken word for the character 'Â' (U+00ab)
#
-chnames[u'\u00ab'] = _("left double angle bracket")
+chnames['\u00ab'] = _("left double angle bracket")
# Translators: this is the spoken word for the character 'Â' (U+00ac)
#
-chnames[u'\u00ac'] = _("logical not")
+chnames['\u00ac'] = _("logical not")
# Translators: this is the spoken word for the character 'Â' (U+00ad)
#
-chnames[u'\u00ad'] = _("soft hyphen")
+chnames['\u00ad'] = _("soft hyphen")
# Translators: this is the spoken word for the character 'Â' (U+00ae)
#
-chnames[u'\u00ae'] = _("registered")
+chnames['\u00ae'] = _("registered")
# Translators: this is the spoken word for the character 'Â' (U+00af)
#
-chnames[u'\u00af'] = _("macron")
+chnames['\u00af'] = _("macron")
# Translators: this is the spoken word for the character 'Â' (U+00b0)
#
-chnames[u'\u00b0'] = _("degrees")
+chnames['\u00b0'] = _("degrees")
# Translators: this is the spoken word for the character 'Â' (U+00b1)
#
-chnames[u'\u00b1'] = _("plus or minus")
+chnames['\u00b1'] = _("plus or minus")
# Translators: this is the spoken word for the character 'Â' (U+00b2)
#
-chnames[u'\u00b2'] = _("superscript 2")
+chnames['\u00b2'] = _("superscript 2")
# Translators: this is the spoken word for the character 'Â' (U+00b3)
#
-chnames[u'\u00b3'] = _("superscript 3")
+chnames['\u00b3'] = _("superscript 3")
# Translators: this is the spoken word for the character 'Â' (U+00b4)
#
-chnames[u'\u00b4'] = _("acute accent")
+chnames['\u00b4'] = _("acute accent")
# Translators: this is the spoken word for the character 'Â' (U+00b5)
#
-chnames[u'\u00b5'] = _("mu")
+chnames['\u00b5'] = _("mu")
# Translators: this is the spoken word for the character 'Â' (U+00b6)
#
-chnames[u'\u00b6'] = _("paragraph marker")
+chnames['\u00b6'] = _("paragraph marker")
# Translators: this is the spoken word for the character 'Â' (U+00b7)
#
-chnames[u'\u00b7'] = _("middle dot")
+chnames['\u00b7'] = _("middle dot")
# Translators: this is the spoken word for the character 'Â' (U+00b8)
#
-chnames[u'\u00b8'] = _("cedilla")
+chnames['\u00b8'] = _("cedilla")
# Translators: this is the spoken word for the character 'Â' (U+00b9)
#
-chnames[u'\u00b9'] = _("superscript 1")
+chnames['\u00b9'] = _("superscript 1")
# Translators: this is the spoken word for the character 'Â' (U+00ba)
#
-chnames[u'\u00ba'] = _("ordinal")
+chnames['\u00ba'] = _("ordinal")
# Translators: this is the spoken word for the character 'Â' (U+00bb)
#
-chnames[u'\u00bb'] = _("right double angle bracket")
+chnames['\u00bb'] = _("right double angle bracket")
# Translators: this is the spoken word for the character 'Â' (U+00bc)
#
-chnames[u'\u00bc'] = _("one fourth")
+chnames['\u00bc'] = _("one fourth")
# Translators: this is the spoken word for the character 'Â' (U+00bd)
#
-chnames[u'\u00bd'] = _("one half")
+chnames['\u00bd'] = _("one half")
# Translators: this is the spoken word for the character 'Â' (U+00be)
#
-chnames[u'\u00be'] = _("three fourths")
+chnames['\u00be'] = _("three fourths")
# Translators: this is the spoken word for the character 'Â' (U+00bf)
#
-chnames[u'\u00bf'] = _("inverted question mark")
+chnames['\u00bf'] = _("inverted question mark")
# Translators: this is the spoken word for the character 'Ã' (U+00e1)
#
-chnames[u'\u00e1'] = _("a acute")
+chnames['\u00e1'] = _("a acute")
# Translators: this is the spoken word for the character 'Ã' (U+00c0)
#
-chnames[u'\u00c0'] = _("A GRAVE")
+chnames['\u00c0'] = _("A GRAVE")
# Translators: this is the spoken word for the character 'Ã' (U+00c1)
#
-chnames[u'\u00c1'] = _("A ACUTE")
+chnames['\u00c1'] = _("A ACUTE")
# Translators: this is the spoken word for the character 'Ã' (U+00c2)
#
-chnames[u'\u00c2'] = _("A CIRCUMFLEX")
+chnames['\u00c2'] = _("A CIRCUMFLEX")
# Translators: this is the spoken word for the character 'Ã' (U+00c3)
#
-chnames[u'\u00c3'] = _("A TILDE")
+chnames['\u00c3'] = _("A TILDE")
# Translators: this is the spoken word for the character 'Ã' (U+00c4)
#
-chnames[u'\u00c4'] = _("A UMLAUT")
+chnames['\u00c4'] = _("A UMLAUT")
# Translators: this is the spoken word for the character 'Ã' (U+00c5)
#
-chnames[u'\u00c5'] = _("A RING")
+chnames['\u00c5'] = _("A RING")
# Translators: this is the spoken word for the character 'Ã' (U+00c6)
#
-chnames[u'\u00c6'] = _("A E")
+chnames['\u00c6'] = _("A E")
# Translators: this is the spoken word for the character 'Ã' (U+00c7)
#
-chnames[u'\u00c7'] = _("C CEDILLA")
+chnames['\u00c7'] = _("C CEDILLA")
# Translators: this is the spoken word for the character 'Ã' (U+00c8)
#
-chnames[u'\u00c8'] = _("E GRAVE")
+chnames['\u00c8'] = _("E GRAVE")
# Translators: this is the spoken word for the character 'Ã' (U+00c9)
#
-chnames[u'\u00c9'] = _("E ACUTE")
+chnames['\u00c9'] = _("E ACUTE")
# Translators: this is the spoken word for the character 'Ã' (U+00ca)
#
-chnames[u'\u00ca'] = _("E CIRCUMFLEX")
+chnames['\u00ca'] = _("E CIRCUMFLEX")
# Translators: this is the spoken word for the character 'Ã' (U+00cb)
#
-chnames[u'\u00cb'] = _("E UMLAUT")
+chnames['\u00cb'] = _("E UMLAUT")
# Translators: this is the spoken word for the character 'Ã' (U+00cc)
#
-chnames[u'\u00cc'] = _("I GRAVE")
+chnames['\u00cc'] = _("I GRAVE")
# Translators: this is the spoken word for the character 'Ã' (U+00cd)
#
-chnames[u'\u00cd'] = _("I ACUTE")
+chnames['\u00cd'] = _("I ACUTE")
# Translators: this is the spoken word for the character 'Ã' (U+00ce)
#
-chnames[u'\u00ce'] = _("I CIRCUMFLEX")
+chnames['\u00ce'] = _("I CIRCUMFLEX")
# Translators: this is the spoken word for the character 'Ã' (U+00cf)
#
-chnames[u'\u00cf'] = _("I UMLAUT")
+chnames['\u00cf'] = _("I UMLAUT")
# Translators: this is the spoken word for the character 'Ã' (U+00d0)
#
-chnames[u'\u00d0'] = _("ETH")
+chnames['\u00d0'] = _("ETH")
# Translators: this is the spoken word for the character 'Ã' (U+00d1)
#
-chnames[u'\u00d1'] = _("N TILDE")
+chnames['\u00d1'] = _("N TILDE")
# Translators: this is the spoken word for the character 'Ã' (U+00d2)
#
-chnames[u'\u00d2'] = _("O GRAVE")
+chnames['\u00d2'] = _("O GRAVE")
# Translators: this is the spoken word for the character 'Ã' (U+00d3)
#
-chnames[u'\u00d3'] = _("O ACUTE")
+chnames['\u00d3'] = _("O ACUTE")
# Translators: this is the spoken word for the character 'Ã' (U+00d4)
#
-chnames[u'\u00d4'] = _("O CIRCUMFLEX")
+chnames['\u00d4'] = _("O CIRCUMFLEX")
# Translators: this is the spoken word for the character 'Ã' (U+00d5)
#
-chnames[u'\u00d5'] = _("O TILDE")
+chnames['\u00d5'] = _("O TILDE")
# Translators: this is the spoken word for the character 'Ã' (U+00d6)
#
-chnames[u'\u00d6'] = _("O UMLAUT")
+chnames['\u00d6'] = _("O UMLAUT")
# Translators: this is the spoken word for the character 'Ã' (U+00d7)
#
-chnames[u'\u00d7'] = _("times")
+chnames['\u00d7'] = _("times")
# Translators: this is the spoken word for the character 'Ã' (U+00d8)
#
-chnames[u'\u00d8'] = _("O STROKE")
+chnames['\u00d8'] = _("O STROKE")
# Translators: this is the spoken word for the character 'Ã' (U+00d9)
#
-chnames[u'\u00d9'] = _("U GRAVE")
+chnames['\u00d9'] = _("U GRAVE")
# Translators: this is the spoken word for the character 'Ã' (U+00da)
#
-chnames[u'\u00da'] = _("U ACUTE")
+chnames['\u00da'] = _("U ACUTE")
# Translators: this is the spoken word for the character 'Ã' (U+00db)
#
-chnames[u'\u00db'] = _("U CIRCUMFLEX")
+chnames['\u00db'] = _("U CIRCUMFLEX")
# Translators: this is the spoken word for the character 'Ã' (U+00dc)
#
-chnames[u'\u00dc'] = _("U UMLAUT")
+chnames['\u00dc'] = _("U UMLAUT")
# Translators: this is the spoken word for the character 'Ã' (U+00dd)
#
-chnames[u'\u00dd'] = _("Y ACUTE")
+chnames['\u00dd'] = _("Y ACUTE")
# Translators: this is the spoken word for the character 'Ã' (U+00de)
#
-chnames[u'\u00de'] = _("THORN")
+chnames['\u00de'] = _("THORN")
# Translators: this is the spoken word for the character 'Ã' (U+00df)
#
-chnames[u'\u00df'] = _("s sharp")
+chnames['\u00df'] = _("s sharp")
# Translators: this is the spoken word for the character 'Ã' (U+00e0)
#
-chnames[u'\u00e0'] = _("a grave")
+chnames['\u00e0'] = _("a grave")
# Translators: this is the spoken word for the character 'Ã' (U+00e2)
#
-chnames[u'\u00e2'] = _("a circumflex")
+chnames['\u00e2'] = _("a circumflex")
# Translators: this is the spoken word for the character 'Ã' (U+00e3)
#
-chnames[u'\u00e3'] = _("a tilde")
+chnames['\u00e3'] = _("a tilde")
# Translators: this is the spoken word for the character 'Ã' (U+00e4)
#
-chnames[u'\u00e4'] = _("a umlaut")
+chnames['\u00e4'] = _("a umlaut")
# Translators: this is the spoken word for the character 'Ã' (U+00e5)
#
-chnames[u'\u00e5'] = _("a ring")
+chnames['\u00e5'] = _("a ring")
# Translators: this is the spoken word for the character 'Ã' (U+00e6)
#
-chnames[u'\u00e6'] = _("a e")
+chnames['\u00e6'] = _("a e")
# Translators: this is the spoken word for the character 'Ã' (U+00e7)
#
-chnames[u'\u00e7'] = _("c cedilla")
+chnames['\u00e7'] = _("c cedilla")
# Translators: this is the spoken word for the character 'Ã' (U+00e8)
#
-chnames[u'\u00e8'] = _("e grave")
+chnames['\u00e8'] = _("e grave")
# Translators: this is the spoken word for the character 'Ã' (U+00e9)
#
-chnames[u'\u00e9'] = _("e acute")
+chnames['\u00e9'] = _("e acute")
# Translators: this is the spoken word for the character 'Ã' (U+00ea)
#
-chnames[u'\u00ea'] = _("e circumflex")
+chnames['\u00ea'] = _("e circumflex")
# Translators: this is the spoken word for the character 'Ã' (U+00eb)
#
-chnames[u'\u00eb'] = _("e umlaut")
+chnames['\u00eb'] = _("e umlaut")
# Translators: this is the spoken word for the character 'Ã' (U+00ec)
#
-chnames[u'\u00ec'] = _("i grave")
+chnames['\u00ec'] = _("i grave")
# Translators: this is the spoken word for the character 'Ã' (U+00ed)
#
-chnames[u'\u00ed'] = _("i acute")
+chnames['\u00ed'] = _("i acute")
# Translators: this is the spoken word for the character 'Ã' (U+00ee)
#
-chnames[u'\u00ee'] = _("i circumflex")
+chnames['\u00ee'] = _("i circumflex")
# Translators: this is the spoken word for the character 'Ã' (U+00ef)
#
-chnames[u'\u00ef'] = _("i umlaut")
+chnames['\u00ef'] = _("i umlaut")
# Translators: this is the spoken word for the character 'Ã' (U+00f0)
#
-chnames[u'\u00f0'] = _("eth")
+chnames['\u00f0'] = _("eth")
# Translators: this is the spoken word for the character 'Ã' (U+00f1)
#
-chnames[u'\u00f1'] = _("n tilde")
+chnames['\u00f1'] = _("n tilde")
# Translators: this is the spoken word for the character 'Ã' (U+00f2)
#
-chnames[u'\u00f2'] = _("o grave")
+chnames['\u00f2'] = _("o grave")
# Translators: this is the spoken word for the character 'Ã' (U+00f3)
#
-chnames[u'\u00f3'] = _("o acute")
+chnames['\u00f3'] = _("o acute")
# Translators: this is the spoken word for the character 'Ã' (U+00f4)
#
-chnames[u'\u00f4'] = _("o circumflex")
+chnames['\u00f4'] = _("o circumflex")
# Translators: this is the spoken word for the character 'Ã' (U+00f5)
#
-chnames[u'\u00f5'] = _("o tilde")
+chnames['\u00f5'] = _("o tilde")
# Translators: this is the spoken word for the character 'Ã' (U+00f6)
#
-chnames[u'\u00f6'] = _("o umlaut")
+chnames['\u00f6'] = _("o umlaut")
# Translators: this is the spoken word for the character 'Ã' (U+00f7)
#
-chnames[u'\u00f7'] = _("divided by")
+chnames['\u00f7'] = _("divided by")
# Translators: this is the spoken word for the character 'Ã' (U+00f8)
#
-chnames[u'\u00f8'] = _("o stroke")
+chnames['\u00f8'] = _("o stroke")
# Translators: this is the spoken word for the character 'Ã' (U+00fe)
#
-chnames[u'\u00fe'] = _("thorn")
+chnames['\u00fe'] = _("thorn")
# Translators: this is the spoken word for the character 'Ã' (U+00fa)
#
-chnames[u'\u00fa'] = _("u acute")
+chnames['\u00fa'] = _("u acute")
# Translators: this is the spoken word for the character 'Ã' (U+00f9)
#
-chnames[u'\u00f9'] = _("u grave")
+chnames['\u00f9'] = _("u grave")
# Translators: this is the spoken word for the character 'Ã' (U+00fb)
#
-chnames[u'\u00fb'] = _("u circumflex")
+chnames['\u00fb'] = _("u circumflex")
# Translators: this is the spoken word for the character 'Ã' (U+00fc)
#
-chnames[u'\u00fc'] = _("u umlaut")
+chnames['\u00fc'] = _("u umlaut")
# Translators: this is the spoken word for the character 'Ã' (U+00fd)
#
-chnames[u'\u00fd'] = _("y acute")
+chnames['\u00fd'] = _("y acute")
# Translators: this is the spoken word for the character 'Ã' (U+00ff)
#
-chnames[u'\u00ff'] = _("y umlaut")
+chnames['\u00ff'] = _("y umlaut")
# Translators: this is the spoken word for the character 'Å' (U+0178)
#
-chnames[u'\u0178'] = _("Y UMLAUT")
+chnames['\u0178'] = _("Y UMLAUT")
# Translators: this is the spoken word for the character 'Æ' (U+0192)
#
-chnames[u'\u0192'] = _("florin")
+chnames['\u0192'] = _("florin")
# Translators: this is the spoken word for the character 'â' (U+2013)
#
-chnames[u'\u2013'] = _("en dash")
+chnames['\u2013'] = _("en dash")
# Translators: this is the spoken word for the left single quote: â
# (U+2018)
#
-chnames[u'\u2018'] = _("left single quote")
+chnames['\u2018'] = _("left single quote")
# Translators: this is the spoken word for the right single quote: â
# (U+2019)
#
-chnames[u'\u2019'] = _("right single quote")
+chnames['\u2019'] = _("right single quote")
# Translators: this is the spoken word for the character 'â' (U+201a)
#
-chnames[u'\u201a'] = _("single low quote")
+chnames['\u201a'] = _("single low quote")
# Translators: this is the spoken word for the character 'â' (U+201c)
#
-chnames[u'\u201c'] = _("left double quote")
+chnames['\u201c'] = _("left double quote")
# Translators: this is the spoken word for the character 'â' (U+201d)
#
-chnames[u'\u201d'] = _("right double quote")
+chnames['\u201d'] = _("right double quote")
# Translators: this is the spoken word for the character 'â' (U+201e)
#
-chnames[u'\u201e'] = _("double low quote")
+chnames['\u201e'] = _("double low quote")
# Translators: this is the spoken word for the character 'â' (U+2020)
#
-chnames[u'\u2020'] = _("dagger")
+chnames['\u2020'] = _("dagger")
# Translators: this is the spoken word for the character 'â' (U+2021)
#
-chnames[u'\u2021'] = _("double dagger")
+chnames['\u2021'] = _("double dagger")
# Translators: this is the spoken word for the character 'â' (U+2022)
#
-chnames[u'\u2022'] = _("bullet")
+chnames['\u2022'] = _("bullet")
# Translators: this is the spoken word for the character 'â' (U+2023)
#
-chnames[u'\u2023'] = _("triangular bullet")
+chnames['\u2023'] = _("triangular bullet")
# Translators: this is the spoken word for the character 'â' (U+2030)
#
-chnames[u'\u2030'] = _("per mille")
+chnames['\u2030'] = _("per mille")
# Translators: this is the spoken word for the character 'â' (U+2032)
#
-chnames[u'\u2032'] = _("prime")
+chnames['\u2032'] = _("prime")
# Translators: this is the spoken word for the character 'â' (U+2033)
#
-chnames[u'\u2033'] = _("double prime")
+chnames['\u2033'] = _("double prime")
# Translators: this is the spoken word for the character 'â' (U+2043)
#
-chnames[u'\u2043'] = _("hyphen bullet")
+chnames['\u2043'] = _("hyphen bullet")
# Translators: this is the spoken word for the character 'â' (U+20ac)
#
-chnames[u'\u20ac'] = _("euro")
+chnames['\u20ac'] = _("euro")
# Translators: this is the spoken word for the character 'â' (U+2122)
#
-chnames[u'\u2122'] = _("trademark")
+chnames['\u2122'] = _("trademark")
# Translators: this is the spoken word for the character 'â' (U+2190)
#
-chnames[u'\u2190'] = _("left arrow")
+chnames['\u2190'] = _("left arrow")
# Translators: this is the spoken word for the character 'â' (U+2192)
#
-chnames[u'\u2192'] = _("right arrow")
+chnames['\u2192'] = _("right arrow")
# Translators: this is the spoken word for the character 'â' (U+2248)
#
-chnames[u'\u2248'] = _("almost equal to")
+chnames['\u2248'] = _("almost equal to")
# Translators: this is the spoken word for the character 'â' (U+2260)
#
-chnames[u'\u2260'] = _("not equal to")
+chnames['\u2260'] = _("not equal to")
# Translators: this is the spoken word for the character 'â' (U+2264)
#
-chnames[u'\u2264'] = _("less than or equal to")
+chnames['\u2264'] = _("less than or equal to")
# Translators: this is the spoken word for the character 'â' (U+2265)
#
-chnames[u'\u2265'] = _("greater than or equal to")
+chnames['\u2265'] = _("greater than or equal to")
# Translators: this is the spoken word for the character 'â' (U+221a)
#
-chnames[u'\u221a'] = _("square root")
+chnames['\u221a'] = _("square root")
# Translators: this is the spoken word for the character 'â' (U+221b)
#
-chnames[u'\u221b'] = _("cube root")
+chnames['\u221b'] = _("cube root")
# Translators: this is the spoken word for the character 'â' (U+221e)
#
-chnames[u'\u221e'] = _("infinity")
+chnames['\u221e'] = _("infinity")
# Translators: this is the spoken word for the character 'â' (U+25a0)
# It can be used as a bullet in a list.
#
-chnames[u'\u25a0'] = _("black square")
+chnames['\u25a0'] = _("black square")
# Translators: this is the spoken word for the character 'â' (U+25a1)
# It can be used as a bullet in a list.
#
-chnames[u'\u25a1'] = _("white square")
+chnames['\u25a1'] = _("white square")
# Translators: this is the spoken word for the character 'â' (U+25c6)
# It can be used as a bullet in a list.
#
-chnames[u'\u25c6'] = _("black diamond")
+chnames['\u25c6'] = _("black diamond")
# Translators: this is the spoken word for the character 'â' (U+25cb)
# It can be used as a bullet in a list.
#
-chnames[u'\u25cb'] = _("white circle")
+chnames['\u25cb'] = _("white circle")
# Translators: this is the spoken word for the character 'â' (U+25cf)
# It can be used as a bullet in a list.
#
-chnames[u'\u25cf'] = _("black circle")
+chnames['\u25cf'] = _("black circle")
# Translators: this is the spoken word for the character 'â' (U+25e6)
#
-chnames[u'\u25e6'] = _("white bullet")
+chnames['\u25e6'] = _("white bullet")
# Translators: this is the spoken word for the character 'â' (U+2713)
# It can be used as a bullet in a list.
#
-chnames[u'\u2713'] = _("check mark")
+chnames['\u2713'] = _("check mark")
# Translators: this is the spoken word for the character 'â' (U+2714)
# It can be used as a bullet in a list.
#
-chnames[u'\u2714'] = _("heavy check mark")
+chnames['\u2714'] = _("heavy check mark")
# Translators: this is the spoken word for the character 'x' (U+2717)
# This symbol is included here because it can be used as a bullet in
@@ -719,145 +719,145 @@ chnames[u'\u2714'] = _("heavy check mark")
# the typed letter 'x'. "Ballot x" might confuse the user. Hence the
# use of "x-shaped bullet".
#
-chnames[u'\u2717'] = _("x-shaped bullet")
+chnames['\u2717'] = _("x-shaped bullet")
# Translators: this is the spoken word for the character 'â' (U+2794)
# This symbol is included here because it can be used as a bullet in
# an OOo list. The goal is to inform the user of the appearance of
# the bullet without too much verbiage, hence simply "right-pointing arrow".
#
-chnames[u'\u2794'] = _("right-pointing arrow")
+chnames['\u2794'] = _("right-pointing arrow")
# Translators: this is the spoken word for the character 'â' (U+2070)
#
-chnames[u'\u2070'] = _("superscript 0")
+chnames['\u2070'] = _("superscript 0")
# Translators: this is the spoken word for the character 'â' (U+2074)
#
-chnames[u'\u2074'] = _("superscript 4")
+chnames['\u2074'] = _("superscript 4")
# Translators: this is the spoken word for the character 'â' (U+2075)
#
-chnames[u'\u2075'] = _("superscript 5")
+chnames['\u2075'] = _("superscript 5")
# Translators: this is the spoken word for the character 'â' (U+2076)
#
-chnames[u'\u2076'] = _("superscript 6")
+chnames['\u2076'] = _("superscript 6")
# Translators: this is the spoken word for the character 'â' (U+2077)
#
-chnames[u'\u2077'] = _("superscript 7")
+chnames['\u2077'] = _("superscript 7")
# Translators: this is the spoken word for the character 'â' (U+2078)
#
-chnames[u'\u2078'] = _("superscript 8")
+chnames['\u2078'] = _("superscript 8")
# Translators: this is the spoken word for the character 'â' (U+2079)
#
-chnames[u'\u2079'] = _("superscript 9")
+chnames['\u2079'] = _("superscript 9")
# Translators: this is the spoken word for the character 'â' (U+207a)
#
-chnames[u'\u207a'] = _("superscript plus")
+chnames['\u207a'] = _("superscript plus")
# Translators: this is the spoken word for the character 'â' (U+207b)
#
-chnames[u'\u207b'] = _("superscript minus")
+chnames['\u207b'] = _("superscript minus")
# Translators: this is the spoken word for the character 'â' (U+207c)
#
-chnames[u'\u207c'] = _("superscript equals")
+chnames['\u207c'] = _("superscript equals")
# Translators: this is the spoken word for the character 'â' (U+207d)
#
-chnames[u'\u207d'] = _("superscript left paren")
+chnames['\u207d'] = _("superscript left paren")
# Translators: this is the spoken word for the character 'â' (U+207e)
#
-chnames[u'\u207e'] = _("superscript right paren")
+chnames['\u207e'] = _("superscript right paren")
# Translators: this is the spoken word for the character 'â' (U+207f)
#
-chnames[u'\u207f'] = _("superscript n")
+chnames['\u207f'] = _("superscript n")
# Translators: this is the spoken word for the character 'â' (U+2080)
#
-chnames[u'\u2080'] = _("subscript 0")
+chnames['\u2080'] = _("subscript 0")
# Translators: this is the spoken word for the character 'â' (U+2081)
#
-chnames[u'\u2081'] = _("subscript 1")
+chnames['\u2081'] = _("subscript 1")
# Translators: this is the spoken word for the character 'â' (U+2082)
#
-chnames[u'\u2082'] = _("subscript 2")
+chnames['\u2082'] = _("subscript 2")
# Translators: this is the spoken word for the character 'â' (U+2083)
#
-chnames[u'\u2083'] = _("subscript 3")
+chnames['\u2083'] = _("subscript 3")
# Translators: this is the spoken word for the character 'â' (U+2084)
#
-chnames[u'\u2084'] = _("subscript 4")
+chnames['\u2084'] = _("subscript 4")
# Translators: this is the spoken word for the character 'â' (U+2085)
#
-chnames[u'\u2085'] = _("subscript 5")
+chnames['\u2085'] = _("subscript 5")
# Translators: this is the spoken word for the character 'â' (U+2086)
#
-chnames[u'\u2086'] = _("subscript 6")
+chnames['\u2086'] = _("subscript 6")
# Translators: this is the spoken word for the character 'â' (U+2087)
#
-chnames[u'\u2087'] = _("subscript 7")
+chnames['\u2087'] = _("subscript 7")
# Translators: this is the spoken word for the character 'â' (U+2088)
#
-chnames[u'\u2088'] = _("subscript 8")
+chnames['\u2088'] = _("subscript 8")
# Translators: this is the spoken word for the character 'â' (U+2089)
#
-chnames[u'\u2089'] = _("subscript 9")
+chnames['\u2089'] = _("subscript 9")
# Translators: this is the spoken word for the character 'â' (U+208a)
#
-chnames[u'\u208a'] = _("subscript plus")
+chnames['\u208a'] = _("subscript plus")
# Translators: this is the spoken word for the character 'â' (U+208b)
#
-chnames[u'\u208b'] = _("subscript minus")
+chnames['\u208b'] = _("subscript minus")
# Translators: this is the spoken word for the character 'â' (U+208c)
#
-chnames[u'\u208c'] = _("subscript equals")
+chnames['\u208c'] = _("subscript equals")
# Translators: this is the spoken word for the character 'â' (U+208d)
#
-chnames[u'\u208d'] = _("subscript left paren")
+chnames['\u208d'] = _("subscript left paren")
# Translators: this is the spoken word for the character 'â' (U+208e)
#
-chnames[u'\u208e'] = _("subscript right paren")
+chnames['\u208e'] = _("subscript right paren")
# Translators: this is the spoken word for the character 'â' (U+27a2)
# This symbol is included here because it can be used as a bullet in an
# OOo list. The goal is to inform the user of the appearance of the bullet
# without too much verbiage, hence simply "right-pointing arrowhead".
#
-chnames[u'\u27a2'] = _("right-pointing arrowhead")
+chnames['\u27a2'] = _("right-pointing arrowhead")
# Translators: StarOffice/OOo includes private-use unicode character U+E00A
# as a bullet which looks like the black square: â (U+25A0). Therefore,
# please use the same translation for this character.
#
-chnames[u'\ue00a'] = _("black square")
+chnames['\ue00a'] = _("black square")
# Translators: StarOffice/OOo includes private-use unicode character U+E00C
# as a bullet which looks like the black diamond: â (U+25C6). Therefore,
# please use the same translation for this character.
#
-chnames[u'\ue00c'] = _("black diamond")
+chnames['\ue00c'] = _("black diamond")
def getCharacterName(character):
"""Given a character, return its name as people might refer to it
@@ -869,10 +869,4 @@ def getCharacterName(character):
Returns a string representing the name for the character
"""
- if not isinstance(character, unicode):
- character = character.decode("UTF-8")
-
- try:
- return chnames[character]
- except:
- return character
+ return chnames.get(character, character)
diff --git a/src/orca/debug.py b/src/orca/debug.py
index 02b8b25..75609ed 100644
--- a/src/orca/debug.py
+++ b/src/orca/debug.py
@@ -203,18 +203,12 @@ def println(level, text = ""):
except TypeError:
text = "TypeError when trying to write text"
debugFile.writelines([text, "\n"])
- except UnicodeDecodeError:
- text = "UnicodeDecodeError when trying to write text"
- debugFile.writelines([text, "\n"])
else:
try:
sys.stderr.writelines([text, "\n"])
except TypeError:
text = "TypeError when trying to write text"
sys.stderr.writelines([text, "\n"])
- except UnicodeDecodeError:
- text = "UnicodeDecodeError when trying to write text"
- debugFile.writelines([text, "\n"])
def printResult(level, result=None):
"""Prints the return result, along with information about the
@@ -237,7 +231,7 @@ def printResult(level, result=None):
# To better print arguments which are accessible objects
args = inspect.getargvalues(frame)
- for key, value in args.locals.items():
+ for key, value in list(args.locals.items()):
args.locals[key] = str(value)
fArgs = str.replace(inspect.formatargvalues(*args), "'", "")
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index a8fe7ef..f2a263c 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -26,7 +26,7 @@ __license__ = "LGPL"
from gi.repository import GObject
import pyatspi
-import Queue
+import queue
import threading
import time
@@ -48,7 +48,7 @@ class EventManager:
self.registry = pyatspi.Registry
self._enqueueCount = 0
self._dequeueCount = 0
- self._eventQueue = Queue.Queue(0)
+ self._eventQueue = queue.Queue(0)
self._gidleId = 0
self._gidleLock = threading.Lock()
self.noFocusTimestamp = 0.0
@@ -76,9 +76,6 @@ class EventManager:
def _ignore(self, event):
"""Returns True if this event should be ignored."""
- if not event or not event.source:
- return True
-
ignoredList = ['object:state-changed:defunct',
'object:property-change:accessible-parent']
ignoredList.extend(settings.ignoredEventsList)
@@ -223,10 +220,13 @@ class EventManager:
# some reason if done inside an acquire/release block for a
# lock. So...we do it here.]]]
#
- noFocus = \
- not orca_state.activeScript \
- or (not orca_state.locusOfFocus \
- and self.noFocusTimestamp != orca_state.noFocusTimestamp)
+ try:
+ noFocus = \
+ not orca_state.activeScript \
+ or (not orca_state.locusOfFocus and \
+ self.noFocusTimestamp != orca_state.noFocusTimestamp)
+ except:
+ noFocus = True
self._gidleLock.acquire()
if self._eventQueue.empty():
@@ -244,7 +244,7 @@ class EventManager:
self._gidleId = 0
rerun = False # destroy and don't call again
self._gidleLock.release()
- except Queue.Empty:
+ except queue.Empty:
debug.println(debug.LEVEL_SEVERE,
"event_manager._dequeue: the event queue is empty!")
self._gidleId = 0
@@ -416,7 +416,8 @@ class EventManager:
debug.println(debug.LEVEL_WARNING, msg)
return None
except:
- debug.printException(debug.LEVEL_WARNING)
+ msg = 'WARNING: Exception when getting script for event.'
+ debug.println(debug.LEVEL_WARNING, msg)
else:
script = _scriptManager.getScript(app, event.source)
@@ -517,7 +518,6 @@ class EventManager:
orca_state.activeWindow = None
return
except:
- debug.printException(debug.LEVEL_WARNING)
return
if state and state.contains(pyatspi.STATE_DEFUNCT):
diff --git a/src/orca/flat_review.py b/src/orca/flat_review.py
index ed0bd43..e136ada 100644
--- a/src/orca/flat_review.py
+++ b/src/orca/flat_review.py
@@ -46,7 +46,7 @@ from .orca_i18n import ngettext
#
whitespace_re = re.compile(r'(\s+)', re.DOTALL | re.IGNORECASE | re.M)
-EMBEDDED_OBJECT_CHARACTER = u'\ufffc'
+EMBEDDED_OBJECT_CHARACTER = '\ufffc'
class Char:
"""Represents a single char of an Accessibility_Text object."""
@@ -100,7 +100,7 @@ class Word:
self.index = index
self.startOffset = startOffset
self.string = string
- self.length = len(string.decode("UTF-8"))
+ self.length = len(string)
self.x = x
self.y = y
self.width = width
@@ -142,7 +142,7 @@ class Word:
# Bug #495303. We can try to correct this.
#
if len(char):
- char = char.decode("UTF-8")[0].encode("UTF-8")
+ char[0]
[x, y, width, height] = text.getRangeExtents(
startOffset,
startOffset + 1,
@@ -180,7 +180,7 @@ class Zone:
self.accessible = accessible
self.string = string
- self.length = len(string.decode("UTF-8"))
+ self.length = len(string)
self.x = x
self.y = y
self.width = width
@@ -236,7 +236,7 @@ class Zone:
wordAtOffset = None
offset = 0
for word in self.words:
- nextOffset = offset + len(word.string.decode("UTF-8"))
+ nextOffset = offset + len(word.string)
wordAtOffset = word
if nextOffset > charOffset:
return [wordAtOffset, charOffset - offset]
@@ -298,7 +298,7 @@ class TextZone(Zone):
offset = self.startOffset
for string in whitespace_re.split(self.string):
if len(string):
- endOffset = offset + len(string.decode("UTF-8"))
+ endOffset = offset + len(string)
[x, y, width, height] = text.getRangeExtents(
offset,
endOffset,
@@ -577,10 +577,7 @@ class Line:
region.brailleOffset = brailleOffset
self.brailleRegions.append(region)
- try:
- regionString = region.string.decode("UTF-8")
- except UnicodeEncodeError:
- regionString = region.string
+ regionString = region.string
brailleOffset += len(regionString)
if not settings.disableBrailleEOL:
@@ -791,7 +788,7 @@ class Context:
substringStartOffset = startOffset
substringEndOffset = startOffset
unicodeStartOffset = 0
- unicodeString = string.decode("UTF-8")
+ unicodeString = string
#print "LOOKING AT '%s'" % unicodeString
for i in range(0, len(unicodeString) + 1):
if (i != len(unicodeString)) \
@@ -840,7 +837,7 @@ class Context:
#print " SUBSTRING '%s'" % substring
zones.append(TextZone(accessible,
substringStartOffset,
- substring.encode("UTF-8"),
+ substring.
clipping[0],
clipping[1],
clipping[2],
@@ -919,16 +916,6 @@ class Context:
offset,
pyatspi.TEXT_BOUNDARY_LINE_START)
- #NEED TO SKIP OVER EMBEDDED_OBJECT_CHARACTERS
-
- #print "STRING at %d is (start=%d end=%d): '%s'" \
- # % (offset, startOffset, endOffset, string)
- #if startOffset > offset:
- # embedded = text.getText(offset, offset + 1).decode("UTF-8")
- # if embedded[0] == \
- # orca_state.activeScript.EMBEDDED_OBJECT_CHARACTER:
- # offset = startOffset
-
debug.println(debug.LEVEL_FINEST,
" line at %d is (start=%d end=%d): '%s'" \
% (offset, startOffset, endOffset, string))
@@ -1640,7 +1627,7 @@ class Context:
if zone.words:
for wordIndex in range(0, self.wordIndex):
regionWithFocus.cursorOffset += \
- len(zone.words[wordIndex].string.decode("UTF-8"))
+ len(zone.words[wordIndex].string)
regionWithFocus.cursorOffset += self.charIndex
regionWithFocus.repositionCursor()
break
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index f8907c1..2b216a0 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -620,8 +620,8 @@ class Formatting(dict):
if key in self:
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], str) \
+ and isinstance(val, str):
self[key] = val
else:
# exception or such like, we are trying to murge
diff --git a/src/orca/generator.py b/src/orca/generator.py
index f302a18..582f3c6 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -912,11 +912,6 @@ class Generator:
if not displayedText:
return []
- try:
- displayedText = displayedText.decode('UTF-8')
- except (UnicodeDecodeError, UnicodeEncodeError):
- pass
-
return [displayedText]
#####################################################################
diff --git a/src/orca/input_event.py b/src/orca/input_event.py
index 1c1d5e2..1d32778 100644
--- a/src/orca/input_event.py
+++ b/src/orca/input_event.py
@@ -267,17 +267,7 @@ class KeyboardEvent(InputEvent):
if orca_state.bypassNextCommand:
return False
- orcaMods = settings.orcaModifierKeys
- try:
- orcaMods = [x.encode('UTF-8') for x in orcaMods]
- except (UnicodeDecodeError, UnicodeEncodeError):
- pass
-
- string = self.event_string
- if isinstance(string, unicode):
- string = string.encode('UTF-8')
-
- return string in orcaMods
+ return self.event_string in settings.orcaModifierKeys
def isOrcaModified(self):
"""Return True if this key is Orca modified."""
@@ -296,14 +286,13 @@ class KeyboardEvent(InputEvent):
if self.event_string in ["space", " "]:
return True
- unicodeString = self.event_string.decode("UTF-8")
- if not len(unicodeString) == 1:
+ if not len(self.event_string) == 1:
return False
- if unicodeString.isalnum() or unicodeString.isspace():
+ if self.event_string.isalnum() or self.event_string.isspace():
return True
- return unicodedata.category(unicodeString)[0] in ('P', 'S')
+ return unicodedata.category(self.event_string)[0] in ('P', 'S')
def isPressedKey(self):
"""Returns True if the key is pressed"""
@@ -486,6 +475,10 @@ class InputEventHandler:
def __eq__(self, other):
"""Compares one input handler to another."""
+
+ if not other:
+ return False
+
return (self.function == other.function)
def processInputEvent(self, script, inputEvent):
diff --git a/src/orca/keybindings.py b/src/orca/keybindings.py
index 733b802..4d0bb1f 100644
--- a/src/orca/keybindings.py
+++ b/src/orca/keybindings.py
@@ -28,7 +28,9 @@ __license__ = "LGPL"
from gi.repository import Gdk
+import functools
import pyatspi
+
from . import debug
from . import settings
@@ -367,8 +369,8 @@ class KeyBindings:
# the one whose click count is closest to, but does not exceed,
# the actual click count.
#
- candidates.sort(cmp=lambda x, y: x.click_count - y.click_count,
- reverse=True)
+ comparison = lambda x, y: y.click_count - x.click_count
+ candidates.sort(key=functools.cmp_to_key(comparison))
for candidate in candidates:
if candidate.click_count <= clickCount:
return candidate.handler
diff --git a/src/orca/keynames.py b/src/orca/keynames.py
index ccd2188..731821a 100644
--- a/src/orca/keynames.py
+++ b/src/orca/keynames.py
@@ -316,13 +316,7 @@ def getKeyName(key):
Returns a string representing the name for the key
"""
- if isinstance(key, unicode):
- key = key.encode("UTF-8")
-
- try:
- return __keynames[key]
- except:
- return chnames.getCharacterName(key)
+ return __keynames.get(key, chnames.getCharacterName(key))
def localizeKeySequence(keys):
"""Given a sequence of keys, such as 'Shift Control A', localize the
@@ -338,14 +332,6 @@ def localizeKeySequence(keys):
keyList = keys.split()
for key in keyList:
keyName = getKeyName(key)
- try:
- key = key.encode("UTF-8")
- except UnicodeDecodeError:
- pass
- try:
- keyName = keyName.encode("UTF-8")
- except UnicodeDecodeError:
- pass
keys = keys.replace(key, keyName)
return keys
diff --git a/src/orca/liveregions.py b/src/orca/liveregions.py
index 89e9191..6a58bf2 100644
--- a/src/orca/liveregions.py
+++ b/src/orca/liveregions.py
@@ -436,10 +436,6 @@ class LiveRegionManager:
# We found an embed character. We can expect a children-changed
# event, which we will act on, so just return.
txt = sourceitext.getText(0, -1)
- try:
- txt = txt.decode("UTF-8")
- except UnicodeEncodeError:
- pass
if txt.count(self._script.EMBEDDED_OBJECT_CHARACTER) > 0:
return None
diff --git a/src/orca/logger.py b/src/orca/logger.py
index a93d489..0530d97 100644
--- a/src/orca/logger.py
+++ b/src/orca/logger.py
@@ -29,7 +29,7 @@ __copyright__ = "Copyright (c) 2012 Igalia, S.L."
__license__ = "LGPL"
import logging
-import StringIO
+import io
from . import debug
@@ -72,7 +72,7 @@ class Logger:
def _createStreamHandlers(self):
for logger in self._types:
- stringIO = StringIO.StringIO()
+ stringIO = io.StringIO()
handler = logging.StreamHandler(stringIO)
self._streamHandlers[logger] = [stringIO, handler]
log = logging.getLogger(logger)
diff --git a/src/orca/orca_console_prefs.py b/src/orca/orca_console_prefs.py
index 7558ad5..0203cd4 100644
--- a/src/orca/orca_console_prefs.py
+++ b/src/orca/orca_console_prefs.py
@@ -103,7 +103,7 @@ def sayAndPrint(text,
speech.speak(text, voice)
if getInput:
- return raw_input(text)
+ return input(text)
else:
print(text)
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 4efed86..0e1aaa9 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -607,9 +607,6 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
if len(self.speechFamiliesChoices) == 0:
return
- if isinstance(familyName, unicode):
- familyName = familyName.encode('UTF-8')
-
valueSet = False
i = 0
for family in self.speechFamiliesChoices:
@@ -719,11 +716,6 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
if not serverInfo:
serverInfo = speech.getInfo()
- try:
- serverInfo = [x.encode('UTF-8') for x in serverInfo]
- except (UnicodeDecodeError, UnicodeEncodeError):
- pass
-
valueSet = False
i = 0
for server in self.speechServersChoices:
@@ -1497,8 +1489,6 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
sdtime(settings.TIME_FORMAT_24_HM_WITH_WORDS, ltime())])
indextime = TIME_FORMAT_LOCALE
timeFormat = self.prefsDict["presentTimeFormat"]
- if isinstance(timeFormat, unicode):
- timeFormat = timeFormat.encode('UTF-8')
if timeFormat == settings.TIME_FORMAT_LOCALE:
indextime = TIME_FORMAT_LOCALE
elif timeFormat == settings.TIME_FORMAT_24_HMS:
@@ -1975,10 +1965,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
else:
clickCount = self._clickCountToString(kb.click_count)
modifierNames = keybindings.getModifierNames(kb.modifiers)
- try:
- keysymstring = kb.keysymstring.encode('UTF-8')
- except (UnicodeDecodeError, UnicodeEncodeError):
- keysymstring = kb.keysymstring
+ keysymstring = kb.keysymstring
text = keybindings.getModifierNames(kb.modifiers) \
+ keysymstring \
+ clickCount
@@ -2806,10 +2793,6 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
eventState = keyPressedEvent.state
orcaMods = settings.orcaModifierKeys
- try:
- orcaMods = [x.encode('UTF-8') for x in orcaMods]
- except (UnicodeDecodeError, UnicodeEncodeError):
- pass
if eventString in orcaMods:
self._capturedKey = ['', settings.ORCA_MODIFIER_MASK, 0]
return False
diff --git a/src/orca/phonnames.py b/src/orca/phonnames.py
index fcc688c..e380c60 100644
--- a/src/orca/phonnames.py
+++ b/src/orca/phonnames.py
@@ -76,10 +76,4 @@ def getPhoneticName(character):
Returns a string representing the military name for the character
"""
- if isinstance(character, unicode):
- character = character.encode("UTF-8")
-
- try:
- return __phonnames[character]
- except:
- return character
+ return __phonnames.get(character, character)
diff --git a/src/orca/pronunciation_dict.py b/src/orca/pronunciation_dict.py
index 5ea735b..36b72ea 100644
--- a/src/orca/pronunciation_dict.py
+++ b/src/orca/pronunciation_dict.py
@@ -43,10 +43,7 @@ def getPronunciation(word, pronunciations=None):
the word if there is no representation.
"""
- if isinstance(word, unicode):
- word = word.encode("UTF-8")
-
- lowerWord = word.decode("UTF-8").lower().encode("UTF-8")
+ lowerWord = word.lower()
dictionary = pronunciations or pronunciation_dict
entry = dictionary.get(lowerWord, [word, word])
@@ -63,7 +60,7 @@ def setPronunciation(word, replacementString, pronunciations=None):
into.
"""
- key = word.decode("UTF-8").lower().encode("UTF-8")
+ key = word.lower()
if pronunciations != None:
pronunciations[key] = [ word, replacementString ]
else:
diff --git a/src/orca/punctuation_settings.py b/src/orca/punctuation_settings.py
index ba44993..167eed4 100644
--- a/src/orca/punctuation_settings.py
+++ b/src/orca/punctuation_settings.py
@@ -63,100 +63,100 @@ LEVEL_NONE = settings.PUNCTUATION_STYLE_NONE
# Bullets and bullet-like characters
#
-middle_dot = u'\u00b7'
-bullet = u'\u2022'
-triangular_bullet = u'\u2023'
-hyphen_bullet = u'\u2043'
-black_square = u'\u25a0'
-white_square = u'\u25a1'
-white_bullet = u'\u25e6'
-white_circle = u'\u25cb'
-black_diamond = u'\u25c6'
-black_circle = u'\u25cf'
-check_mark = u'\u2713'
-heavy_check_mark = u'\u2714'
-x_shaped_bullet = u'\u2717'
-heavy_right_arrow = u'\u2794'
-right_arrowhead = u'\u27a2'
+middle_dot = '\u00b7'
+bullet = '\u2022'
+triangular_bullet = '\u2023'
+hyphen_bullet = '\u2043'
+black_square = '\u25a0'
+white_square = '\u25a1'
+white_bullet = '\u25e6'
+white_circle = '\u25cb'
+black_diamond = '\u25c6'
+black_circle = '\u25cf'
+check_mark = '\u2713'
+heavy_check_mark = '\u2714'
+x_shaped_bullet = '\u2717'
+heavy_right_arrow = '\u2794'
+right_arrowhead = '\u27a2'
# StarOffice/OOo's special-purpose bullet chararacters
#
-SO_black_square = u'\ue00a'
-SO_black_diamond = u'\ue00c'
+SO_black_square = '\ue00a'
+SO_black_diamond = '\ue00c'
# Miscellaneous other symbols
#
-cent = u'\u00a2'
-pound = u'\u00a3'
-yen = u'\u00a5'
-section = u'\u00a7'
-copyright_sign = u'\u00a9'
-left_double_angle = u'\u00ab'
-not_sign = u'\u00ac'
-registered = u'\u00ae'
-degree = u'\u00b0'
-plus_minus = u'\u00b1'
-right_double_angle = u'\u00bb'
-one_quarter = u'\u00bc'
-one_half = u'\u00bd'
-three_quarters = u'\u00be'
-multiply = u'\u00d7'
-divide = u'\u00f7'
-en_dash = u'\u2013'
-left_single_quote = u'\u2018'
-right_single_quote = u'\u2019'
-single_low_quote = u'\u201a'
-left_double_quote = u'\u201c'
-right_double_quote = u'\u201d'
-double_low_quote = u'\u201e'
-dagger = u'\u2020'
-double_dagger = u'\u2021'
-per_mille = u'\u2030'
-prime = u'\u2032'
-double_prime = u'\u2033'
-euro = u'\u20ac'
-trademark = u'\u2122'
-left_arrow = u'\u2190'
-right_arrow = u'\u2192'
-infinity = u'\u221e'
-almost_equal = u'\u2248'
-not_equal = u'\u2260'
-lt_or_equal = u'\u2264'
-gt_or_equal = u'\u2265'
-square_root = u'\u221a'
-cube_root = u'\u221b'
+cent = '\u00a2'
+pound = '\u00a3'
+yen = '\u00a5'
+section = '\u00a7'
+copyright_sign = '\u00a9'
+left_double_angle = '\u00ab'
+not_sign = '\u00ac'
+registered = '\u00ae'
+degree = '\u00b0'
+plus_minus = '\u00b1'
+right_double_angle = '\u00bb'
+one_quarter = '\u00bc'
+one_half = '\u00bd'
+three_quarters = '\u00be'
+multiply = '\u00d7'
+divide = '\u00f7'
+en_dash = '\u2013'
+left_single_quote = '\u2018'
+right_single_quote = '\u2019'
+single_low_quote = '\u201a'
+left_double_quote = '\u201c'
+right_double_quote = '\u201d'
+double_low_quote = '\u201e'
+dagger = '\u2020'
+double_dagger = '\u2021'
+per_mille = '\u2030'
+prime = '\u2032'
+double_prime = '\u2033'
+euro = '\u20ac'
+trademark = '\u2122'
+left_arrow = '\u2190'
+right_arrow = '\u2192'
+infinity = '\u221e'
+almost_equal = '\u2248'
+not_equal = '\u2260'
+lt_or_equal = '\u2264'
+gt_or_equal = '\u2265'
+square_root = '\u221a'
+cube_root = '\u221b'
-superscript_zero = u'\u2070'
-superscript1 = u'\u00b9'
-superscript2 = u'\u00b2'
-superscript3 = u'\u00b3'
-superscript4 = u'\u2074'
-superscript5 = u'\u2075'
-superscript6 = u'\u2076'
-superscript7 = u'\u2077'
-superscript8 = u'\u2078'
-superscript9 = u'\u2079'
-superscript_plus = u'\u207a'
-superscript_minus = u'\u207b'
-superscript_equals = u'\u207c'
-superscript_left_paren = u'\u207d'
-superscript_right_paren = u'\u207e'
-superscriptn = u'\u207f'
-subscript_zero = u'\u2080'
-subscript1 = u'\u2081'
-subscript2 = u'\u2082'
-subscript3 = u'\u2083'
-subscript4 = u'\u2084'
-subscript5 = u'\u2085'
-subscript6 = u'\u2086'
-subscript7 = u'\u2087'
-subscript8 = u'\u2088'
-subscript9 = u'\u2089'
-subscript_plus = u'\u208a'
-subscript_minus = u'\u208b'
-subscript_equals = u'\u208c'
-subscript_left_paren = u'\u208d'
-subscript_right_paren = u'\u208e'
+superscript_zero = '\u2070'
+superscript1 = '\u00b9'
+superscript2 = '\u00b2'
+superscript3 = '\u00b3'
+superscript4 = '\u2074'
+superscript5 = '\u2075'
+superscript6 = '\u2076'
+superscript7 = '\u2077'
+superscript8 = '\u2078'
+superscript9 = '\u2079'
+superscript_plus = '\u207a'
+superscript_minus = '\u207b'
+superscript_equals = '\u207c'
+superscript_left_paren = '\u207d'
+superscript_right_paren = '\u207e'
+superscriptn = '\u207f'
+subscript_zero = '\u2080'
+subscript1 = '\u2081'
+subscript2 = '\u2082'
+subscript3 = '\u2083'
+subscript4 = '\u2084'
+subscript5 = '\u2085'
+subscript6 = '\u2086'
+subscript7 = '\u2087'
+subscript8 = '\u2088'
+subscript9 = '\u2089'
+subscript_plus = '\u208a'
+subscript_minus = '\u208b'
+subscript_equals = '\u208c'
+subscript_left_paren = '\u208d'
+subscript_right_paren = '\u208e'
# punctuation is a dictionary where the keys represent a unicode
# character and the values are a list of two elements where the
@@ -299,10 +299,4 @@ def getPunctuationInfo(character):
or None
"""
- if not isinstance(character, unicode):
- character = character.decode("UTF-8")
-
- try:
- return punctuation[character]
- except:
- return None
+ return punctuation.get(character)
diff --git a/src/orca/script.py b/src/orca/script.py
index dbdaa30..f40d285 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -381,11 +381,6 @@ class Script:
- event: the Event
"""
- if not event.source:
- msg = 'script.processObjectEvent: event.source went away'
- debug.println(debug.LEVEL_FINE, msg)
- return
-
try:
role = event.source.getRole()
except (LookupError, RuntimeError):
diff --git a/src/orca/script_manager.py b/src/orca/script_manager.py
index be900f4..bed72cc 100644
--- a/src/orca/script_manager.py
+++ b/src/orca/script_manager.py
@@ -238,14 +238,19 @@ class ScriptManager:
toolkitScript.registerEventListeners()
self.toolkitScripts[app] = toolkitScripts
- if not app:
+ try:
+ if not app:
+ appScript = self.getDefaultScript()
+ elif app in self.appScripts:
+ appScript = self.appScripts[app]
+ else:
+ appScript = self._createScript(app, None)
+ self.appScripts[app] = appScript
+ appScript.registerEventListeners()
+ except:
+ msg = "WARNING: Exception getting app script."
+ debug.printException(debug.LEVEL_WARNING, msg)
appScript = self.getDefaultScript()
- elif app in self.appScripts:
- appScript = self.appScripts[app]
- else:
- appScript = self._createScript(app, None)
- self.appScripts[app] = appScript
- appScript.registerEventListeners()
# Only defer to the toolkit script for this object if the app script
# is based on a different toolkit.
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index b3c2e07..aad5e2b 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -28,6 +28,7 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2010 Joanmarie Diggs."
__license__ = "LGPL"
+import functools
import math
import pyatspi
import re
@@ -50,13 +51,13 @@ from .orca_i18n import ngettext
class Utilities:
- EMBEDDED_OBJECT_CHARACTER = u'\ufffc'
+ EMBEDDED_OBJECT_CHARACTER = '\ufffc'
SUPERSCRIPT_DIGITS = \
- [u'\u2070', u'\u00b9', u'\u00b2', u'\u00b3', u'\u2074',
- u'\u2075', u'\u2076', u'\u2077', u'\u2078', u'\u2079']
+ ['\u2070', '\u00b9', '\u00b2', '\u00b3', '\u2074',
+ '\u2075', '\u2076', '\u2077', '\u2078', '\u2079']
SUBSCRIPT_DIGITS = \
- [u'\u2080', u'\u2081', u'\u2082', u'\u2083', u'\u2084',
- u'\u2085', u'\u2086', u'\u2087', u'\u2088', u'\u2089']
+ ['\u2080', '\u2081', '\u2082', '\u2083', '\u2084',
+ '\u2085', '\u2086', '\u2087', '\u2088', '\u2089']
flags = re.UNICODE
WORDS_RE = re.compile("(\W+)", flags)
@@ -169,20 +170,24 @@ class Utilities:
Returns: a list of all objects under the specified object
"""
- if root.childCount <= 0:
+ if root and root.childCount <= 0:
return []
objlist = []
for i, child in enumerate(root):
debug.println(debug.LEVEL_FINEST,
"Script.allDescendants looking at child %d" % i)
- if child \
- and ((not onlyShowing) or (onlyShowing and \
- (child.getState().contains(pyatspi.STATE_SHOWING)))):
+ try:
+ state = child.getState()
+ except:
+ debug.println(debug.LEVEL_FINEST, "Error getting state")
+ continue
+
+ if not onlyShowing \
+ or (onlyShowing and state.contains(pyatspi.STATE_SHOWING)):
objlist.append(child)
- if (child.getState().contains( \
- pyatspi.STATE_MANAGES_DESCENDANTS) == 0) \
- and (child.childCount > 0):
+ if not state.contains(pyatspi.STATE_MANAGES_DESCENDANTS) \
+ and child.childCount > 0:
objlist.extend(Utilities.allDescendants(child, onlyShowing))
return objlist
@@ -580,23 +585,21 @@ class Utilities:
# current object is a single EMBEDDED_OBJECT_CHARACTER. In
# this case, we look to the child for the real text.]]]
#
- unicodeText = displayedText.decode("UTF-8")
- if unicodeText \
- and len(unicodeText) == 1 \
- and unicodeText[0] == self.EMBEDDED_OBJECT_CHARACTER \
+ if len(displayedText) == 1 \
+ and displayedText[0] == self.EMBEDDED_OBJECT_CHARACTER \
and obj.childCount > 0:
try:
displayedText = self.displayedText(obj[0])
except:
debug.printException(debug.LEVEL_WARNING)
- elif unicodeText:
+ else:
# [[[TODO: HACK - Welll.....we'll just plain ignore any
# text with EMBEDDED_OBJECT_CHARACTERs here. We still need a
# general case to handle this stuff and expand objects
# with EMBEDDED_OBJECT_CHARACTERs.]]]
#
- for i in range(len(unicodeText)):
- if unicodeText[i] == self.EMBEDDED_OBJECT_CHARACTER:
+ for i in range(len(displayedText)):
+ if displayedText[i] == self.EMBEDDED_OBJECT_CHARACTER:
displayedText = None
break
@@ -1531,9 +1534,12 @@ class Utilities:
"""
allLabels = self.descendantsWithRole(root, pyatspi.ROLE_LABEL)
- labels = [x for x in allLabels if not x.getRelationSet()]
- labels = [x for x in labels if x.parent and x.name != x.parent.name]
- labels = [x for x in labels if x.getState().contains(pyatspi.STATE_SHOWING)]
+ try:
+ labels = [x for x in allLabels if not x.getRelationSet()]
+ labels = [x for x in labels if x.parent and x.name != x.parent.name]
+ labels = [x for x in labels if x.getState().contains(pyatspi.STATE_SHOWING)]
+ except:
+ return []
# Eliminate duplicates
d = {}
@@ -1541,7 +1547,7 @@ class Utilities:
d[label.name] = label
labels = list(d.values())
- return sorted(labels, self.spatialComparison)
+ return sorted(labels, key=functools.cmp_to_key(self.spatialComparison))
def unfocusedAlertAndDialogCount(self, obj):
"""If the current application has one or more alert or dialog
@@ -1781,32 +1787,28 @@ class Utilities:
"""
string = self.substring(obj, startOffset, endOffset)
- if string:
- unicodeText = string.decode("UTF-8")
- if unicodeText and self.EMBEDDED_OBJECT_CHARACTER in unicodeText:
- # If we're not getting the full text of this object, but
- # rather a substring, we need to figure out the offset of
- # the first child within this substring.
- #
- childOffset = 0
- for child in obj:
- if Utilities.characterOffsetInParent(child) >= startOffset:
- break
- childOffset += 1
-
- toBuild = list(unicodeText)
- count = toBuild.count(self.EMBEDDED_OBJECT_CHARACTER)
- for i in range(count):
- index = toBuild.index(self.EMBEDDED_OBJECT_CHARACTER)
- child = obj[i + childOffset]
- childText = self.expandEOCs(child)
- if not childText:
- childText = ""
- try:
- toBuild[index] = childText.decode("UTF-8")
- except UnicodeEncodeError:
- toBuild[index] = childText
- string = "".join(toBuild)
+ if self.EMBEDDED_OBJECT_CHARACTER in string:
+ # If we're not getting the full text of this object, but
+ # rather a substring, we need to figure out the offset of
+ # the first child within this substring.
+ #
+ childOffset = 0
+ for child in obj:
+ if Utilities.characterOffsetInParent(child) >= startOffset:
+ break
+ childOffset += 1
+
+ toBuild = list(string)
+ count = toBuild.count(self.EMBEDDED_OBJECT_CHARACTER)
+ for i in range(count):
+ index = toBuild.index(self.EMBEDDED_OBJECT_CHARACTER)
+ child = obj[i + childOffset]
+ childText = self.expandEOCs(child)
+ if not childText:
+ childText = ""
+ toBuild[index] = childText
+
+ string = "".join(toBuild)
return string
@@ -2114,13 +2116,13 @@ class Utilities:
doesn't implement the accessible text specialization.
"""
+ # TODO: eliminate calls to this now-redundant method
+
text = self.queryNonEmptyText(obj)
if text:
- unicodeText = text.getText(0, -1).decode("UTF-8")
- else:
- unicodeText = None
+ return text.getText(0, -1)
- return unicodeText
+ return None
def willEchoCharacter(self, event):
"""Given a keyboard event containing an alphanumeric key,
@@ -2419,16 +2421,6 @@ class Utilities:
from . import punctuation_settings
from . import chnames
- try:
- line = line.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
- try:
- segment = segment.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
style = settings.verbalizePunctuationStyle
isPunctChar = True
try:
@@ -2450,12 +2442,6 @@ class Utilities:
"%(count)d %(repeatChar)s characters",
count) \
% {"count" : count, "repeatChar": repeatChar}
-
- try:
- repeatSegment = repeatSegment.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
line = "%s %s" % (line, repeatSegment)
else:
line += segment
@@ -2483,12 +2469,6 @@ class Utilities:
newSegment = pronunciation_dict.getPronunciation(
segment, self._script.app_pronunciation_dict)
-
- if isinstance(segment, unicode):
- segment = segment.encode('UTF-8')
- if isinstance(newSegment, unicode):
- newSegment = newSegment.encode('UTF-8')
-
if newSegment == segment:
newSegment = pronunciation_dict.getPronunciation(segment)
@@ -2508,13 +2488,7 @@ class Utilities:
from . import punctuation_settings
- try:
- line = line.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
endOffset = startOffset + len(line)
-
try:
hyperText = obj.queryHypertext()
nLinks = hyperText.getNLinks()
@@ -2539,7 +2513,7 @@ class Utilities:
# Translators: this indicates that this piece of
# text is a hypertext link.
#
- linkString = " " + _("link").decode("UTF-8")
+ linkString = " " + _("link")
# If the link was not followed by a whitespace or punctuation
# character, then add in a space to make it more presentable.
@@ -2552,7 +2526,7 @@ class Utilities:
linkString += " "
adjustedLine[index:index] = linkString
- return "".join(adjustedLine).encode("UTF-8")
+ return "".join(adjustedLine)
def adjustForPronunciation(self, line):
"""Adjust the line to replace words in the pronunciation dictionary,
@@ -2566,19 +2540,9 @@ class Utilities:
"""
newLine = ""
- try:
- line = line.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
words = self.WORDS_RE.split(line)
newLine = ''.join(map(self._pronunciationForSegment, words))
- try:
- newLine = newLine.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
return newLine
def adjustForRepeats(self, line):
@@ -2600,15 +2564,10 @@ class Utilities:
Returns: a new line adjusted for repeat character counts (if enabled).
"""
- try:
- line = line.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
if (len(line) < 4) or (settings.repeatCharacterLimit < 4):
- return line.encode("UTF-8")
+ return line
- newLine = u''
+ newLine = ''
segment = lastChar = line[0]
multipleChars = False
@@ -2622,24 +2581,7 @@ class Utilities:
lastChar = line[i]
- newLine = self._addRepeatSegment(segment, newLine, multipleChars)
-
- # Pylint is confused and flags this with the following error:
- #
- # E1103:5188:Script.adjustForRepeats: Instance of 'True' has
- # no 'encode' member (but some types could not be inferred)
- #
- # We know newLine is a unicode string, so we'll just tell pylint
- # that we know what we are doing.
- #
- # pylint: disable-msg=E1103
-
- try:
- newLine = newLine.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
- return newLine
+ return self._addRepeatSegment(segment, newLine, multipleChars)
def adjustForDigits(self, string):
"""Adjusts the string to convert digit-like text, such as subscript
@@ -2651,13 +2593,8 @@ class Utilities:
Returns: a new string which contains actual digits.
"""
- try:
- uString = string.decode("UTF-8")
- except UnicodeEncodeError:
- uString = string
-
- subscripted = set(re.findall(self.SUBSCRIPTS_RE, uString))
- superscripted = set(re.findall(self.SUPERSCRIPTS_RE, uString))
+ subscripted = set(re.findall(self.SUBSCRIPTS_RE, string))
+ superscripted = set(re.findall(self.SUPERSCRIPTS_RE, string))
for number in superscripted:
new = [str(self.SUPERSCRIPT_DIGITS.index(d)) for d in number]
@@ -2667,11 +2604,7 @@ class Utilities:
# 'superscript 3' should be presented as 'X superscript 23'.
#
newString = _(" superscript %s") % "".join(new)
- try:
- newString = newString.decode("UTF-8")
- except UnicodeEncodeError:
- pass
- uString = re.sub(number, newString, uString)
+ string = re.sub(number, newString, string)
for number in subscripted:
new = [str(self.SUBSCRIPT_DIGITS.index(d)) for d in number]
@@ -2681,17 +2614,9 @@ class Utilities:
# 'subscript 3', should be presented as 'X subscript 23.'
#
newString = _(" subscript %s") % "".join(new)
- uString = re.sub(number, newString, uString)
- try:
- newString = newString.decode("UTF-8")
- except UnicodeEncodeError:
- pass
- try:
- uString = uString.encode("UTF-8")
- except UnicodeDecodeError:
- pass
+ string = re.sub(number, newString, string)
- return uString
+ return string
@staticmethod
def absoluteMouseCoordinates():
@@ -2714,16 +2639,6 @@ class Utilities:
if not text:
return newText
- try:
- text = text.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
- try:
- newText = newText.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
return text + delimiter + newText
def isAutoTextEvent(self, event):
@@ -2763,12 +2678,6 @@ class Utilities:
Returns True if the given character is a sentence delimiter.
"""
- if not isinstance(currentChar, unicode):
- currentChar = currentChar.decode("UTF-8")
-
- if not isinstance(previousChar, unicode):
- previousChar = previousChar.decode("UTF-8")
-
if currentChar == '\r' or currentChar == '\n':
return True
@@ -2784,9 +2693,6 @@ class Utilities:
Returns True if the given character is a word delimiter.
"""
- if not isinstance(character, unicode):
- character = character.decode("UTF-8")
-
return character in self._script.whitespace \
or character in '!*+,-./:;<=>? [\]^_{|}' \
or character == self._script.NO_BREAK_SPACE_CHARACTER
@@ -2882,7 +2788,7 @@ class Utilities:
# The keybindings in <full-path> should be separated by ":"
#
try:
- bindingStrings = action.getKeyBinding(0).decode("UTF-8").split(';')
+ bindingStrings = action.getKeyBinding(0).split(';')
except:
self._script.generatorCache[self.KEY_BINDING][obj] = ["", "", ""]
return self._script.generatorCache[self.KEY_BINDING][obj]
@@ -3009,8 +2915,6 @@ class Utilities:
"""
try:
- if not isinstance(character, unicode):
- character = character.decode('UTF-8')
return "%04x" % ord(character)
except:
debug.printException(debug.LEVEL_WARNING)
diff --git a/src/orca/scripts/apps/acroread/script.py b/src/orca/scripts/apps/acroread/script.py
index b7c6e7e..d826824 100644
--- a/src/orca/scripts/apps/acroread/script.py
+++ b/src/orca/scripts/apps/acroread/script.py
@@ -659,7 +659,7 @@ class Script(default.Script):
if self.utilities.linkIndex(obj, offset) >= 0:
voice = self.voices[settings.HYPERLINK_VOICE]
- elif word.decode("UTF-8").isupper():
+ elif word.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
diff --git a/src/orca/scripts/apps/evolution/script.py b/src/orca/scripts/apps/evolution/script.py
index 3c5a411..5abcd3f 100644
--- a/src/orca/scripts/apps/evolution/script.py
+++ b/src/orca/scripts/apps/evolution/script.py
@@ -1222,7 +1222,7 @@ class Script(default.Script):
if mode == pyatspi.TEXT_BOUNDARY_LINE_START or \
len(mystr) == 0 or mystr[len(mystr)-1] in '.?!':
string = self.utilities.adjustForRepeats(string)
- if string.decode("UTF-8").isupper():
+ if string.isupper():
voice = voices[settings.UPPERCASE_VOICE]
else:
voice = voices[settings.DEFAULT_VOICE]
@@ -1251,7 +1251,7 @@ class Script(default.Script):
#
if len(string) != 0:
string = self.utilities.adjustForRepeats(string)
- if string.decode("UTF-8").isupper():
+ if string.isupper():
voice = voices[settings.UPPERCASE_VOICE]
else:
voice = voices[settings.DEFAULT_VOICE]
diff --git a/src/orca/scripts/apps/gedit/script.py b/src/orca/scripts/apps/gedit/script.py
index 2aaf592..68bc302 100644
--- a/src/orca/scripts/apps/gedit/script.py
+++ b/src/orca/scripts/apps/gedit/script.py
@@ -147,7 +147,7 @@ class Script(default.Script):
if mode == pyatspi.TEXT_BOUNDARY_LINE_START or \
len(mystr) == 0 or mystr[len(mystr)-1] in '.?!':
string = self.utilities.adjustForRepeats(string)
- if string.decode("UTF-8").isupper():
+ if string.isupper():
voice = settings.voices[settings.UPPERCASE_VOICE]
else:
voice = settings.voices[settings.DEFAULT_VOICE]
@@ -185,7 +185,7 @@ class Script(default.Script):
#
if len(string) != 0:
string = self.utilities.adjustForRepeats(string)
- if string.decode("UTF-8").isupper():
+ if string.isupper():
voice = settings.voices[settings.UPPERCASE_VOICE]
else:
voice = settings.voices[settings.DEFAULT_VOICE]
diff --git a/src/orca/scripts/apps/gnome-terminal/script.py b/src/orca/scripts/apps/gnome-terminal/script.py
index e03ac80..8c76542 100644
--- a/src/orca/scripts/apps/gnome-terminal/script.py
+++ b/src/orca/scripts/apps/gnome-terminal/script.py
@@ -118,12 +118,12 @@ class Script(default.Script):
# Speak the character that has just been deleted.
#
character = event.any_data
- if character.decode("UTF-8").isupper():
+ if character.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
- if len(character.decode('utf-8')) == 1:
+ if len(character) == 1:
speech.speakCharacter(character, voice)
else:
speech.speak(character, voice, False)
diff --git a/src/orca/scripts/apps/packagemanager/script.py b/src/orca/scripts/apps/packagemanager/script.py
index 56d0a3e..dd83bbb 100644
--- a/src/orca/scripts/apps/packagemanager/script.py
+++ b/src/orca/scripts/apps/packagemanager/script.py
@@ -457,7 +457,7 @@ class Script(default.Script):
isLink = self.utilities.isLink(child)
if len(line) and line != "\n":
- if line.decode("UTF-8").isupper():
+ if line.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
elif isLink:
voice = self.voices[settings.HYPERLINK_VOICE]
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index ed8ba35..e4012f6 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -1134,7 +1134,7 @@ class Script(default.Script):
if self.utilities.linkIndex(obj, i) >= 0:
voice = voices[settings.HYPERLINK_VOICE]
break
- elif word.decode("UTF-8").isupper():
+ elif word.isupper():
voice = voices[settings.UPPERCASE_VOICE]
else:
voice = voices[settings.DEFAULT_VOICE]
@@ -1274,12 +1274,12 @@ class Script(default.Script):
hypertext = None
if not hypertext or (hypertext.getNLinks() == 0):
- result = self.speechGenerator.generateTextIndentation( \
- event.source, line=textToSpeak.encode("UTF-8"))
+ result = self.speechGenerator.generateTextIndentation(
+ event.source, line=textToSpeak)
if result:
speech.speak(result[0])
- speech.speak(textToSpeak.encode("UTF-8"), None, False)
+ speech.speak(textToSpeak, None, False)
else:
started = False
startOffset = 0
@@ -1288,8 +1288,7 @@ class Script(default.Script):
if started:
endOffset = i
self.sayWriterWord(event.source,
- textToSpeak[startOffset:endOffset+1].encode( \
- "UTF-8"),
+ textToSpeak[startOffset:endOffset+1],
startOffset, endOffset)
startOffset = i
started = False
@@ -1301,8 +1300,7 @@ class Script(default.Script):
if started:
endOffset = len(textToSpeak)
self.sayWriterWord(event.source,
- textToSpeak[startOffset:endOffset].encode("UTF-8"),
- startOffset, endOffset)
+ textToSpeak[startOffset:endOffset], startOffset, endOffset)
def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
"""Called when the visual object with focus changes.
@@ -1353,7 +1351,7 @@ class Script(default.Script):
"StarOffice.locusOfFocusChanged - Writer: text paragraph.")
result = self.getTextLineAtCaret(event.source)
- textToSpeak = result[0].decode("UTF-8")
+ textToSpeak = result[0]
self._speakWriterText(event, textToSpeak)
self.displayBrailleForObject(event.source)
return
@@ -1643,7 +1641,8 @@ class Script(default.Script):
# If it is, we want to speak the misspelled word and context
# after we've spoken the window name.
#
- if event.source.getRole() == pyatspi.ROLE_DIALOG \
+ if event.source \
+ and event.source.getRole() == pyatspi.ROLE_DIALOG \
and event.source.childCount \
and event.source[0].getRole() == pyatspi.ROLE_OPTION_PANE:
self.readMisspeltWord(event, event.source)
@@ -2145,8 +2144,7 @@ class Script(default.Script):
focusRole = orca_state.locusOfFocus.getRole()
if focusRole != pyatspi.ROLE_UNKNOWN and keyString == "Return":
result = self.utilities.substring(event.source, 0, -1)
- line = result.decode("UTF-8")
- self.echoPreviousWord(event.source, len(line))
+ self.echoPreviousWord(event.source, len(result))
return
# Otherwise, if the object is losing focus, then just ignore this event.
@@ -2193,8 +2191,7 @@ class Script(default.Script):
return
result = self.utilities.substring(event.source, 0, -1)
- textToSpeak = result.decode("UTF-8")
- self._speakWriterText(event, textToSpeak)
+ self._speakWriterText(event, result)
self.displayBrailleForObject(event.source)
else:
# The lists and combo boxes in the Formatting toolbar emit
@@ -2256,7 +2253,7 @@ class Script(default.Script):
if isinstance(orca_state.lastInputEvent,
input_event.MouseButtonEvent) and \
orca_state.lastInputEvent.button == "2":
- if text.decode("UTF-8").isupper():
+ if text.isupper():
speech.speak(text, self.voices[settings.UPPERCASE_VOICE])
else:
speech.speak(text)
@@ -2290,10 +2287,9 @@ class Script(default.Script):
# Sometimes we get the trailing line-feed -- remove it
#
- content = lineString.decode("UTF-8")
- if content[-1:] == "\n":
- content = content[:-1]
+ if lineString[-1:] == "\n":
+ lineString = lineString[:-1]
- return [content.encode("UTF-8"), 0, startOffset]
+ return [lineString, 0, startOffset]
return default.Script.getTextLineAtCaret(self, obj, offset)
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py b/src/orca/scripts/apps/soffice/script_utilities.py
index 7c65f6e..5616776 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -356,7 +356,7 @@ class Utilities(script_utilities.Utilities):
- endOffset: the ending character position
"""
- text = obj.queryText().getText(0, -1).decode("UTF-8")
+ text = obj.queryText().getText(0, -1)
if startOffset >= len(text):
startOffset = len(text) - 1
if endOffset == -1:
@@ -364,7 +364,6 @@ class Utilities(script_utilities.Utilities):
elif startOffset >= endOffset:
endOffset = startOffset + 1
string = text[max(0, startOffset):min(len(text), endOffset)]
- string = string.encode("UTF-8")
return string
diff --git a/src/orca/scripts/apps/soffice/speech_generator.py b/src/orca/scripts/apps/soffice/speech_generator.py
index 6c67e73..cf662e9 100644
--- a/src/orca/scripts/apps/soffice/speech_generator.py
+++ b/src/orca/scripts/apps/soffice/speech_generator.py
@@ -193,7 +193,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
desc = obj.description.replace(text, "")
for item in obj.name.split():
desc = desc.replace(item, "")
- for char in desc.decode("UTF-8").strip():
+ for char in desc.strip():
if char.isalnum():
result.append(obj.description)
break
@@ -387,7 +387,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
try:
text = obj.queryText()
objectText = \
- self._script.utilities.substring(obj, 0, -1).decode("UTF-8")
+ self._script.utilities.substring(obj, 0, -1)
extents = obj.queryComponent().getExtents(pyatspi.DESKTOP_COORDS)
except NotImplementedError:
pass
@@ -443,7 +443,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
# digit.
#
for name in nameList:
- for char in name.decode("UTF-8"):
+ for char in name:
if char.isdigit():
result.append(name)
break
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 6249ada..a60009a 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -68,8 +68,8 @@ _settingsManager = settings_manager.getManager()
class Script(script.Script):
- EMBEDDED_OBJECT_CHARACTER = u'\ufffc'
- NO_BREAK_SPACE_CHARACTER = u'\u00a0'
+ EMBEDDED_OBJECT_CHARACTER = '\ufffc'
+ NO_BREAK_SPACE_CHARACTER = '\u00a0'
# generatorCache
#
@@ -1198,6 +1198,9 @@ class Script(script.Script):
self.inputEventHandlers["processBrailleCutBeginHandler"]
brailleBindings[braille.brlapi.KEY_CMD_CUTLINE] = \
self.inputEventHandlers["processBrailleCutLineHandler"]
+ except AttributeError:
+ debug.println(debug.LEVEL_CONFIGURATION,
+ "WARNING: braille bindings unavailable:")
except:
debug.println(debug.LEVEL_CONFIGURATION,
"WARNING: braille bindings unavailable:")
@@ -2099,12 +2102,12 @@ class Script(script.Script):
- itemString: the string to spell.
"""
- for (charIndex, character) in enumerate(itemString.decode("UTF-8")):
+ for (charIndex, character) in enumerate(itemString):
if character.isupper():
- speech.speak(character.encode("UTF-8"),
+ speech.speak(character,
self.voices[settings.UPPERCASE_VOICE])
else:
- speech.speak(character.encode("UTF-8"))
+ speech.speak(character)
def _reviewCurrentItem(self, inputEvent, targetCursorCell=0,
speechType=1):
@@ -2146,7 +2149,7 @@ class Script(script.Script):
# user has navigated to a line with only whitespace on it.
#
speech.speak(_("white space"))
- elif wordString.decode("UTF-8").isupper() and speechType == 1:
+ elif wordString.isupper() and speechType == 1:
speech.speak(wordString,
self.voices[settings.UPPERCASE_VOICE])
elif speechType == 2:
@@ -2274,7 +2277,7 @@ class Script(script.Script):
self.speakUnicodeCharacter(charString)
elif speechType == 2:
self.phoneticSpellCurrentItem(charString)
- elif charString.decode("UTF-8").isupper():
+ elif charString.isupper():
speech.speakCharacter(charString,
self.voices[settings.UPPERCASE_VOICE])
else:
@@ -2411,7 +2414,7 @@ class Script(script.Script):
# user has navigated to a line with only whitespace on it.
#
speech.speak(_("white space"))
- elif lineString.decode("UTF-8").isupper() \
+ elif lineString.isupper() \
and (speechType < 2 or speechType > 3):
speech.speak(lineString, self.voices[settings.UPPERCASE_VOICE])
elif speechType == 2:
@@ -3566,7 +3569,7 @@ class Script(script.Script):
if self.utilities.linkIndex(event.source, text.caretOffset) >= 0:
voice = self.voices[settings.HYPERLINK_VOICE]
- elif character.decode("UTF-8").isupper():
+ elif character.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -3575,7 +3578,7 @@ class Script(script.Script):
# right now because it is typically something else
# related to this event.
#
- if len(character.decode('utf-8')) == 1:
+ if len(character) == 1:
speech.speakCharacter(character, voice)
else:
speech.speak(character, voice, False)
@@ -3677,10 +3680,10 @@ class Script(script.Script):
or (_settingsManager.getSetting('enableEchoByCharacter') \
and string \
and role != pyatspi.ROLE_PASSWORD_TEXT \
- and len(string.decode("UTF-8")) == 1)
+ and len(string) == 1)
if speakThis:
- if string.decode("UTF-8").isupper():
+ if string.isupper():
speech.speak(string, self.voices[settings.UPPERCASE_VOICE])
else:
speech.speak(string)
@@ -4247,7 +4250,7 @@ class Script(script.Script):
if self.utilities.linkIndex(obj, sentenceStartOffset + 1) >= 0:
voice = self.voices[settings.HYPERLINK_VOICE]
- elif sentence.decode("UTF-8").isupper():
+ elif sentence.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -4324,7 +4327,7 @@ class Script(script.Script):
if self.utilities.linkIndex(obj, wordStartOffset + 1) >= 0:
voice = self.voices[settings.HYPERLINK_VOICE]
- elif word.decode("UTF-8").isupper():
+ elif word.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -4559,7 +4562,7 @@ class Script(script.Script):
if self.utilities.linkIndex(obj, offset) >= 0:
voice = self.voices[settings.HYPERLINK_VOICE]
- elif character.decode("UTF-8").isupper():
+ elif character.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -4618,7 +4621,7 @@ class Script(script.Script):
(caretOffset, _settingsManager.getSetting('speakBlankLines')))
if len(line) and line != "\n":
- if line.decode("UTF-8").isupper():
+ if line.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -4649,7 +4652,7 @@ class Script(script.Script):
phrase = self.utilities.substring(obj, startOffset, endOffset)
if len(phrase) and phrase != "\n":
- if phrase.decode("UTF-8").isupper():
+ if phrase.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -4699,7 +4702,7 @@ class Script(script.Script):
if self.utilities.linkIndex(obj, offset) >= 0:
voice = self.voices[settings.HYPERLINK_VOICE]
- elif word.decode("UTF-8").isupper():
+ elif word.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -4849,7 +4852,7 @@ class Script(script.Script):
context = self.getFlatReviewContext()
[regions, regionWithFocus] = context.getCurrentBrailleRegions()
for region in regions:
- if ((region.brailleOffset + len(region.string.decode("UTF-8"))) \
+ if ((region.brailleOffset + len(region.string)) \
> braille.viewport[0]) \
and (isinstance(region, braille.ReviewText) \
or isinstance(region, braille.ReviewComponent)):
@@ -4909,31 +4912,31 @@ class Script(script.Script):
if not self._unicodeCurrencySymbols:
self._unicodeCurrencySymbols = [ \
- u'\u0024', # dollar sign
- u'\u00A2', # cent sign
- u'\u00A3', # pound sign
- u'\u00A4', # currency sign
- u'\u00A5', # yen sign
- u'\u0192', # latin small letter f with hook
- u'\u060B', # afghani sign
- u'\u09F2', # bengali rupee mark
- u'\u09F3', # bengali rupee sign
- u'\u0AF1', # gujarati rupee sign
- u'\u0BF9', # tamil rupee sign
- u'\u0E3F', # thai currency symbol baht
- u'\u17DB', # khmer currency symbol riel
- u'\u2133', # script capital m
- u'\u5143', # cjk unified ideograph-5143
- u'\u5186', # cjk unified ideograph-5186
- u'\u5706', # cjk unified ideograph-5706
- u'\u5713', # cjk unified ideograph-5713
- u'\uFDFC', # rial sign
+ '\u0024', # dollar sign
+ '\u00A2', # cent sign
+ '\u00A3', # pound sign
+ '\u00A4', # currency sign
+ '\u00A5', # yen sign
+ '\u0192', # latin small letter f with hook
+ '\u060B', # afghani sign
+ '\u09F2', # bengali rupee mark
+ '\u09F3', # bengali rupee sign
+ '\u0AF1', # gujarati rupee sign
+ '\u0BF9', # tamil rupee sign
+ '\u0E3F', # thai currency symbol baht
+ '\u17DB', # khmer currency symbol riel
+ '\u2133', # script capital m
+ '\u5143', # cjk unified ideograph-5143
+ '\u5186', # cjk unified ideograph-5186
+ '\u5706', # cjk unified ideograph-5706
+ '\u5713', # cjk unified ideograph-5713
+ '\uFDFC', # rial sign
]
# Add 20A0 (EURO-CURRENCY SIGN) to 20B5 (CEDI SIGN)
#
- for ordChar in range(ord(u'\u20A0'), ord(u'\u20B5') + 1):
- self._unicodeCurrencySymbols.append(unichr(ordChar))
+ for ordChar in range(ord('\u20A0'), ord('\u20B5') + 1):
+ self._unicodeCurrencySymbols.append(chr(ordChar))
return self._unicodeCurrencySymbols
@@ -5052,7 +5055,7 @@ class Script(script.Script):
offset = endOffset
lineString = self.utilities.adjustForRepeats(lineString)
- if lineString.decode("UTF-8").isupper():
+ if lineString.isupper():
voice = settings.voices[settings.UPPERCASE_VOICE]
else:
voice = settings.voices[settings.DEFAULT_VOICE]
@@ -5129,8 +5132,7 @@ class Script(script.Script):
#
if text.caretOffset == text.characterCount:
caretOffset = max(0, text.caretOffset - 1)
- character = text.getText(caretOffset,
- caretOffset + 1).decode("UTF-8")
+ character = text.getText(caretOffset, caretOffset + 1)
else:
caretOffset = text.caretOffset
character = None
@@ -5158,19 +5160,16 @@ class Script(script.Script):
return ["", 0, 0]
# Sometimes we get the trailing line-feed-- remove it
- #
- content = lineString.decode("UTF-8")
-
# It is important that these are in order.
# In some circumstances we might get:
# word word\r\n
# so remove \n, and then remove \r.
# See bgo#619332.
#
- content = content.rstrip('\n')
- content = content.rstrip('\r')
+ lineString = lineString.rstrip('\n')
+ lineString = lineString.rstrip('\r')
- return [content.encode("UTF-8"), text.caretOffset, startOffset]
+ return [lineString, text.caretOffset, startOffset]
def phoneticSpellCurrentItem(self, itemString):
"""Phonetically spell the current flat review word or line.
@@ -5179,7 +5178,7 @@ class Script(script.Script):
- itemString: the string to phonetically spell.
"""
- for (charIndex, character) in enumerate(itemString.decode("UTF-8")):
+ for (charIndex, character) in enumerate(itemString):
if character.isupper():
voice = settings.voices[settings.UPPERCASE_VOICE]
character = character.lower()
@@ -5396,10 +5395,9 @@ class Script(script.Script):
# the startOffset and endOffset to exclude them.
#
try:
- tmpStr = text.getText(startOffset,
- endOffset).decode("UTF-8")
+ tmpStr = text.getText(startOffset, endOffset)
except:
- tmpStr = u''
+ tmpStr = ''
n = len(tmpStr)
# Don't strip whitespace if string length is one (might be a
@@ -5951,11 +5949,6 @@ class Script(script.Script):
def presentTime(self, inputEvent):
""" Presents the current time. """
timeFormat = _settingsManager.getSetting('presentTimeFormat')
- try:
- timeFormat = timeFormat.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
message = time.strftime(timeFormat, time.localtime())
self.presentMessage(message)
return True
@@ -5963,11 +5956,6 @@ class Script(script.Script):
def presentDate(self, inputEvent):
""" Presents the current date. """
dateFormat = _settingsManager.getSetting('presentDateFormat')
- try:
- dateFormat = dateFormat.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
message = time.strftime(dateFormat, time.localtime())
self.presentMessage(message)
return True
diff --git a/src/orca/scripts/toolkits/CALLY/script.py b/src/orca/scripts/toolkits/CALLY/script.py
index bc8da3b..376ade5 100644
--- a/src/orca/scripts/toolkits/CALLY/script.py
+++ b/src/orca/scripts/toolkits/CALLY/script.py
@@ -76,14 +76,11 @@ def _computeIsText(string):
"""
is_text = False
- if (string):
- char = unicode (string, "UTF-8")
- if (char > 0 and _unicharIsPrint (char)):
+ if string:
+ if _unicharIsPrint(string):
is_text = True
else:
is_text = False
- else:
- is_text = False
return is_text
diff --git a/src/orca/scripts/toolkits/Gecko/bookmarks.py b/src/orca/scripts/toolkits/Gecko/bookmarks.py
index 05fbbed..dc26a42 100644
--- a/src/orca/scripts/toolkits/Gecko/bookmarks.py
+++ b/src/orca/scripts/toolkits/Gecko/bookmarks.py
@@ -30,7 +30,7 @@ __copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
__license__ = "LGPL"
import pyatspi
-import urlparse
+import urllib.parse
import orca.speech as speech
import orca.bookmarks as bookmarks
@@ -287,7 +287,7 @@ class GeckoBookmarks(bookmarks.Bookmarks):
parameters?query#fragment as seen in urlparse."""
uri = self._script.utilities.documentFrameURI()
if uri:
- parsed_uri = urlparse.urlparse(uri)
+ parsed_uri = urllib.parse.urlparse(uri)
return ''.join(parsed_uri[0:3])
else:
return None
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index f931c0a..90b6c0f 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -45,7 +45,7 @@ from gi.repository import Gtk
import pyatspi
import re
import time
-import urlparse
+import urllib.parse
import orca.braille as braille
import orca.debug as debug
@@ -1098,7 +1098,7 @@ class Script(default.Script):
[obj, startOffset, endOffset, text] = \
contents[min(i, len(contents)-1)]
[element, voice] = clumped[i]
- if isinstance(element, basestring):
+ if isinstance(element, str):
element = self.utilities.adjustForRepeats(element)
if isinstance(element, (Pause, ACSS)):
# At the moment, SayAllContext is expecting a string; not
@@ -1293,7 +1293,7 @@ class Script(default.Script):
# scheme://netloc/path;parameters?query#fragment.
try:
uri = self.utilities.uri(orca_state.locusOfFocus)
- uriInfo = urlparse.urlparse(uri)
+ uriInfo = urllib.parse.urlparse(uri)
except:
pass
else:
@@ -3206,7 +3206,7 @@ class Script(default.Script):
"""
text = self.utilities.displayedText(obj)
- if text and text != u'\u00A0':
+ if text and text != '\u00A0':
return False
else:
for child in obj:
@@ -3302,7 +3302,7 @@ class Script(default.Script):
textObj = \
self.utilities.queryNonEmptyText(obj.parent)
if textObj:
- text = textObj.getText(0, -1).decode("UTF-8")
+ text = textObj.getText(0, -1)
text = text.replace(\
self.EMBEDDED_OBJECT_CHARACTER, "").strip()
if not text:
@@ -3374,10 +3374,6 @@ class Script(default.Script):
text = self.utilities.queryNonEmptyText(documentFrame)
if text:
char = text.getText(text.characterCount - 1, text.characterCount)
- try:
- char = char.decode("UTF-8")
- except UnicodeEncodeError:
- pass
if char != self.EMBEDDED_OBJECT_CHARACTER:
return [documentFrame, text.characterCount - 1]
@@ -3392,10 +3388,6 @@ class Script(default.Script):
if text:
char = text.getText(text.characterCount - 1,
text.characterCount)
- try:
- char = char.decode("UTF-8")
- except UnicodeEncodeError:
- pass
if char != self.EMBEDDED_OBJECT_CHARACTER:
return [obj.parent, text.characterCount - 1]
@@ -3553,7 +3545,7 @@ class Script(default.Script):
start = 0
end = 1
- unicodeText = string.decode("UTF-8")
+ unicodeText = string
objects.append([obj, start, end, unicodeText])
pattern = re.compile(self.EMBEDDED_OBJECT_CHARACTER)
@@ -3650,7 +3642,7 @@ class Script(default.Script):
else:
text = self.utilities.queryNonEmptyText(item[0])
if text:
- string = text.getText(item[1], item[2]).decode("UTF-8")
+ string = text.getText(item[1], item[2])
if not len(string.strip()):
continue
@@ -4246,8 +4238,7 @@ class Script(default.Script):
#
return [obj, characterOffset]
- character = text.getText(characterOffset,
- characterOffset + 1).decode("UTF-8")
+ character = text.getText(characterOffset, characterOffset + 1)
if character == self.EMBEDDED_OBJECT_CHARACTER:
if obj.childCount <= 0:
return self.findFirstCaretContext(obj, characterOffset + 1)
@@ -4797,7 +4788,7 @@ class Script(default.Script):
candidate, startOffset, endOffset, string = content
if self.utilities.isSameObject(candidate, obj) \
and (offset is None or (startOffset <= offset <= endOffset)):
- return string.encode("UTF-8"), caretOffset, startOffset
+ return string, caretOffset, startOffset
# If we're still here, obj presumably is not on this line. This
# shouldn't happen, but if it does we'll let the default script
@@ -4866,19 +4857,6 @@ class Script(default.Script):
[obj, caretOffset] = \
self._documentFrameCaretContext[hash(documentFrame)]
- # Yelp is seemingly fond of killing children for sport. Better
- # check for that.
- #
- try:
- state = obj.getState()
- except:
- return [None, -1]
- else:
- if state.contains(pyatspi.STATE_DEFUNCT):
- #print "getCaretContext: defunct object", obj
- debug.printStack(debug.LEVEL_WARNING)
- [obj, caretOffset] = [None, -1]
-
return [obj, caretOffset]
def getCharacterAtOffset(self, obj, characterOffset):
@@ -4889,7 +4867,7 @@ class Script(default.Script):
try:
unicodeText = self.utilities.unicodeText(obj)
- return unicodeText[characterOffset].encode("UTF-8")
+ return unicodeText[characterOffset]
except:
return None
@@ -5185,14 +5163,9 @@ class Script(default.Script):
def getACSS(self, obj, string):
"""Returns the ACSS to speak anything for the given obj."""
- try:
- string = string.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
if obj.getRole() == pyatspi.ROLE_LINK:
acss = self.voices[settings.HYPERLINK_VOICE]
- elif string and isinstance(string, basestring) \
+ elif string and isinstance(string, str) \
and string.isupper() \
and string.strip().isalpha():
acss = self.voices[settings.UPPERCASE_VOICE]
@@ -5298,7 +5271,7 @@ class Script(default.Script):
# kill them. (They don't deal well with what the speech
# generator provides.)
for item in rv:
- if isinstance(item, basestring):
+ if isinstance(item, str):
utterances.append([item, self.getACSS(obj, item)])
else:
utterances.append([string, self.getACSS(obj, string)])
@@ -5344,17 +5317,9 @@ class Script(default.Script):
if len(clumped) == 0:
clumped = [[element, acss]]
elif acss == clumped[-1][1] \
- and isinstance(element, basestring) \
- and isinstance(clumped[-1][0], basestring):
+ and isinstance(element, str) \
+ and isinstance(clumped[-1][0], str):
clumped[-1][0] = clumped[-1][0].rstrip(" ")
- try:
- clumped[-1][0] = clumped[-1][0].decode("UTF-8")
- except UnicodeEncodeError:
- pass
- try:
- element = element.decode("UTF-8")
- except UnicodeEncodeError:
- pass
clumped[-1][0] += " " + element
else:
clumped.append([element, acss])
@@ -5366,7 +5331,7 @@ class Script(default.Script):
#
return [[_("blank"), self.voices[settings.SYSTEM_VOICE]]]
- if len(clumped) and isinstance(clumped[-1][0], basestring):
+ if len(clumped) and isinstance(clumped[-1][0], str):
clumped[-1][0] = clumped[-1][0].rstrip(" ")
return clumped
@@ -5376,7 +5341,7 @@ class Script(default.Script):
utterances = self.getUtterancesFromContents(contents, speakRole)
clumped = self.clumpUtterances(utterances)
for [element, acss] in clumped:
- if isinstance(element, basestring):
+ if isinstance(element, str):
element = self.utilities.adjustForRepeats(element)
speech.speak(element, acss, False)
diff --git a/src/orca/scripts/toolkits/Gecko/speech_generator.py b/src/orca/scripts/toolkits/Gecko/speech_generator.py
index a4b19ac..2bc16db 100644
--- a/src/orca/scripts/toolkits/Gecko/speech_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/speech_generator.py
@@ -396,7 +396,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
#
parentText = self._script.utilities.queryNonEmptyText(parent)
if parentText:
- unicodeText = parentText.getText(0, -1).decode("UTF-8")
+ unicodeText = parentText.getText(0, -1)
if self._script.EMBEDDED_OBJECT_CHARACTER in unicodeText \
and (len(unicodeText) == 1 \
or role == pyatspi.ROLE_TABLE_CELL):
diff --git a/src/orca/scripts/toolkits/Gecko/structural_navigation.py b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
index 341b71c..3ea9741 100644
--- a/src/orca/scripts/toolkits/Gecko/structural_navigation.py
+++ b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
@@ -229,15 +229,13 @@ class GeckoStructuralNavigation(structural_navigation.StructuralNavigation):
return False
if text \
and text.characterCount > settings.largeObjectTextLength:
- string = text.getText(0, -1).decode("UTF-8")
+ string = text.getText(0, -1)
eocs = float(string.count(embeddedObjectChar))
if eocs/text.characterCount < 0.05:
- # print "Guess #1", string, eocs/text.characterCount
return True
else:
string = string[0:settings.largeObjectTextLength]
eocs = float(string.count(embeddedObjectChar))
- # print "Guess #2", string, eocs/len(string)
return eocs/len(string) < 0.005
########################
diff --git a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
index 8f4479a..794e438 100644
--- a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
+++ b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
@@ -110,7 +110,7 @@ class Script(default.Script):
and len(keyboardEvent.event_string) > 1:
keyval = Gdk.keyval_from_name(keyboardEvent.keyval_name)
if 0 < keyval < 256:
- keyboardEvent.event_string = unichr(keyval).encode("UTF-8")
+ keyboardEvent.event_string = chr(keyval)
def onFocus(self, event):
"""Called whenever an object gets focus.
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 05765c5..4142fa7 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -397,7 +397,7 @@ class Script(default.Script):
phrase = self.utilities.substring(obj, startOffset, endOffset)
if len(phrase) and phrase != "\n":
- if phrase.decode("UTF-8").isupper():
+ if phrase.isupper():
voice = self.voices[settings.UPPERCASE_VOICE]
else:
voice = self.voices[settings.DEFAULT_VOICE]
@@ -605,7 +605,7 @@ class Script(default.Script):
# TODO - JD: Piece together the full line for braille
textLine = default.Script.getTextLineAtCaret(self, obj, offset)
- string = textLine[0].decode('UTF-8')
+ string = textLine[0]
if string.find(self.EMBEDDED_OBJECT_CHARACTER) == -1:
return textLine
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py b/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
index 5dee35f..9a968f2 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
@@ -102,10 +102,6 @@ class Utilities(script_utilities.Utilities):
"""
text = script_utilities.Utilities.displayedText(self, obj)
- try:
- text = text.decode('UTF-8')
- except:
- pass
if text and text != self.EMBEDDED_OBJECT_CHARACTER:
return text
@@ -134,7 +130,7 @@ class Utilities(script_utilities.Utilities):
except (AttributeError, NotImplementedError):
return [(obj, 0, 1, '')]
- string = text.getText(0, -1).decode('UTF-8')
+ string = text.getText(0, -1)
if not string:
return [(obj, 0, 1, '')]
diff --git a/src/orca/scripts/toolkits/WebKitGtk/speech_generator.py b/src/orca/scripts/toolkits/WebKitGtk/speech_generator.py
index 9fa9a3a..4231ab7 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/speech_generator.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/speech_generator.py
@@ -51,7 +51,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
def getVoiceForString(self, obj, string, **args):
voice = settings.voices[settings.DEFAULT_VOICE]
- if string.decode("UTF-8").isupper():
+ if string.isupper():
voice = settings.voices[settings.UPPERCASE_VOICE]
return voice
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 011912d..c46f94c 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -410,8 +410,6 @@ class SettingsManager(object):
self.profileGeneral = {}
for key, value in list(general.items()):
- if isinstance(value, unicode):
- value = value.encode('UTF-8')
if key in settings.excludeKeys:
continue
elif key == 'profile':
diff --git a/src/orca/speech.py b/src/orca/speech.py
index 0700f90..e2ae7cf 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -176,11 +176,6 @@ def _speak(text, acss, interrupt):
extraDebug = " voice=%s" % key
break
- try:
- extraDebug = extraDebug.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
debug.println(debug.LEVEL_INFO, logLine + extraDebug)
log.info(logLine + extraDebug)
@@ -200,7 +195,7 @@ def speak(content, acss=None, interrupt=True):
if settings.silenceSpeech:
return
- validTypes = (basestring, list, sound.Sound, speech_generator.Pause,
+ validTypes = (str, list, sound.Sound, speech_generator.Pause,
speech_generator.LineBreak, ACSS)
error = "bad content sent to speech.speak: '%s'"
if not isinstance(content, validTypes):
@@ -214,7 +209,7 @@ def speak(content, acss=None, interrupt=True):
interrupt = interrupt \
and ((time.time() - orca_state.lastKeyEchoTime) > 0.5)
- if isinstance(content, basestring):
+ if isinstance(content, str):
_speak(content, acss, interrupt)
elif isinstance(content, sound.Sound):
content.play()
@@ -228,7 +223,7 @@ def speak(content, acss=None, interrupt=True):
debug.println(debug.LEVEL_WARNING, error % element)
elif isinstance(element, list):
speak(element, acss, interrupt)
- elif isinstance(element, basestring):
+ elif isinstance(element, str):
if len(element):
toSpeak.append(element)
elif toSpeak:
@@ -246,12 +241,6 @@ def speak(content, acss=None, interrupt=True):
newItemsToSpeak.append(toSpeak.pop())
if toSpeak:
- for i, item in enumerate(toSpeak):
- try:
- toSpeak[i] = item.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
string = " ".join(toSpeak)
_speak(string, activeVoice, interrupt)
activeVoice = newVoice
@@ -261,12 +250,6 @@ def speak(content, acss=None, interrupt=True):
element.play()
if toSpeak:
- for i, item in enumerate(toSpeak):
- try:
- toSpeak[i] = item.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
string = " ".join(toSpeak)
_speak(string, activeVoice, interrupt)
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 5b2a47c..e9da595 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -26,7 +26,7 @@ __copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
import pyatspi
-import urlparse, urllib2
+import urllib.parse, urllib.request, urllib.error, urllib.parse
from gi.repository import Atspi, Atk
from . import debug
@@ -111,7 +111,7 @@ class SpeechGenerator(generator.Generator):
try:
soundBite = sound.Sound(sounds[key])
except:
- if isinstance(key, basestring):
+ if isinstance(key, str):
soundBite = sound.Sound(key)
else:
soundBite = None
@@ -462,7 +462,7 @@ class SpeechGenerator(generator.Generator):
result.extend(self._generateRoleName(obj))
result.append(self._script.utilities.displayedText(obj))
else:
- link_uri_info = urlparse.urlparse(link_uri)
+ link_uri_info = urllib.parse.urlparse(link_uri)
if link_uri_info[0] in ["ftp", "ftps", "file"]:
fileName = link_uri_info[2].split('/')
# Translators: this refers to a link to a file, where
@@ -501,12 +501,12 @@ class SpeechGenerator(generator.Generator):
acss = self.voice(HYPERLINK)
link_uri = self._script.utilities.uri(obj)
if link_uri:
- link_uri_info = urlparse.urlparse(link_uri)
+ link_uri_info = urllib.parse.urlparse(link_uri)
else:
return result
doc_uri = self._script.utilities.documentFrameURI()
if doc_uri:
- doc_uri_info = urlparse.urlparse(doc_uri)
+ doc_uri_info = urllib.parse.urlparse(doc_uri)
if link_uri_info[1] == doc_uri_info[1]:
if link_uri_info[2] == doc_uri_info[2]:
# Translators: this is an indication that a given
@@ -555,12 +555,12 @@ class SpeechGenerator(generator.Generator):
if not uri:
return result
try:
- x = urllib2.urlopen(uri)
+ x = urllib.request.urlopen(uri)
try:
sizeString = x.info()['Content-length']
except KeyError:
pass
- except (ValueError, urllib2.URLError, OSError):
+ except (ValueError, urllib.error.URLError, OSError):
pass
if sizeString:
size = int(sizeString)
@@ -1063,8 +1063,7 @@ class SpeechGenerator(generator.Generator):
# characters). Until we do, this expansion is better than
# presenting the actual embedded object character.
#
- unicodeText = line.decode("UTF-8")
- if self._script.EMBEDDED_OBJECT_CHARACTER in unicodeText:
+ if self._script.EMBEDDED_OBJECT_CHARACTER in line:
line = self._script.utilities.expandEOCs(
obj, startOffset, endOffset)
line = self._script.utilities.adjustForRepeats(line)
@@ -1227,13 +1226,10 @@ class SpeechGenerator(generator.Generator):
if not line:
[line, caretOffset, startOffset] = \
self._script.getTextLineAtCaret(obj)
- # For the purpose of speaking the text indentation, replace
- # occurances of UTF-8 '\302\240' (non breaking space) with
- # spaces.
- #
- line = line.replace("\302\240", " ")
- line = line.decode("UTF-8")
+ # For the purpose of speaking the text indentation, replace
+ # occurances the non breaking space character with spaces.
+ line = line.replace("\u00a0", " ")
spaceCount = 0
tabCount = 0
utterance = ""
diff --git a/src/orca/speechdispatcherfactory.py b/src/orca/speechdispatcherfactory.py
index a7f0d9d..f8a77f8 100644
--- a/src/orca/speechdispatcherfactory.py
+++ b/src/orca/speechdispatcherfactory.py
@@ -177,11 +177,6 @@ class SpeechServer(speechserver.SpeechServer):
# the list will contain the names of all available "real"
# voices provided by the speech engine.
#
- try:
- serverId = serverId.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
self._default_voice_name = _("%s default voice") % serverId
try:
@@ -249,8 +244,6 @@ class SpeechServer(speechserver.SpeechServer):
pass
else:
name = acss_family.get(speechserver.VoiceFamily.NAME)
- if isinstance(name, unicode):
- name = name.encode('UTF-8')
if name != self._default_voice_name:
self._send_command(set_synthesis_voice, name)
@@ -293,11 +286,6 @@ class SpeechServer(speechserver.SpeechServer):
#
spokenEllipsis = _(" dot dot dot") + " "
newText = re.sub(ELLIPSIS, spokenEllipsis, oldText)
- try:
- newText = newText.decode("UTF-8")
- except UnicodeEncodeError:
- pass
-
symbols = set(re.findall(PUNCTUATION, newText))
for symbol in symbols:
try:
@@ -313,20 +301,11 @@ class SpeechServer(speechserver.SpeechServer):
charName = " %s " % chnames.getCharacterName(symbol)
if action == punctuation_settings.PUNCTUATION_INSERT:
charName += symbol
- try:
- charName = charName.decode("UTF-8")
- except UnicodeEncodeError:
- pass
newText = re.sub(symbol, charName, newText)
if orca_state.activeScript:
newText = orca_state.activeScript.utilities.adjustForDigits(newText)
- try:
- newText = newText.encode("UTF-8")
- except UnicodeDecodeError:
- pass
-
return newText
def _speak(self, text, acss, **kwargs):
@@ -336,7 +315,7 @@ class SpeechServer(speechserver.SpeechServer):
# Replace no break space characters with plain spaces since some
# synthesizers cannot handle them. See bug #591734.
#
- text = text.decode("UTF-8").replace(u'\u00a0', ' ').encode("UTF-8")
+ text = text.replace('\u00a0', ' ')
# Replace newline followed by full stop, since
# this seems to crash sd, see bgo#618334.
@@ -474,7 +453,7 @@ class SpeechServer(speechserver.SpeechServer):
# We currently only handle printable characters by Speech
# Dispatcher's KEY command. For other keys, such as Ctrl, Shift
# etc. we prefer Orca's verbalization.
- if event.event_string.decode("UTF-8").isupper():
+ if event.event_string.isupper():
acss = settings.voices[settings.UPPERCASE_VOICE]
else:
acss = None
diff --git a/src/orca/speechserver.py b/src/orca/speechserver.py
index 7ed0bda..d66527e 100644
--- a/src/orca/speechserver.py
+++ b/src/orca/speechserver.py
@@ -187,8 +187,7 @@ class SpeechServer(object):
Arguments:
- event: the input_event.KeyboardEvent.
"""
- if event.isPrintableKey() \
- and event.event_string.decode("UTF-8").isupper():
+ if event.isPrintableKey() and event.event_string.isupper():
voice = ACSS(settings.voices[settings.UPPERCASE_VOICE])
else:
voice = ACSS(settings.voices[settings.DEFAULT_VOICE])
diff --git a/src/orca/text_attribute_names.py b/src/orca/text_attribute_names.py
index 0ee9f5c..b7d0336 100644
--- a/src/orca/text_attribute_names.py
+++ b/src/orca/text_attribute_names.py
@@ -755,9 +755,6 @@ def getTextAttributeKey(localizedTextAttr):
localized text attribute.
"""
- if isinstance(localizedTextAttr, unicode):
- localizedTextAttr = localizedTextAttr.encode("UTF-8")
-
for key, value in list(_textAttributeTable.items()):
if value == localizedTextAttr:
return key
@@ -774,16 +771,9 @@ def getTextAttributeName(textAttr):
attribute.
"""
- if isinstance(textAttr, unicode):
- textAttr = textAttr.encode("UTF-8")
-
# Normalize the name to an Atk name before attempting to look it up.
#
if orca_state.activeScript:
textAttr = orca_state.activeScript.getAtkNameForAttribute(textAttr)
- try:
- return _textAttributeTable[textAttr]
- except:
- return textAttr
-
+ return _textAttributeTable.get(textAttr, textAttr)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]