Changeset 2 for trunk


Ignore:
Timestamp:
Mar 17, 2005, 11:40:26 AM (19 years ago)
Author:
mmc
Message:

Fixed the library.children() method to allow filtering
based on XML node type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/Rappture/library.py

    r1 r2  
    7373
    7474    # ------------------------------------------------------------------
    75     def children(self, path="", flavor="object"):
     75    def children(self, path="", flavor="object", type=None):
    7676        """
    7777        Clients use this to query the children of a particular element
    7878        within the entire data structure.  This is just like the
    7979        element() method, but it returns the children of the element
    80         instead of the element itself.
     80        instead of the element itself.  If the optional type argument
     81        is specified, then the return list is restricted to children
     82        of the specified type.
    8183
    8284        By default, this method returns a list of objects representing
     
    9395
    9496        nlist = [n for n in node.childNodes if not n.nodeName.startswith('#')]
     97
     98        if type:
     99            nlist = [n for n in nlist if n.nodeName == type]
    95100
    96101        if flavor == 'object':
Note: See TracChangeset for help on using the changeset viewer.