split api and driver
[sfa.git] / sfa / rspecs / elements / element.py
index 898706e..401ca31 100644 (file)
@@ -10,7 +10,7 @@ class Element:
 
     def add_element(self, name, attrs={}, parent=None, text=""):
         """
-        Generic wrapper around etree.SubElement(). Adds an element to
+        Wrapper around etree.SubElement(). Adds an element to
         specified parent node. Adds element to root node is parent is
         not specified.
         """
@@ -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: