4 __copyright__
= "Copyright (c) 2002-2005 Free Software Foundation, Inc."
6 Straw is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 2 of the License, or (at your option) any later
11 Straw is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 Place - Suite 330, Boston, MA 02111-1307, USA. """
23 class BlogListEntry(object):
24 __slots__
= ('text', 'url')
26 def _find_entries(outline
):
28 for c
in outline
.children
:
29 entries
+= _find_entries(c
)
30 type = outline
.get('type', '')
31 text
= outline
.get('text', '')
34 url
= outline
.get('url', '')
40 xmlurl
= outline
.get('xmlUrl', '')
44 title
= outline
.get('title', '')
50 # there's something in xmlurl. There's a good chance that's
54 htmlurl
= outline
.get('htmlUrl', '')
56 # there's something in htmlurl, and xmlurl is empty. This
57 # might be our feed's URL.
60 # nothing else to try.
66 def find_entries(outlines
):
69 entries
+= _find_entries(o
)
74 o
= OPML
.parse(stream
)
77 entries
= find_entries(o
.outlines
)
83 edict
[ek
] = edict
.get(ek
, 0) + 1
88 def import_opml(filename
,category
=None):
89 feedlist
= feeds
.get_instance()
90 fstream
= open (filename
)
94 feeds
= [feed
.access_info
[0] for feed
in feedlist
]
95 newitems
= [feeds
.Feed
.create_new_feed(b
.text
, b
.url
) for b
in opml
if b
.url
not in feeds
]
96 feedlist
.extend(category
, newitems
)