dogtail r366 - in trunk: . dogtail



Author: zcerza
Date: Thu Jan 10 21:40:00 2008
New Revision: 366
URL: http://svn.gnome.org/viewvc/dogtail?rev=366&view=rev

Log:
* dogtail/tree.py: Add Node.dead property; useful if you're unsure if
the accessible you're about to poke at is still valid, and don't feel like
trying to catch 3 or more different exceptions.


Modified:
   trunk/ChangeLog
   trunk/dogtail/tree.py

Modified: trunk/dogtail/tree.py
==============================================================================
--- trunk/dogtail/tree.py	(original)
+++ trunk/dogtail/tree.py	Thu Jan 10 21:40:00 2008
@@ -81,6 +81,8 @@
 except ImportError:
     raise ImportError, "Error importing the AT-SPI bindings"
 
+from CORBA import COMM_FAILURE, OBJECT_NOT_EXIST
+
 # We optionally import the bindings for libwnck.
 try:
     import wnck
@@ -195,6 +197,15 @@
     ##
     # Accessible
     ##
+    def _getDead(self):
+        try:
+            if self.roleName == 'invalid': return True
+            n = self.role
+            n = self.name
+            n = self[0]
+        except (LookupError, COMM_FAILURE, OBJECT_NOT_EXIST): return True
+        return False
+    dead = property(_getDead, doc = "Is the node dead (defunct) ?")
 
     def _getChildren(self):
         if self.parent and self.parent.roleName == 'hyper link':



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