[pyatspi2] Remove exception wrapping
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pyatspi2] Remove exception wrapping
- Date: Thu, 2 Feb 2012 01:21:32 +0000 (UTC)
commit c1c05ab0be628258453890bf32f0f1447c414bd0
Author: Mike Gorse <mgorse novell com>
Date: Wed Feb 1 19:19:08 2012 -0600
Remove exception wrapping
When libatspi throws an exception, return the exception as translated by
pygobject. Previously we were raising LookupError since that was
generally the error raised by AT-SPI 1 in similar cases, but this was
kludgy and raised the same exception regardless of the original error,
so an AT could not distinguish between various types of exceptions.
This means that consumers of pyatspi now need to test for pygobject
exceptions (gi._glib.GError, which is a sub-class of RuntimeError).
pyatspi/Accessibility.py | 189 +++++++++++++++++++++------------------------
pyatspi/document.py | 6 +-
pyatspi/editabletext.py | 12 ++--
pyatspi/text.py | 44 ++++++------
pyatspi/utils.py | 9 +--
5 files changed, 120 insertions(+), 140 deletions(-)
---
diff --git a/pyatspi/Accessibility.py b/pyatspi/Accessibility.py
index ec67cbc..e2c5fa0 100644
--- a/pyatspi/Accessibility.py
+++ b/pyatspi/Accessibility.py
@@ -142,68 +142,55 @@ def Event_str(self):
(self.type, self.detail1, self.detail2, self.any_data,
self.source, self.host_application)
-def exwrap(func, *args):
- try:
- return func(*args)
- except RuntimeError as e:
- try:
- domain = e.domain
- except:
- raise e
- if domain == "atspi_error":
- raise LookupError
- else:
- raise e
-
### Accessible ###
Accessible = Atspi.Accessible
-Atspi.Accessible.getChildAtIndex = lambda *args: exwrap(Atspi.Accessible.get_child_at_index, *args)
-Atspi.Accessible.getAttributes = lambda *args: exwrap(Atspi.Accessible.get_attributes_as_array, *args)
-Atspi.Accessible.getApplication = lambda *args: exwrap(Atspi.Accessible.get_application, *args)
-Atspi.Accessible.__getitem__ = lambda *args: exwrap(Accessible_getitem, *args)
-Atspi.Accessible.__len__ = lambda *args: exwrap(Atspi.Accessible.get_child_count, *args)
+Atspi.Accessible.getChildAtIndex = Atspi.Accessible.get_child_at_index
+Atspi.Accessible.getAttributes = Atspi.Accessible.get_attributes_as_array
+Atspi.Accessible.getApplication = Atspi.Accessible.get_application
+Atspi.Accessible.__getitem__ = Accessible_getitem
+Atspi.Accessible.__len__ = Atspi.Accessible.get_child_count
Atspi.Accessible.__nonzero__ = lambda x: True
Atspi.Accessible.__str__ = Accessible_str
-Atspi.Accessible.childCount = property(fget=lambda x: exwrap(Atspi.Accessible.get_child_count, x))
-Atspi.Accessible.getChildCount = lambda *args: exwrap(Atspi.Accessible.get_child_count, *args)
-Atspi.Accessible.getIndexInParent = lambda *args: exwrap(Atspi.Accessible.get_index_in_parent, *args)
-Atspi.Accessible.getLocalizedRoleName = lambda *args: exwrap(Atspi.Accessible.get_localized_role_name, *args)
-Atspi.Accessible.getRelationSet = lambda *args: exwrap(Atspi.Accessible.get_relation_set, *args)
-Atspi.Accessible.getRole = lambda *args: exwrap(Atspi.Accessible.get_role, *args)
-Atspi.Accessible.getRoleName = lambda *args: exwrap(Atspi.Accessible.get_role_name, *args)
-Atspi.Accessible.getState = lambda *args: exwrap(Atspi.Accessible.get_state_set, *args)
+Atspi.Accessible.childCount = property(fget=Atspi.Accessible.get_child_count)
+Atspi.Accessible.getChildCount = Atspi.Accessible.get_child_count
+Atspi.Accessible.getIndexInParent = Atspi.Accessible.get_index_in_parent
+Atspi.Accessible.getLocalizedRoleName = Atspi.Accessible.get_localized_role_name
+Atspi.Accessible.getRelationSet = Atspi.Accessible.get_relation_set
+Atspi.Accessible.getRole = Atspi.Accessible.get_role
+Atspi.Accessible.getRoleName = Atspi.Accessible.get_role_name
+Atspi.Accessible.getState = Atspi.Accessible.get_state_set
del Atspi.Accessible.children
-Atspi.Accessible.description = property(fget=lambda x: exwrap(Atspi.Accessible.get_description, x))
-Atspi.Accessible.name = property(fget=lambda x: exwrap(Atspi.Accessible.get_name, x))
+Atspi.Accessible.description = property(fget=Atspi.Accessible.get_description)
+Atspi.Accessible.name = property(fget=Atspi.Accessible.get_name)
Atspi.Accessible.isEqual = lambda a,b: a == b
Atspi.Accessible.parent = property(fget=Atspi.Accessible.get_parent)
Atspi.Accessible.setCacheMask = Atspi.Accessible.set_cache_mask
Atspi.Accessible.clearCache = Atspi.Accessible.clear_cache
-Atspi.Accessible.id = property(fget=lambda x: exwrap(Atspi.Accessible.get_id, x))
-Atspi.Accessible.toolkitName = property(fget=lambda x: exwrap(Atspi.Accessible.get_toolkit_name, x))
-Atspi.Accessible.toolkitVersion = property(fget=lambda x: exwrap(Atspi.Accessible.get_toolkit_version, x))
-Atspi.Accessible.atspiVersion = property(fget=lambda x: exwrap(Atspi.Accessible.get_atspi_version, x))
+Atspi.Accessible.id = property(fget=Atspi.Accessible.get_id)
+Atspi.Accessible.toolkitName = property(fget=Atspi.Accessible.get_toolkit_name)
+Atspi.Accessible.toolkitVersion = property(fget=Atspi.Accessible.get_toolkit_version)
+Atspi.Accessible.atspiVersion = property(fget=Atspi.Accessible.get_atspi_version)
### action ###
-Action = lambda *args: exwrap(Atspi.Action, *args)
+Action = Atspi.Action
Atspi.Accessible.queryAction = lambda x: getInterface(Atspi.Accessible.get_action, x)
-Atspi.Action.doAction = lambda *args: exwrap(Atspi.Action.do_action, *args)
-Atspi.Action.getDescription = lambda *args: exwrap(Atspi.Action.get_description, *args)
-Atspi.Action.getKeyBinding = lambda *args: exwrap(Atspi.Action.get_key_binding, *args)
-Atspi.Action.getName = lambda *args: exwrap(Atspi.Action.get_name, *args)
-Atspi.Action.nActions = property(fget=lambda x: exwrap(Atspi.Action.get_n_actions, x))
+Atspi.Action.doAction = Atspi.Action.do_action
+Atspi.Action.getDescription = Atspi.Action.get_description
+Atspi.Action.getKeyBinding = Atspi.Action.get_key_binding
+Atspi.Action.getName = Atspi.Action.get_name
+Atspi.Action.nActions = property(fget=Atspi.Action.get_n_actions)
### collection ###
-Collection = lambda *args: exwrap(Atspi.Collection, *args)
+Collection = Atspi.Collection
Atspi.Accessible.queryCollection = lambda x: getInterface(Atspi.Accessible.get_collection, x)
-Atspi.Collection.isAncesterOf = lambda *args: exwrap(Atspi.Collection.is_ancestor_of, *args)
+Atspi.Collection.isAncesterOf = Atspi.Collection.is_ancestor_of
Atspi.Collection.createMatchRule = lambda x, s, smt, a, amt, r, rmt, i, imt, inv: Atspi.MatchRule.new (s, smt, attributeListToHash(a), amt, r, rmt, i, imt, inv)
Atspi.Collection.freeMatchRule = lambda self, x: None
-Atspi.Collection.getMatches = lambda *args: exwrap(Atspi.Collection.get_matches, *args)
-Atspi.Collection.getMatchesFrom = lambda *args: exwrap(Atspi.Collection.get_matches_from, *args)
-Atspi.Collection.getMatchesTo = lambda *args: exwrap(Atspi.Collection.get_matches_to, *args)
-Atspi.Collection.getActiveDescendant = lambda *args: exwrap(Atspi.Collection.get_active_descendant, *args)
+Atspi.Collection.getMatches = Atspi.Collection.get_matches
+Atspi.Collection.getMatchesFrom = Atspi.Collection.get_matches_from
+Atspi.Collection.getMatchesTo = Atspi.Collection.get_matches_to
+#Atspi.Collection.getActiveDescendant = Atspi.Collection.get_active_descendant
Atspi.Collection.MATCH_INVALID = Atspi.CollectionMatchType.INVALID
Atspi.Collection.MATCH_ALL = Atspi.CollectionMatchType.ALL
@@ -226,17 +213,17 @@ Atspi.Collection.TREE_INORDER = Atspi.CollectionTreeTraversalType.INORDER
### component ###
Component = Atspi.Component
Atspi.Accessible.queryComponent = lambda x: getInterface(Atspi.Accessible.get_component, x)
-Atspi.Component.getAccessibleAtPoint = lambda *args: exwrap(Atspi.Component.get_accessible_at_point, *args)
-Atspi.Component.getAlpha = lambda *args: exwrap(Atspi.Component.get_alpha, *args)
+Atspi.Component.getAccessibleAtPoint = Atspi.Component.get_accessible_at_point
+Atspi.Component.getAlpha = Atspi.Component.get_alpha
Atspi.Component.getExtents = lambda x,c: getBoundingBox(Atspi.Component.get_extents(x,c))
-Atspi.Component.getLayer = lambda *args: exwrap(Atspi.Component.get_layer, *args)
-Atspi.Component.getMDIZOrder = lambda *args: exwrap(Atspi.Component.get_mdi_z_order, *args)
+Atspi.Component.getLayer = Atspi.Component.get_layer
+Atspi.Component.getMDIZOrder = Atspi.Component.get_mdi_z_order
Atspi.Component.getPosition = lambda x,p: pointToList(Atspi.Component.get_position(x,p))
Atspi.Component.getSize = lambda x: pointToList(Atspi.Component.get_size(x))
-Atspi.Component.grabFocus = lambda *args: exwrap(Atspi.Component.grab_focus, *args)
-Atspi.Component.setExtents = lambda *args: exwrap(Atspi.Component.set_extents, *args)
-Atspi.Component.setPosition = lambda *args: exwrap(Atspi.Component.set_position, *args)
-Atspi.Component.setSize = lambda *args: exwrap(Atspi.Component.set_size, *args)
+Atspi.Component.grabFocus = Atspi.Component.grab_focus
+Atspi.Component.setExtents = Atspi.Component.set_extents
+Atspi.Component.setPosition = Atspi.Component.set_position
+Atspi.Component.setSize = Atspi.Component.set_size
### document ###
Atspi.Accessible.queryDocument = lambda x: Document(getInterface(Atspi.Accessible.get_document, x))
@@ -246,20 +233,20 @@ Atspi.Accessible.queryEditableText = lambda x: EditableText(getInterface(Atspi.A
### hyperlink ###
Hyperlink = Atspi.Hyperlink
-Atspi.Hyperlink.getObject = lambda *args: exwrap(Atspi.Hyperlink.get_object, *args)
-Atspi.Hyperlink.getURI = lambda *args: exwrap(Atspi.Hyperlink.get_uri, *args)
-Atspi.Hyperlink.isValid = lambda *args: exwrap(Atspi.Hyperlink.is_valid, *args)
-Atspi.Hyperlink.endIndex = property(fget=lambda x: exwrap(Atspi.Hyperlink.get_end_index, x))
-Atspi.Hyperlink.nAnchors = property(fget=lambda x: exwrap(Atspi.Hyperlink.get_n_anchors, x))
-Atspi.Hyperlink.startIndex = property(fget=lambda x: exwrap(Atspi.Hyperlink.get_start_index, x))
+Atspi.Hyperlink.getObject = Atspi.Hyperlink.get_object
+Atspi.Hyperlink.getURI = Atspi.Hyperlink.get_uri
+Atspi.Hyperlink.isValid = Atspi.Hyperlink.is_valid
+Atspi.Hyperlink.endIndex = property(fget=Atspi.Hyperlink.get_end_index)
+Atspi.Hyperlink.nAnchors = property(fget=Atspi.Hyperlink.get_n_anchors)
+Atspi.Hyperlink.startIndex = property(fget=Atspi.Hyperlink.get_start_index)
### hypertext ###
Hypertext = Atspi.Hypertext
Atspi.Accessible.queryHyperlink = lambda x: getInterface(Atspi.Accessible.get_hyperlink, x)
Atspi.Accessible.queryHypertext = lambda x: getInterface(Atspi.Accessible.get_hypertext, x)
-Atspi.Hypertext.getLink = lambda *args: exwrap(Atspi.Hypertext.get_link, *args)
-Atspi.Hypertext.getLinkIndex = lambda *args: exwrap(Atspi.Hypertext.get_link_index, *args)
-Atspi.Hypertext.getNLinks = lambda *args: exwrap(Atspi.Hypertext.get_n_links, *args)
+Atspi.Hypertext.getLink = Atspi.Hypertext.get_link
+Atspi.Hypertext.getLinkIndex = Atspi.Hypertext.get_link_index
+Atspi.Hypertext.getNLinks = Atspi.Hypertext.get_n_links
### image ###
Image = Atspi.Image
@@ -267,50 +254,50 @@ Atspi.Accessible.queryImage = lambda x: getInterface(Atspi.Accessible.get_image,
Atspi.Image.getImageExtents = lambda x,c: getBoundingBox(Atspi.Image.get_image_extents(x,c))
Atspi.Image.getImagePosition = lambda x,p: pointToList(Atspi.Image.get_image_position(x,p))
Atspi.Image.getImageSize = lambda x: pointToList(Atspi.Image.get_image_size(x))
-Atspi.Image.imageDescription = property(fget=lambda x: exwrap(Atspi.Image.get_image_description, x))
-Atspi.Image.imageLocale = property(fget=lambda x: exwrap(Atspi.Image.get_image_locale, x))
+Atspi.Image.imageDescription = property(fget=Atspi.Image.get_image_description)
+Atspi.Image.imageLocale = property(fget=Atspi.Image.get_image_locale)
### selection ###
Selection = Atspi.Selection
Atspi.Accessible.querySelection = lambda x: getInterface(Atspi.Accessible.get_selection, x)
-Atspi.Selection.clearSelection = lambda *args: exwrap(Atspi.Selection.clear_selection, *args)
-Atspi.Selection.deselectChild = lambda *args: exwrap(Atspi.Selection.deselect_child, *args)
-Atspi.Selection.deselectSelectedChild = lambda *args: exwrap(Atspi.Selection.deselect_selected_child, *args)
-Atspi.Selection.getSelectedChild = lambda *args: exwrap(Atspi.Selection.get_selected_child, *args)
-Atspi.Selection.isChildSelected = lambda *args: exwrap(Atspi.Selection.is_child_selected, *args)
-Atspi.Selection.selectAll = lambda *args: exwrap(Atspi.Selection.select_all, *args)
-Atspi.Selection.selectChild = lambda *args: exwrap(Atspi.Selection.select_child, *args)
-Atspi.Selection.nSelectedChildren = property(fget=lambda x: exwrap(Atspi.Selection.get_n_selected_children, x))
+Atspi.Selection.clearSelection = Atspi.Selection.clear_selection
+Atspi.Selection.deselectChild = Atspi.Selection.deselect_child
+Atspi.Selection.deselectSelectedChild = Atspi.Selection.deselect_selected_child
+Atspi.Selection.getSelectedChild = Atspi.Selection.get_selected_child
+Atspi.Selection.isChildSelected = Atspi.Selection.is_child_selected
+Atspi.Selection.selectAll = Atspi.Selection.select_all
+Atspi.Selection.selectChild = Atspi.Selection.select_child
+Atspi.Selection.nSelectedChildren = property(fget=Atspi.Selection.get_n_selected_children)
### table ###
Table = Atspi.Table
Atspi.Accessible.queryTable = lambda x: getInterface(Atspi.Accessible.get_table, x)
-Atspi.Table.addColumnSelection = lambda *args: exwrap(Atspi.Table.add_column_selection, *args)
-Atspi.Table.addRowSelection = lambda *args: exwrap(Atspi.Table.add_row_selection, *args)
-Atspi.Table.caption = property(fget=lambda x: exwrap(Atspi.Table.get_caption, x))
-Atspi.Table.getAccessibleAt = lambda *args: exwrap(Atspi.Table.get_accessible_at, *args)
-Atspi.Table.getColumnAtIndex = lambda *args: exwrap(Atspi.Table.get_column_at_index, *args)
-Atspi.Table.getColumnDescription = lambda *args: exwrap(Atspi.Table.get_column_description, *args)
-Atspi.Table.getColumnExtentAt = lambda *args: exwrap(Atspi.Table.get_column_extent_at, *args)
-Atspi.Table.getColumnHeader = lambda *args: exwrap(Atspi.Table.get_column_header, *args)
-Atspi.Table.getIndexAt = lambda *args: exwrap(Atspi.Table.get_index_at, *args)
-Atspi.Table.getRowAtIndex = lambda *args: exwrap(Atspi.Table.get_row_at_index, *args)
-Atspi.Table.getRowColumnExtentsAtIndex = lambda *args: exwrap(Atspi.Table.get_row_column_extents_at_index, *args)
-Atspi.Table.getRowDescription = lambda *args: exwrap(Atspi.Table.get_row_description, *args)
-Atspi.Table.getRowExtentAt = lambda *args: exwrap(Atspi.Table.get_row_extent_at, *args)
-Atspi.Table.getRowHeader = lambda *args: exwrap(Atspi.Table.get_row_header, *args)
-Atspi.Table.getSelectedColumns = lambda *args: exwrap(Atspi.Table.get_selected_columns, *args)
-Atspi.Table.getSelectedRows = lambda *args: exwrap(Atspi.Table.get_selected_rows, *args)
-Atspi.Table.isColumnSelected = lambda *args: exwrap(Atspi.Table.is_column_selected, *args)
-Atspi.Table.isRowSelected = lambda *args: exwrap(Atspi.Table.is_row_selected, *args)
-Atspi.Table.isSelected = lambda *args: exwrap(Atspi.Table.is_selected, *args)
-Atspi.Table.removeColumnSelection = lambda *args: exwrap(Atspi.Table.remove_column_selection, *args)
-Atspi.Table.removeRowSelection = lambda *args: exwrap(Atspi.Table.remove_row_selection, *args)
-Atspi.Table.nColumns = property(fget=lambda x: exwrap(Atspi.Table.get_n_columns, x))
-Atspi.Table.nRows = property(fget=lambda x: exwrap(Atspi.Table.get_n_rows, x))
-Atspi.Table.get_nSelectedColumns = lambda *args: exwrap(Atspi.Table.get_n_selected_columns, *args)
-Atspi.Table.get_nSelectedRows = lambda *args: exwrap(Atspi.Table.get_n_selected_rows, *args)
-Atspi.Table.summary = property(fget=lambda x: exwrap(Atspi.Table.get_summary, x))
+Atspi.Table.addColumnSelection = Atspi.Table.add_column_selection
+Atspi.Table.addRowSelection = Atspi.Table.add_row_selection
+Atspi.Table.caption = property(fget=Atspi.Table.get_caption)
+Atspi.Table.getAccessibleAt = Atspi.Table.get_accessible_at
+Atspi.Table.getColumnAtIndex = Atspi.Table.get_column_at_index
+Atspi.Table.getColumnDescription = Atspi.Table.get_column_description
+Atspi.Table.getColumnExtentAt = Atspi.Table.get_column_extent_at
+Atspi.Table.getColumnHeader = Atspi.Table.get_column_header
+Atspi.Table.getIndexAt = Atspi.Table.get_index_at
+Atspi.Table.getRowAtIndex = Atspi.Table.get_row_at_index
+Atspi.Table.getRowColumnExtentsAtIndex = Atspi.Table.get_row_column_extents_at_index
+Atspi.Table.getRowDescription = Atspi.Table.get_row_description
+Atspi.Table.getRowExtentAt = Atspi.Table.get_row_extent_at
+Atspi.Table.getRowHeader = Atspi.Table.get_row_header
+Atspi.Table.getSelectedColumns = Atspi.Table.get_selected_columns
+Atspi.Table.getSelectedRows = Atspi.Table.get_selected_rows
+Atspi.Table.isColumnSelected = Atspi.Table.is_column_selected
+Atspi.Table.isRowSelected = Atspi.Table.is_row_selected
+Atspi.Table.isSelected = Atspi.Table.is_selected
+Atspi.Table.removeColumnSelection = Atspi.Table.remove_column_selection
+Atspi.Table.removeRowSelection = Atspi.Table.remove_row_selection
+Atspi.Table.nColumns = property(fget=Atspi.Table.get_n_columns)
+Atspi.Table.nRows = property(fget=Atspi.Table.get_n_rows)
+Atspi.Table.get_nSelectedColumns = Atspi.Table.get_n_selected_columns
+Atspi.Table.get_nSelectedRows = Atspi.Table.get_n_selected_rows
+Atspi.Table.summary = property(fget=Atspi.Table.get_summary)
### text ###
Atspi.Accessible.queryText = lambda x: Text(getInterface(Atspi.Accessible.get_text, x))
@@ -331,10 +318,10 @@ TEXT_CLIP_BOTH= Atspi.TextClipType.BOTH
### value ###
Value = Atspi.Value
Atspi.Accessible.queryValue = lambda x: getInterface(Atspi.Accessible.get_value, x)
-Atspi.Value.currentValue = property(fget=lambda x: exwrap(Atspi.Value.get_current_value, x), fset=Atspi.Value.set_current_value)
-Atspi.Value.maximumValue = property(fget=lambda x: exwrap(Atspi.Value.get_maximum_value, x))
-Atspi.Value.minimumIncrement = property(fget=lambda x: exwrap(Atspi.Value.get_minimum_increment, x))
-Atspi.Value.minimumValue = property(fget=lambda x: exwrap(Atspi.Value.get_minimum_value, x))
+Atspi.Value.currentValue = property(fget=Atspi.Value.get_current_value, fset=Atspi.Value.set_current_value)
+Atspi.Value.maximumValue = property(fget=Atspi.Value.get_maximum_value)
+Atspi.Value.minimumIncrement = property(fget=Atspi.Value.get_minimum_increment)
+Atspi.Value.minimumValue = property(fget=Atspi.Value.get_minimum_value)
### DeviceEvent ###
Atspi.DeviceEvent.__str__ = DeviceEvent_str
diff --git a/pyatspi/document.py b/pyatspi/document.py
index bce7d12..e17590c 100644
--- a/pyatspi/document.py
+++ b/pyatspi/document.py
@@ -47,7 +47,7 @@ class Document:
attribute, or an empty string if the attribute is unspecified
for the object.
"""
- return exwrap(Atspi.Document.get_attribute_value, self.obj, key)
+ return Atspi.Document.get_attribute_value(self.obj, key)
def getAttributes(self):
"""
@@ -57,7 +57,7 @@ class Document:
@return an AttributeSet containing the attributes of the document,
as name-value pairs.
"""
- ret = exwrap(Atspi.Document.get_attributes, self.obj)
+ ret = Atspi.Document.get_attributes(self.obj)
return [key + ':' + value for key, value in ret.iteritems()]
def getLocale(self):
@@ -67,6 +67,6 @@ class Document:
@return a string compliant with the POSIX standard for locale
description.
"""
- return exwrap(Atspi.Document.get_locale, self.obj)
+ return Atspi.Document.get_locale(self.obj)
#END----------------------------------------------------------------------------
diff --git a/pyatspi/editabletext.py b/pyatspi/editabletext.py
index f863b33..b1f3108 100644
--- a/pyatspi/editabletext.py
+++ b/pyatspi/editabletext.py
@@ -41,7 +41,7 @@ class EditableText(Text):
the offset of the first character past the end of the range of
text being copied.
"""
- return exwrap(Atspi.EditableText.copy_text, self.obj, start, end)
+ return Atspi.EditableText.copy_text(self.obj, start, end)
def cutText(self, start, end):
"""
@@ -55,7 +55,7 @@ class EditableText(Text):
text being cut.
@return True if the text was successfully cut, False otherwise.
"""
- return exwrap(Atspi.EditableText.cut_text, self.obj, start, end)
+ return Atspi.EditableText.cut_text(self.obj, start, end)
def deleteText(self, start, end):
"""
@@ -69,7 +69,7 @@ class EditableText(Text):
text being deleted.
@return True if the text was successfully deleted, False otherwise.
"""
- return exwrap(Atspi.EditableText.delete_text, self.obj, start, end)
+ return Atspi.EditableText.delete_text(self.obj, start, end)
def insertText(self, position, text, length):
"""
@@ -88,7 +88,7 @@ class EditableText(Text):
@return True if the text content was successfully inserted, False
otherwise.
"""
- return exwrap(Atspi.EditableText.insert_text, self.obj, position, text, length)
+ return Atspi.EditableText.insert_text(self.obj, position, text, length)
def pasteText(self, position):
"""
@@ -99,7 +99,7 @@ class EditableText(Text):
@return True if the text was successfully pasted into the Text
object, False otherwise.
"""
- return exwrap(Atspi.EditableText.paste_text, self.obj, position)
+ return Atspi.EditableText.paste_text(self.obj, position)
def setTextContents(self, contents):
"""
@@ -111,6 +111,6 @@ class EditableText(Text):
@return True if the text content was successfully changed, False
otherwise.
"""
- return exwrap(Atspi.EditableText.set_text_contents, self.obj, contents)
+ return Atspi.EditableText.set_text_contents(self.obj, contents)
#END----------------------------------------------------------------------------
diff --git a/pyatspi/text.py b/pyatspi/text.py
index de7fed0..0274d2b 100644
--- a/pyatspi/text.py
+++ b/pyatspi/text.py
@@ -115,7 +115,7 @@ class Text:
other reasons (for instance if the user does not have permission
to copy the text into the relevant selection buffer).
"""
- return exwrap(Atspi.Text.add_selection, self.obj, index)
+ return Atspi.Text.add_selection(self.obj, index)
def getAttributeRun(self, offset, includeDefaults=True):
"""
@@ -166,7 +166,7 @@ class Text:
@return the AttributeSet defined at offset, optionally including
the 'default' attributes.
"""
- [attrs, startOffset, endOffset] = exwrap(Atspi.Text.get_attribute_run, self.obj, offset, includeDefaults)
+ [attrs, startOffset, endOffset] = Atspi.Text.get_attribute_run(self.obj, offset, includeDefaults)
dict = [key + ':' + value for key, value in attrs.items()]
return [dict, startOffset, endOffset]
@@ -192,7 +192,7 @@ class Text:
@return the value of attribute (name-value pair) corresponding
to "name", if defined.
"""
- return exwrap(Atspi.Text.get_attribute_value, self.obj, offset, attributeName)
+ return Atspi.Text.get_attribute_value(self.obj, offset, attributeName)
def getAttributes(self, offset):
"""
@@ -200,7 +200,7 @@ class Text:
@return the attributes at offset, as a semicolon-delimited set
of colon-delimited name-value pairs.
"""
- [attrs, startOffset, endOffset] = exwrap(Atspi.Text.get_attributes, self.obj, offset)
+ [attrs, startOffset, endOffset] = Atspi.Text.get_attributes(self.obj, offset)
arr = [key + ':' + value for key, value in attrs.items()]
str = ';'.join (arr)
return [str, startOffset, endOffset]
@@ -233,7 +233,7 @@ class Text:
determines whether text which intersects the bounding box in
the y direction is included.
"""
- return exwrap(Atspi.Text.get_bounded_ranges, self.obj, x, y, width, height, coordType, xClipType, yClipType)
+ return Atspi.Text.get_bounded_ranges(self.obj, x, y, width, height, coordType, xClipType, yClipType)
def getCharacterAtOffset(self, offset):
"""
@@ -243,7 +243,7 @@ class Text:
UCS-4 representation of the character at the specified text offset,
or 0 if offset is out of range.
"""
- return exwrap(Atspi.Text.get_character_offset, self.obj, offset)
+ return Atspi.Text.get_character_offset(self.obj, offset)
def getCharacterExtents(self, offset, coordType):
"""
@@ -264,7 +264,7 @@ class Text:
window, with the x axis pointing right and the y axis pointing
down.
"""
- ret = exwrap(Atspi.Text.get_character_extents, self.obj, offset, coordType)
+ ret = Atspi.Text.get_character_extents(self.obj, offset, coordType)
return rectToList(ret)
def getDefaultAttributeSet(self):
@@ -278,7 +278,7 @@ class Text:
whereas an object whose text weight is inspecified may report
the default or implied text weight in the default AttributeSet.
"""
- ret = exwrap(Atspi.Text.get_default_attribute_set, self.obj)
+ ret = Atspi.Text.get_default_attribute_set(self.obj)
return [key + ':' + value for key, value in ret.values()]
def getDefaultAttributes(self):
@@ -287,7 +287,7 @@ class Text:
@return the attributes which apply to the entire text content,
but which were not explicitly specified by the content creator.
"""
- ret = exwrap(Atspi.Text.get_default_attributes, self.obj)
+ ret = Atspi.Text.get_default_attributes(self.obj)
return ';'.join([key + ':' + value for key, value in ret.iteritems()])
def getNSelections(self):
@@ -302,7 +302,7 @@ class Text:
@return the number of contiguous selections in the current Text
object.
"""
- return exwrap(Atspi.Text.get_n_selections, self.obj)
+ return Atspi.Text.get_n_selections(self.obj)
def getOffsetAtPoint(self, x, y, coordType):
"""
@@ -319,7 +319,7 @@ class Text:
of the glyph whose onscreen bounds contain the point x,y, or
-1 if the point is outside the bounds of any glyph.
"""
- return exwrap(Atspi.Text.get_offset_at_point, self.obj, x, y, coordType)
+ return Atspi.Text.get_offset_at_point(self.obj, x, y, coordType)
def getRangeExtents(self, startOffset, endOffset, coordType):
"""
@@ -349,7 +349,7 @@ class Text:
corner of the screen; if 1, the coordinates are reported relative
to the corner of the containing toplevel window.
"""
- ret = exwrap(Atspi.Text.get_range_extents, self.obj, startOffset, endOffset, coordType)
+ ret = Atspi.Text.get_range_extents(self.obj, startOffset, endOffset, coordType)
return rectToList(ret)
def getSelection(self, selectionNum):
@@ -366,7 +366,7 @@ class Text:
back-filled with the offset of the character immediately following
the resulting substring, if one exists.
"""
- ret = exwrap(Atspi.Text.get_selection, self.obj, selectionNum)
+ ret = Atspi.Text.get_selection(self.obj, selectionNum)
return rangeToList(ret)
def getText(self, startOffset, endOffset):
@@ -386,7 +386,7 @@ class Text:
"""
if not endOffset:
endOffset = -1
- return exwrap(Atspi.Text.get_text, self.obj, startOffset, endOffset)
+ return Atspi.Text.get_text(self.obj, startOffset, endOffset)
def getTextAfterOffset(self, offset, type):
"""
@@ -413,7 +413,7 @@ class Text:
@return a string which is a substring of the text content of
the object, delimited by the specified boundary condition.
"""
- ret = exwrap(Atspi.Text.get_text_after_offset, self.obj, offset, type)
+ ret = Atspi.Text.get_text_after_offset(self.obj, offset, type)
return textRangeToList(ret)
def getTextAtOffset(self, offset, type):
@@ -440,7 +440,7 @@ class Text:
@return a string which is a substring of the text content of
the object, delimited by the specified boundary condition.
"""
- ret = exwrap(Atspi.Text.get_text_at_offset, self.obj, offset, type)
+ ret = Atspi.Text.get_text_at_offset(self.obj, offset, type)
return textRangeToList(ret)
def getTextBeforeOffset(self, offset, type):
@@ -467,7 +467,7 @@ class Text:
@return a string which is a substring of the text content of
the object, delimited by the specified boundary condition.
"""
- ret = exwrap(Atspi.Text.get_text_before_offset, self.obj, offset, type)
+ ret = Atspi.Text.get_text_before_offset(self.obj, offset, type)
return textRangeToList(ret)
def removeSelection(self, selectionNum):
@@ -480,7 +480,7 @@ class Text:
@return True if the selection was successfully removed, False
otherwise.
"""
- return exwrap(Atspi.Text.remove_selection, self.obj, index)
+ return Atspi.Text.remove_selection(self.obj, index)
def setCaretOffset(self, offset):
"""
@@ -493,7 +493,7 @@ class Text:
@return TRUE if the request was carried out, or FALSE if the
caret could not be moved to the requested position.
"""
- return exwrap(Atspi.Text.set_caret_offset, self.obj, offset)
+ return Atspi.Text.set_caret_offset(self.obj, offset)
def setSelection(self, selectionNum, startOffset, endOffset):
"""
@@ -511,10 +511,10 @@ class Text:
@return True if the selection corresponding to selectionNum is
successfully modified, False otherwise.
"""
- return exwrap(Atspi.Text.set_selection, self.obj, selectionNum, startOffset, endOffset)
+ return Atspi.Text.set_selection(self.obj, selectionNum, startOffset, endOffset)
def get_caretOffset(self):
- return exwrap(Atspi.Text.get_caret_offset, self.obj)
+ return Atspi.Text.get_caret_offset(self.obj)
_caretOffsetDoc = \
"""
The current offset of the text caret in the Text object. This
@@ -527,7 +527,7 @@ class Text:
caretOffset = property(fget=get_caretOffset, doc=_caretOffsetDoc)
def get_characterCount(self):
- return exwrap(Atspi.Text.get_character_count, self.obj)
+ return Atspi.Text.get_character_count(self.obj)
_characterCountDoc = \
"""
The total current number of characters in the Text object, including
diff --git a/pyatspi/utils.py b/pyatspi/utils.py
index 59fa75a..d5754ac 100644
--- a/pyatspi/utils.py
+++ b/pyatspi/utils.py
@@ -42,8 +42,7 @@ __all__ = [
"findAllDescendants",
"findAncestor",
"getPath",
- "rectToList",
- "exwrap"
+ "rectToList"
]
def setCacheLevel(level):
@@ -331,9 +330,3 @@ def pointToList(point):
def rectToList(rect):
return (rect.x, rect.y, rect.width, rect.height)
-
-def exwrap(func, *args):
- try:
- return func(*args)
- except RuntimeError:
- raise LookupError
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]