[orca] More work on the Python 3 migration
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] More work on the Python 3 migration
- Date: Tue, 1 May 2012 03:42:01 +0000 (UTC)
commit 7bca3f7e1d9aa810c6d2226670ad1aa8de038a27
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Mon Apr 30 23:03:31 2012 -0400
More work on the Python 3 migration
src/orca/bookmarks.py | 6 +--
src/orca/find.py | 10 ++--
src/orca/flat_review.py | 36 ++++++------
src/orca/liveregions.py | 2 +-
src/orca/orca.py | 16 +++---
src/orca/orca_console_prefs.py | 8 ++--
src/orca/orca_gui_prefs.py | 3 +-
src/orca/script_utilities.py | 20 ++++----
src/orca/scripts/apps/metacity/script.py | 2 +-
.../scripts/apps/notification-daemon/script.py | 2 +-
src/orca/scripts/default.py | 4 +-
src/orca/scripts/toolkits/Gecko/script.py | 18 +++---
src/orca/settings_manager.py | 10 ++--
src/orca/sound.py | 2 +-
src/orca/speech.py | 6 +-
test/harness/settings_test.py | 56 ++++++++++----------
test/harness/utils.py | 45 ++++++++--------
17 files changed, 121 insertions(+), 125 deletions(-)
---
diff --git a/src/orca/bookmarks.py b/src/orca/bookmarks.py
index 477fcd7..8a1297f 100644
--- a/src/orca/bookmarks.py
+++ b/src/orca/bookmarks.py
@@ -159,8 +159,7 @@ class Bookmarks:
selected, the first bookmark will be used. """
# get the hardware keys that have registered bookmarks
- hwkeys = self._bookmarks.keys()
- hwkeys.sort()
+ hwkeys = sorted(self._bookmarks.keys())
# no bookmarks have been entered
if len(hwkeys) == 0:
@@ -181,8 +180,7 @@ class Bookmarks:
def goToPrevBookmark(self, inputEvent):
# get the hardware keys that have registered bookmarks
- hwkeys = self._bookmarks.keys()
- hwkeys.sort()
+ hwkeys = sorted(self._bookmarks.keys())
# no bookmarks have been entered
if len(hwkeys) == 0:
diff --git a/src/orca/find.py b/src/orca/find.py
index 5b726b9..bc34787 100644
--- a/src/orca/find.py
+++ b/src/orca/find.py
@@ -86,15 +86,15 @@ class SearchQuery:
def dumpContext(self, context):
"""Debug utility which prints out the context."""
- print "DUMP"
+ print("DUMP")
for i in range(0, len(context.lines)):
- print " Line %d" % i
+ print(" Line %d" % i)
for j in range(0, len(context.lines[i].zones)):
- print " Zone: %d" % j
+ print(" Zone: %d" % j)
for k in range(0, len(context.lines[i].zones[j].words)):
- print " Word %d = `%s` len(word): %d" % \
+ print(" Word %d = `%s` len(word): %d" % \
(k, context.lines[i].zones[j].words[k].string, \
- len(context.lines[i].zones[j].words[k].string))
+ len(context.lines[i].zones[j].words[k].string)))
def findQuery(self, context, justEnteredFlatReview):
"""Performs a search on the string specified in searchQuery.
diff --git a/src/orca/flat_review.py b/src/orca/flat_review.py
index ba620c5..ecd9bae 100644
--- a/src/orca/flat_review.py
+++ b/src/orca/flat_review.py
@@ -1433,54 +1433,54 @@ class Context:
return lines
def _dumpCurrentState(self):
- print "line=%d, zone=%d, word=%d, char=%d" \
+ print("line=%d, zone=%d, word=%d, char=%d" \
% (self.lineIndex,
self.zoneIndex,
self.wordIndex,
- self.zoneIndex)
+ self.zoneIndex))
zone = self.lines[self.lineIndex].zones[self.zoneIndex]
text = zone.accessible.queryText()
if not text:
- print " Not Accessibility_Text"
+ print(" Not Accessibility_Text")
return
- print " getTextBeforeOffset: %d" % text.caretOffset
+ print(" getTextBeforeOffset: %d" % text.caretOffset)
[string, startOffset, endOffset] = text.getTextBeforeOffset(
text.caretOffset,
pyatspi.TEXT_BOUNDARY_WORD_START)
- print " WORD_START: start=%d end=%d string='%s'" \
- % (startOffset, endOffset, string)
+ print(" WORD_START: start=%d end=%d string='%s'" \
+ % (startOffset, endOffset, string))
[string, startOffset, endOffset] = text.getTextBeforeOffset(
text.caretOffset,
pyatspi.TEXT_BOUNDARY_WORD_END)
- print " WORD_END: start=%d end=%d string='%s'" \
- % (startOffset, endOffset, string)
+ print(" WORD_END: start=%d end=%d string='%s'" \
+ % (startOffset, endOffset, string))
- print " getTextAtOffset: %d" % text.caretOffset
+ print(" getTextAtOffset: %d" % text.caretOffset)
[string, startOffset, endOffset] = text.getTextAtOffset(
text.caretOffset,
pyatspi.TEXT_BOUNDARY_WORD_START)
- print " WORD_START: start=%d end=%d string='%s'" \
- % (startOffset, endOffset, string)
+ print(" WORD_START: start=%d end=%d string='%s'" \
+ % (startOffset, endOffset, string))
[string, startOffset, endOffset] = text.getTextAtOffset(
text.caretOffset,
pyatspi.TEXT_BOUNDARY_WORD_END)
- print " WORD_END: start=%d end=%d string='%s'" \
- % (startOffset, endOffset, string)
+ print(" WORD_END: start=%d end=%d string='%s'" \
+ % (startOffset, endOffset, string))
- print " getTextAfterOffset: %d" % text.caretOffset
+ print(" getTextAfterOffset: %d" % text.caretOffset)
[string, startOffset, endOffset] = text.getTextAfterOffset(
text.caretOffset,
pyatspi.TEXT_BOUNDARY_WORD_START)
- print " WORD_START: start=%d end=%d string='%s'" \
- % (startOffset, endOffset, string)
+ print(" WORD_START: start=%d end=%d string='%s'" \
+ % (startOffset, endOffset, string))
[string, startOffset, endOffset] = text.getTextAfterOffset(
text.caretOffset,
pyatspi.TEXT_BOUNDARY_WORD_END)
- print " WORD_END: start=%d end=%d string='%s'" \
- % (startOffset, endOffset, string)
+ print(" WORD_END: start=%d end=%d string='%s'" \
+ % (startOffset, endOffset, string))
def setCurrent(self, lineIndex, zoneIndex, wordIndex, charIndex):
"""Sets the current character of interest.
diff --git a/src/orca/liveregions.py b/src/orca/liveregions.py
index fe5e18d..234266d 100644
--- a/src/orca/liveregions.py
+++ b/src/orca/liveregions.py
@@ -588,7 +588,7 @@ class LiveRegionManager:
to the document frame."""
docframe = self._script.utilities.documentFrame()
path = []
- while 1:
+ while True:
if obj.parent is None or obj == docframe:
path.reverse()
return tuple(path)
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 5e3d61a..1508a17 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -186,10 +186,10 @@ class Options(argparse.Namespace):
os.waitpid(pid, 0)
os._exit(0)
else:
- if type(msg) == MethodType:
+ if isinstance(msg, MethodType):
msg()
else:
- print msg
+ print(msg)
os._exit(0)
def convertToSettings(self):
@@ -243,7 +243,7 @@ def presentInvalidOptions(invalidOptions):
# the list of arguments, as typed by the user, is displayed.
#
msg = _("The following arguments are not valid: ")
- print(msg + " ".join(invalidOptions))
+ print((msg + " ".join(invalidOptions)))
return True
return False
@@ -394,7 +394,7 @@ options.validate()
from settings_manager import SettingsManager
_settingsManager = SettingsManager(prefsDir=options.userPrefsDir)
if _settingsManager is None:
- print "Could not load the settings manager. Exiting."
+ print("Could not load the settings manager. Exiting.")
sys.exit(1)
from event_manager import EventManager
@@ -1465,7 +1465,7 @@ def main():
except:
continue
- print msg
+ print(msg)
if multipleOrcas():
die(0)
@@ -1476,9 +1476,9 @@ def main():
_showPreferencesConsole()
if not options.desktopRunning:
- print "Cannot start Orca because it cannot connect"
- print "to the Desktop. Please make sure the DISPLAY"
- print "environment variable has been set."
+ print("Cannot start Orca because it cannot connect")
+ print("to the Desktop. Please make sure the DISPLAY")
+ print("environment variable has been set.")
return 1
sys.path.insert(0, _settingsManager.getPrefsDir())
diff --git a/src/orca/orca_console_prefs.py b/src/orca/orca_console_prefs.py
index b813967..d18059c 100644
--- a/src/orca/orca_console_prefs.py
+++ b/src/orca/orca_console_prefs.py
@@ -115,7 +115,7 @@ def sayAndPrint(text,
if getInput:
return raw_input(text)
else:
- print text
+ print(text)
def setupSpeech(prefsDict):
"""Sets up speech support. If speech setup is successful and the
@@ -138,7 +138,7 @@ def setupSpeech(prefsDict):
# Translators: this means speech synthesis (i.e., the machine
# speaks to you from its speakers) is not installed or working.
#
- print _("Speech is unavailable.")
+ print(_("Speech is unavailable."))
return False
try:
@@ -147,7 +147,7 @@ def setupSpeech(prefsDict):
# Translators: this means speech synthesis (i.e., the machine
# speaks to you from its speakers) is not installed or working.
#
- print _("Speech is unavailable.")
+ print(_("Speech is unavailable."))
return False
sayAndPrint(_("Welcome to Orca setup."))
@@ -165,7 +165,7 @@ def setupSpeech(prefsDict):
# Translators: this means speech synthesis (i.e., the machine
# speaks to you from its speakers) is not installed or working.
#
- print _("Speech is unavailable.")
+ print(_("Speech is unavailable."))
return False
elif len(workingFactories) > 1:
# Translators: the speech system represents what general
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 6b8d256..c6bdc52 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -1576,8 +1576,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
braille.getDefaultTable()
if tableDict:
tablesModel = Gtk.ListStore(str, str)
- names = tableDict.keys()
- names.sort()
+ names = sorted(tableDict.keys())
for name in names:
fname = tableDict[name]
it = tablesModel.append([name, fname])
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index ebf413f..21e57ed 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2264,7 +2264,7 @@ class Utilities:
try:
if visitedObjs.index(referent):
if self._isInterestingObj(referent):
- print indent, "CYCLE!!!!", repr(referent)
+ print(indent, "CYCLE!!!!", repr(referent))
break
except:
pass
@@ -2288,7 +2288,7 @@ class Utilities:
line = indent + "+- " + \
debug.getAccessibleDetails(debug.LEVEL_OFF, ancestor)
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
indent += " "
def printApps(self):
@@ -2297,17 +2297,17 @@ class Utilities:
apps = self.knownApplications()
line = "There are %d Accessible applications" % len(apps)
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
for app in apps:
line = debug.getAccessibleDetails(
debug.LEVEL_OFF, app, " App: ", False)
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
for child in app:
line = debug.getAccessibleDetails(
debug.LEVEL_OFF, child, " Window: ", False)
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
if child.parent != app:
debug.println(debug.LEVEL_OFF,
" WARNING: child's parent is not app!!!")
@@ -2337,7 +2337,7 @@ class Utilities:
debug.LEVEL_OFF, root)
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
rootManagesDescendants = root.getState().contains(
pyatspi.STATE_MANAGES_DESCENDANTS)
@@ -2346,15 +2346,15 @@ class Utilities:
if child == root:
line = indent + " " + "WARNING CHILD == PARENT!!!"
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
elif not child:
line = indent + " " + "WARNING Child IS NONE!!!"
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
elif self.validParent(child) != root:
line = indent + " " + "WARNING CHILD.PARENT != PARENT!!!"
debug.println(debug.LEVEL_OFF, line)
- print line
+ print(line)
else:
paint = (not onlyShowing) or (onlyShowing and \
child.getState().contains(pyatspi.STATE_SHOWING))
@@ -2393,7 +2393,7 @@ class Utilities:
infoString += " Version unknown"
debug.println(debug.LEVEL_OFF, infoString)
- print infoString
+ print(infoString)
self._script.speakMessage(infoString)
self._script.displayBrailleMessage(infoString)
diff --git a/src/orca/scripts/apps/metacity/script.py b/src/orca/scripts/apps/metacity/script.py
index 2253e49..6e3fcb2 100644
--- a/src/orca/scripts/apps/metacity/script.py
+++ b/src/orca/scripts/apps/metacity/script.py
@@ -94,7 +94,7 @@ class Script(default.Script):
except:
win = None
if win is None:
- print "app error " + app.name
+ print("app error " + app.name)
elif win.name == objName:
found = True
i = i + 1
diff --git a/src/orca/scripts/apps/notification-daemon/script.py b/src/orca/scripts/apps/notification-daemon/script.py
index 5c14c22..c442077 100644
--- a/src/orca/scripts/apps/notification-daemon/script.py
+++ b/src/orca/scripts/apps/notification-daemon/script.py
@@ -56,7 +56,7 @@ class Script(default.Script):
- event: the Event.
"""
a = self.utilities.descendantsWithRole(event.source, pyatspi.ROLE_LABEL)
- print a
+ print(a)
texts = [self.utilities.displayedText(acc) for acc in a]
# Translators: This denotes a notification to the user of some sort.
#
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 8997fea..f1688ae 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3018,7 +3018,7 @@ class Script(script.Script):
def printMemoryUsageHandler(self, inputEvent):
"""Prints memory usage information."""
- print 'TODO: print something useful for memory debugging'
+ print('TODO: print something useful for memory debugging')
def printAppsHandler(self, inputEvent=None):
"""Prints a list of all applications to stdout."""
@@ -5462,7 +5462,7 @@ class Script(script.Script):
purpose of representing an error, event etc)
"""
- print "\a"
+ print("\a")
def speakWordUnderMouse(self, acc):
"""Determine if the speak-word-under-mouse capability applies to
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 2d08bb2..e4ed727 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -2344,7 +2344,7 @@ class Script(default.Script):
string = text.getText(0, -1)
if characterOffset >= len(string) \
and not obj.getState().contains(pyatspi.STATE_EDITABLE):
- print "YIKES in Gecko.sayCharacter!"
+ print("YIKES in Gecko.sayCharacter!")
characterOffset -= 1
if characterOffset >= 0:
@@ -2374,7 +2374,7 @@ class Script(default.Script):
string = text.getText(0, -1)
if characterOffset >= len(string) \
and not obj.getState().contains(pyatspi.STATE_EDITABLE):
- print "YIKES in Gecko.sayWord!"
+ print("YIKES in Gecko.sayWord!")
characterOffset -= 1
# Ideally in an entry we would just let default.sayWord() handle
@@ -2415,7 +2415,7 @@ class Script(default.Script):
string = text.getText(0, -1)
if characterOffset >= len(string) \
and not obj.getState().contains(pyatspi.STATE_EDITABLE):
- print "YIKES in Gecko.sayLine!"
+ print("YIKES in Gecko.sayLine!")
characterOffset -= 1
self.speakContents(self.getLineContentsAtOffset(obj, characterOffset))
@@ -2475,17 +2475,17 @@ class Script(default.Script):
if obj.parent:
self.dumpInfo(obj.parent)
- print "---"
+ print("---")
text = self.utilities.queryNonEmptyText(obj)
if text and obj.getRole() != pyatspi.ROLE_DOCUMENT_FRAME:
string = text.getText(0, -1)
else:
string = ""
- print obj, obj.name, obj.getRole(), \
- obj.accessible.getIndexInParent(), string
+ print(obj, obj.name, obj.getRole(), \
+ obj.accessible.getIndexInParent(), string)
offset = self.utilities.characterOffsetInParent(obj)
if offset >= 0:
- print " offset =", offset
+ print(" offset =", offset)
def getDocumentContents(self):
"""Returns an ordered list where each element is composed of
@@ -2611,8 +2611,8 @@ class Script(default.Script):
string += "[%s] name='%s' " % (obj.getRole(), obj.name)
else:
string += "\nNEWLINE\n"
- print "==========================="
- print string
+ print("===========================")
+ print(string)
self.drawOutline(extents[0], extents[1], extents[2], extents[3])
####################################################################
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 2455198..e062686 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -165,7 +165,7 @@ class SettingsManager(object):
_createDir(orcaScriptDir)
initFile = os.path.join(orcaScriptDir, "__init__.py")
if not os.path.exists(initFile):
- os.close(os.open(initFile, os.O_CREAT, 0700))
+ os.close(os.open(initFile, os.O_CREAT, 0o700))
# Set up $XDG_DATA_HOME/orca/app-settings as a Python package.
#
@@ -173,17 +173,17 @@ class SettingsManager(object):
_createDir(orcaSettingsDir)
initFile = os.path.join(orcaSettingsDir, "__init__.py")
if not os.path.exists(initFile):
- os.close(os.open(initFile, os.O_CREAT, 0700))
+ os.close(os.open(initFile, os.O_CREAT, 0o700))
# Set up $XDG_DATA_HOME/orca/orca-customizations.py empty file and
# define orcaDir as a Python package.
initFile = os.path.join(orcaDir, "__init__.py")
if not os.path.exists(initFile):
- os.close(os.open(initFile, os.O_CREAT, 0700))
+ os.close(os.open(initFile, os.O_CREAT, 0o700))
userCustomFile = os.path.join(orcaDir, "orca-customizations.py")
if not os.path.exists(userCustomFile):
- os.close(os.open(userCustomFile, os.O_CREAT, 0700))
+ os.close(os.open(userCustomFile, os.O_CREAT, 0o700))
if self.isFirstStart():
self._backend.saveDefaultSettings(self.defaultGeneral,
@@ -583,7 +583,7 @@ def getValueForKey(prefsDict, key):
value = None
if key in prefsDict:
- if type(prefsDict[key]) is str:
+ if isinstance(prefsDict[key], str):
if key in need2repr:
value = "\'%s\'" % prefsDict[key]
elif key == 'voices':
diff --git a/src/orca/sound.py b/src/orca/sound.py
index a14c286..f585504 100644
--- a/src/orca/sound.py
+++ b/src/orca/sound.py
@@ -59,7 +59,7 @@ class Sound:
source = gst.element_factory_make("filesrc", "file-source")
decoder = gst.element_factory_make("wavparse", "wav-decoder")
sink = gst.element_factory_make("autoaudiosink", "audio-sink")
- print source, decoder, sink
+ print(source, decoder, sink)
player.add(source, decoder, sink)
gst.element_link_many(source, decoder, sink)
player.get_by_name("file-source").set_property(
diff --git a/src/orca/speech.py b/src/orca/speech.py
index 5d35eee..ec622fa 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -408,14 +408,14 @@ def test():
import speechserver
factories = getSpeechServerFactories()
for factory in factories:
- print factory.__name__
+ print(factory.__name__)
servers = factory.SpeechServer.getSpeechServers()
for server in servers:
try:
- print " ", server.getInfo()
+ print(" ", server.getInfo())
for family in server.getVoiceFamilies():
name = family[speechserver.VoiceFamily.NAME]
- print " ", name
+ print(" ", name)
acss = ACSS({ACSS.FAMILY : family})
server.speak(name, acss)
server.speak("testing")
diff --git a/test/harness/settings_test.py b/test/harness/settings_test.py
index 0cf3833..437f8c1 100644
--- a/test/harness/settings_test.py
+++ b/test/harness/settings_test.py
@@ -5,75 +5,75 @@ from pprint import pprint
def exerciseBackendAPI(backendName, profile):
settingsManager = settings_manager.SettingsManager(backendName)
- print "\n\n================ Testing Backend %s ====================\n\n" % \
- backendName
- print 'Profile: ', profile
- print 'Profiles list: ', settingsManager.availableProfiles()
+ print("\n\n================ Testing Backend %s ====================\n\n" % \
+ backendName)
+ print('Profile: ', profile)
+ print('Profiles list: ', settingsManager.availableProfiles())
#settingsManager.setProfile(profile)
# Getters
preferences = settingsManager.getPreferences(profile)
- print 'preferences: \n', preferences, '\n\n'
+ print('preferences: \n', preferences, '\n\n')
generalSettings = settingsManager.getGeneralSettings(profile)
- print 'generalSettings: \n', generalSettings, '\n\n'
+ print('generalSettings: \n', generalSettings, '\n\n')
pronunciations = settingsManager.getPronunciations(profile)
- print 'pronunciations: \n', pronunciations, '\n\n'
+ print('pronunciations: \n', pronunciations, '\n\n')
keybindings = settingsManager.getKeybindings(profile)
- print 'keybindings: \n', keybindings, '\n\n'
+ print('keybindings: \n', keybindings, '\n\n')
# Adding new settings to the profile and merging them
newGeneralSettings = getSettingsFromFile('general')
- print "newGeneralSettings = "
+ print("newGeneralSettings = ")
pprint(newGeneralSettings)
settingsManager._setProfileGeneral(newGeneralSettings)
generalSettings = settingsManager.getGeneralSettings(profile)
- print "generalSettings = "
+ print("generalSettings = ")
pprint(generalSettings)
newKeybindingsSettings = getSettingsFromFile('keybindings')
- print "\n\nnewKeybindingsSettings = "
+ print("\n\nnewKeybindingsSettings = ")
pprint(newKeybindingsSettings)
settingsManager._setProfileKeybindings(newKeybindingsSettings)
keybindings = settingsManager.getKeybindings(profile)
- print "keybindings = "
+ print("keybindings = ")
pprint(keybindings)
newPronunciationsSettings = getSettingsFromFile('pronunciations')
- print "\n\nnewPronunciationsSettings = "
+ print("\n\nnewPronunciationsSettings = ")
pprint(newPronunciationsSettings)
settingsManager._setProfileGeneral(newPronunciationsSettings)
pronunciations = settingsManager.getPronunciations(profile)
- print "pronunciations = "
+ print("pronunciations = ")
pprint(pronunciations)
#settingsManager.saveSettings()
isFirstStart = settingsManager.isFirstStart()
- print "\n\nIs First Start? => ", isFirstStart
- print "\n\nSetting firstStart key"
+ print("\n\nIs First Start? => ", isFirstStart)
+ print("\n\nSetting firstStart key")
settingsManager.setFirstStart()
isFirstStart = settingsManager.isFirstStart()
- print "\n\nIs First Start? => ", isFirstStart
- print "\n\n===========================================================\n\n"
+ print("\n\nIs First Start? => ", isFirstStart)
+ print("\n\n===========================================================\n\n")
- print "\n\nTesting import from a file I"
- print "\n==========================================================="
+ print("\n\nTesting import from a file I")
+ print("\n===========================================================")
availableProfilesBefore = settingsManager.availableProfiles()
- print "\nAvailable Profiles BEFORE the import => ", availableProfilesBefore
+ print("\nAvailable Profiles BEFORE the import => ", availableProfilesBefore)
settingsManager.importProfile('importFile.conf')
availableProfilesAfter = settingsManager.availableProfiles()
- print "\nAvailable Profiles AFTER the import => ", availableProfilesAfter
+ print("\nAvailable Profiles AFTER the import => ", availableProfilesAfter)
- print "\n\nTesting import from a file II"
- print "\n==========================================================="
+ print("\n\nTesting import from a file II")
+ print("\n===========================================================")
availableProfilesBefore = settingsManager.availableProfiles()
- print "\nAvailable Profiles BEFORE the import => ", availableProfilesBefore
+ print("\nAvailable Profiles BEFORE the import => ", availableProfilesBefore)
settingsManager.importProfile('importFile2.conf')
availableProfilesAfter = settingsManager.availableProfiles()
- print "\nAvailable Profiles AFTER the import => ", availableProfilesAfter
+ print("\nAvailable Profiles AFTER the import => ", availableProfilesAfter)
def getSettingsFromFile(dictName):
@@ -82,7 +82,7 @@ def getSettingsFromFile(dictName):
dictFile = open(fileName)
except:
import sys
- print "You should run the test from the test directory"
+ print("You should run the test from the test directory")
sys.exit()
settings = load(dictFile)
dictFile.close()
@@ -90,7 +90,7 @@ def getSettingsFromFile(dictName):
# main
profile = 'default'
-print 'profile: default backendName: json\n'
+print('profile: default backendName: json\n')
exerciseBackendAPI('json', 'default')
#print 'profile: default backendName: gconf\n'
#exerciseBackendAPI('gconf', 'default')
diff --git a/test/harness/utils.py b/test/harness/utils.py
index 131d08b..0c85372 100644
--- a/test/harness/utils.py
+++ b/test/harness/utils.py
@@ -175,7 +175,7 @@ class AssertPresentationAction(AtomicAction):
"""
knownIssue = False
- print >> myErr, "DIFFERENCES FOUND:"
+ print("DIFFERENCES FOUND:", file=myErr)
if isinstance(self._expectedResults, [].__class__):
for result in self._expectedResults:
if result.startswith("KNOWN ISSUE") \
@@ -192,18 +192,18 @@ class AssertPresentationAction(AtomicAction):
# so we need to capture it. Otherwise, it can hang the tests.
#
diffs = list(d.compare(self._expectedResults, results))
- print >> myErr, '\n'.join(list(diffs))
+ print('\n'.join(list(diffs)), file=myErr)
except:
- print >> myErr, "(ERROR COMPUTING DIFFERENCES!!!)"
+ print("(ERROR COMPUTING DIFFERENCES!!!)", file=myErr)
for i in range(0, max(len(results), len(self._expectedResults))):
try:
- print >> myErr, " EXPECTED: %s" \
- % self._expectedResults[i].decode("UTF-8", "replace")
+ print(" EXPECTED: %s" \
+ % self._expectedResults[i].decode("UTF-8", "replace"), file=myErr)
except:
pass
try:
- print >> myErr, " ACTUAL: %s" \
- % results[i].decode("UTF-8", "replace")
+ print(" ACTUAL: %s" \
+ % results[i].decode("UTF-8", "replace"), file=myErr)
except:
pass
@@ -219,24 +219,24 @@ class AssertPresentationAction(AtomicAction):
"""
knownIssue = False
- print >> myErr, "EXPECTED:"
+ print("EXPECTED:", file=myErr)
if isinstance(self._expectedResults, [].__class__):
for result in self._expectedResults:
if result.startswith("KNOWN ISSUE") \
or result.startswith("BUG?"):
knownIssue = True
- print >> myErr, ' "%s",' % result
+ print(' "%s",' % result, file=myErr)
else:
if self._expectedResults.startswith("KNOWN ISSUE") \
or self._expectedResults.startswith("BUG?"):
knownIssue = True
- print >> myErr, ' "%s"' % self._expectedResults
- print >> myErr, "ACTUAL:"
+ print(' "%s"' % self._expectedResults, file=myErr)
+ print("ACTUAL:", file=myErr)
if isinstance(results, [].__class__):
for result in results:
- print >> myErr, ' "%s",' % result
+ print(' "%s",' % result, file=myErr)
else:
- print >> myErr, ' "%s"' % results
+ print(' "%s"' % results, file=myErr)
return knownIssue
def _stopRecording(self):
@@ -244,16 +244,16 @@ class AssertPresentationAction(AtomicAction):
results = self._assertionPredicate(result, self._expectedResults)
if not results:
AssertPresentationAction.totalSucceed += 1
- print >> myOut, "Test %d of %d SUCCEEDED: %s" \
+ print("Test %d of %d SUCCEEDED: %s" \
% (self._num,
AssertPresentationAction.totalCount,
- self._name)
+ self._name), file=myOut)
else:
AssertPresentationAction.totalFail += 1
- print >> myErr, "Test %d of %d FAILED: %s" \
+ print("Test %d of %d FAILED: %s" \
% (self._num,
AssertPresentationAction.totalCount,
- self._name)
+ self._name), file=myErr)
if createDiffs:
knownIssue = self.printDiffs(results)
else:
@@ -261,11 +261,11 @@ class AssertPresentationAction(AtomicAction):
if knownIssue:
AssertPresentationAction.totalKnownIssues += 1
- print >> myErr, '[FAILURE WAS EXPECTED - ' \
+ print('[FAILURE WAS EXPECTED - ' \
'LOOK FOR KNOWN ISSUE OR BUG? ' \
- 'IN EXPECTED RESULTS]'
+ 'IN EXPECTED RESULTS]', file=myErr)
else:
- print >> myErr, '[FAILURE WAS UNEXPECTED]'
+ print('[FAILURE WAS UNEXPECTED]', file=myErr)
def __str__(self):
return 'Assert Presentation Action: %s' % self._name
@@ -278,14 +278,13 @@ class AssertionSummaryAction(AtomicAction):
AtomicAction.__init__(self, 0, self._printSummary)
def _printSummary(self):
- print >> myOut, \
- "SUMMARY: %d SUCCEEDED and %d FAILED (%d UNEXPECTED) of %d for %s"\
+ print("SUMMARY: %d SUCCEEDED and %d FAILED (%d UNEXPECTED) of %d for %s"\
% (AssertPresentationAction.totalSucceed,
AssertPresentationAction.totalFail,
(AssertPresentationAction.totalFail \
- AssertPresentationAction.totalKnownIssues),
AssertPresentationAction.totalCount,
- sys.argv[0])
+ sys.argv[0]), file=myOut)
def __str__(self):
return 'Start Recording Action'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]