1 #!/usr/bin/env python2.5
4 # Copyright (c) 2007-2008 INdT.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # ============================================================================
21 # Author : Yves Marcoz
23 # Description : Simple RSS Reader
24 # ============================================================================
26 from xml.dom.minidom import parse, parseString
28 from os.path import isfile, dirname
30 logger = logging.getLogger(__name__)
32 def getOpmlText(listing):
33 time_now = time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime())
34 opml_text = """<?xml version="1.0" encoding="UTF-8"?>
37 <title>Feeding It Export</title>
41 for key in listing.getListOfFeeds():
42 title = listing.getFeedTitle(key)
43 url = listing.getFeedUrl(key)
44 if not title == "Archived Articles":
45 opml_text += """\n\t\t<outline type="rss" text="%s" title="%s" xmlUrl="%s"/>""" % (sanitize(title), sanitize(title), sanitize(url))
46 opml_text += """\n</body>\n</opml>\n"""
50 from cgi import escape
51 return escape(text).encode('ascii', 'xmlcharrefreplace')
53 def parseOpml(opmlData):
55 dom1 = parseString(opmlData)
57 outlines = dom1.getElementsByTagName('outline')
58 for outline in outlines:
59 title = outline.getAttribute('text')
60 url = outline.getAttribute('xmlUrl')
62 url = outline.getAttribute('htmlUrl')
64 feeds.append( (title, url) )