Mercurial > hg > Feedworm
annotate OpmlImport.py @ 254:156edbd0733a pyqt5
the pyqt5 branch was merged into the default branch
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 10 Nov 2017 01:45:55 +0100 |
parents | 699d8f1cebd4 |
children |
rev | line source |
---|---|
217
bb3c851b18b1
add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
63
diff
changeset
|
1 # -*- coding: utf-8 -*- |
63
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
2 from Feed import Feed |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
3 from xml.dom.minidom import parse |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
4 |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
5 def createFeedsFromOPML(session=None, filename=None): |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
6 document = parse(filename) |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
7 outlines = document.getElementsByTagName("outline") |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
8 for outline in outlines: |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
9 url = outline.getAttribute("xmlUrl") |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
10 title = outline.getAttribute("title") |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
11 |
63
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
12 feed = Feed(title, url) |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
13 session.add(feed) |
b8d209fdad14
helper class to create Feed objects from an OPML feed
dirk@xanthippe.ping.de
parents:
diff
changeset
|
14 session.commit() |