Beispiel #1
0
 def getFromXml( self, configFile ):
     # Get the xml document.
     doc = xml.dom.minidom.parse( configFile  )
     # Set up the inital data structure for settings.
     settings = { "feeds": {} }
     # Iterate from the root node.
     for child in utils.xmlGetNode( doc, "podcast" ).childNodes:
         # Only process the feeds node.
         if utils.xmlFilterName( child, "feeds" ):
             for feed in child.childNodes:
                 # Only process the feed nodes
                 if utils.xmlFilterName( feed, "feed" ):
                     print "FEED!"
                     key = None
                     atrib = {}
                     # Build up an attribute dictionary.
                     for i in xrange( feed.attributes.length ):
                         name = feed.attributes.item( i ).localName
                         if name == "name":
                             key = utils.xmlGetAttrib( feed, "name" )
                         else:
                             atrib[ name ] = utils.xmlGetAttrib( feed, name )
                     if key:
                         settings[ "feeds" ][ key ] = atrib
         # Else, try and add a general node with a value setting.
         elif child.nodeType == child.ELEMENT_NODE and child.localName:
             settings[ child.localName ] = utils.xmlGetAttrib( child, "value" )
     return settings
Beispiel #2
0
 def genItems( self, doc ):
     return ( item
         for rss in doc.childNodes
             if utils.xmlFilterName( rss, "rss" )
                 for chan in rss.childNodes
                     if utils.xmlFilterName( chan, "channel" )
                         for item in chan.childNodes
                             if utils.xmlFilterName( item, "item" )
     )