changeset 63:b8d209fdad14

helper class to create Feed objects from an OPML feed
author dirk@xanthippe.ping.de
date Wed, 28 Jul 2010 21:14:34 +0200
parents abc0516a1c0c
children d21f5025034d
files OpmlImport.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OpmlImport.py	Wed Jul 28 21:14:34 2010 +0200
@@ -0,0 +1,14 @@
+
+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()