X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=psa_harmattan%2Ffeedingit%2Fpysrc%2Fopml_lib.py;fp=psa_harmattan%2Ffeedingit%2Fpysrc%2Fopml_lib.py;h=4de756b5e05708abae8d1471548085d42cc011be;hb=4a48b1271cfdf4c6b5665e8a53b115d1e6876fdb;hp=0000000000000000000000000000000000000000;hpb=2e3d13f0400464104e011843428f48d3c03a9cab;p=feedingit
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