view OpmlImport.py @ 198:460a3062c5e6

create the database if it doesn't exist and drop it after test
author dirk
date Fri, 27 Jan 2012 02:35:46 +0100
parents b8d209fdad14
children bb3c851b18b1
line wrap: on
line source


from Feed import Feed
from xml.dom.minidom import parse

def createFeedsFromOPML(session=None, filename=None):
    document = parse(filename)
    outlines = document.getElementsByTagName("outline")
    for outline in outlines:
        url = outline.getAttribute("xmlUrl")
        title = outline.getAttribute("title")
        
        feed = Feed(title, url)
        session.add(feed)
    session.commit()