[Hildon-test-aut-commits] r612 - trunk/dogtail/dogtail

suanand at garage.maemo.org suanand at garage.maemo.org
Fri Nov 23 12:43:28 EET 2007


Author: suanand
Date: 2007-11-23 12:43:28 +0200 (Fri, 23 Nov 2007)
New Revision: 612

Modified:
   trunk/dogtail/dogtail/rocknrole.py
Log:
updated refresh to old copy, where we don't use atspi directly

Modified: trunk/dogtail/dogtail/rocknrole.py
===================================================================
--- trunk/dogtail/dogtail/rocknrole.py	2007-11-23 10:00:14 UTC (rev 611)
+++ trunk/dogtail/dogtail/rocknrole.py	2007-11-23 10:43:28 UTC (rev 612)
@@ -1,5 +1,4 @@
 #!/usr/bin/python  -tt
-# vim: sw=4 ts=4 expandtab ai
 
 #########################################################################################
 #   rocknrole.py - Work on dogtail nodes by creating objects with rolenames as attributes.
@@ -55,50 +54,22 @@
         self.RRlastItem=0
         self.waitfortime=0
         self.__timer()
+
     def __str__ (self):
         return "RNR (%s)" % self.node
 
     def refresh(self):
-        """ Creates attributes for the object, based on roleName.
+        """ Creates attributes for the object, based on roleName. """
 
-        All roleNames are prepended with 'RNR' and they contain a list of dogtail nodes with that roleName under the object.
-        Even single entries are stored in list format. So, to access the only dialog under a given node we can :
-            - refer to it directly as <RNRObject>.RNRdialog[0], OR, 
-            - call the object's doon method as <RNRObject>.doon('dialog') """
-
         for i in self.__dict__.keys():
             if i.startswith('RNR'):
                 self.__dict__.pop(i)
+        try :
+            chkChildren=self.node.children
+            for child in self.node.findChildren(predicate.GenericPredicate()) :
+                self.__setattr__('RNR'+child.roleName.lower().replace(' ',''), child)
+        except AttributeError : pass
 
-        def kidsearch(node):
-            """Basic recursive function which collapses given tree, slightly faster than original way.
-            
-            May need to revisit this with pyatspi.
-            """
-            try:
-                children = []
-                for i in xrange(node._Node__accessible.getChildCount()):
-                    children.append(node._Node__accessible.getChildAtIndex(i))
-                for child in children:
-                     if child is not None:
-                        child = tree.Node(child)
-                        self.__setattr__('RNR'+child.roleName.replace(' ','').lower(), child)
-                        kidsearch(child)
-                     if not child: raise TypeError
-            except AttributeError:
-                pass 
-        try:        
-            kidsearch(self.node)
-        except TypeError:
-            try:
-                for i in self.__dict__.keys():
-                    if i.startswith('RNR'):
-                        self.__dict__.pop(i)
-                
-                kidsearch(self.node)
-            except TypeError: raise AssertionError, "Error in finding children"
-        
-
     def __getattrresolver(self, attr, *args):
 
         self.refreshFlag=False



More information about the Hildon-test-aut-commits mailing list