From: Yves Marcoz Date: Tue, 24 Jan 2012 05:58:02 +0000 (-0800) Subject: psa: adding missing opml_lib library X-Git-Url: https://vcs.maemo.org/git/?p=feedingit;a=commitdiff_plain;h=4a48b1271cfdf4c6b5665e8a53b115d1e6876fdb psa: adding missing opml_lib library --- diff --git a/psa_harmattan/feedingit/pysrc/opml_lib.py b/psa_harmattan/feedingit/pysrc/opml_lib.py new file mode 100644 index 0000000..4de756b --- /dev/null +++ b/psa_harmattan/feedingit/pysrc/opml_lib.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python2.5 + +# +# Copyright (c) 2007-2008 INdT. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# + +# ============================================================================ +# Name : FeedingIt.py +# Author : Yves Marcoz +# Version : 0.2.2 +# Description : Simple RSS Reader +# ============================================================================ + +from xml.dom.minidom import parse, parseString +import time +from os.path import isfile, dirname +import logging +logger = logging.getLogger(__name__) + +def getOpmlText(listing): + time_now = time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime()) + opml_text = """ + + + Feeding It Export + + +""" + for key in listing.getListOfFeeds(): + title = listing.getFeedTitle(key) + url = listing.getFeedUrl(key) + if not title == "Archived Articles": + opml_text += """\n\t\t""" % (sanitize(title), sanitize(title), sanitize(url)) + opml_text += """\n\n\n""" + return opml_text + +def sanitize(text): + from cgi import escape + return escape(text).encode('ascii', 'xmlcharrefreplace') + +def parseOpml(opmlData): + feeds = [] + dom1 = parseString(opmlData) + + outlines = dom1.getElementsByTagName('outline') + for outline in outlines: + title = outline.getAttribute('text') + url = outline.getAttribute('xmlUrl') + if url == "": + url = outline.getAttribute('htmlUrl') + if not url == "": + feeds.append( (title, url) ) + return feeds \ No newline at end of file