replace 'recursive' argument with 'depth' argument in get_attributes()
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 30 Jun 2011 19:26:54 +0000 (15:26 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 30 Jun 2011 19:26:54 +0000 (15:26 -0400)
sfa/rspecs/elements/element.py

index 898706e..8217c11 100644 (file)
@@ -59,12 +59,12 @@ class Element:
                     if opt.text == value:
                         elem.remove(opt)
 
-    def get_attributes(self, elem=None, recursive=False):
+    def get_attributes(self, elem=None, depth=None):
         if elem == None:
             elem = self.root_node
         attrs = dict(elem.attrib)
         attrs['text'] = str(elem.text).strip()
-        if recursive:
+        if depth is None or isinstance(depth, int) and depth > 0: 
             for child_elem in list(elem):
                 key = str(child_elem.tag)
                 if key not in attrs: