From 7f1849bd6e4ea60eb1ef00abd15fa3fbb946ef63 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Tue, 23 Jun 2009 12:40:34 +0000 Subject: [PATCH] Split download/parsing of RSS data in 2 functions. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27777 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../ExtensionTemplateItem/GetRssDataAsDict.py | 7 +++++-- bt5/erp5_knowledge_pad/bt/revision | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bt5/erp5_knowledge_pad/ExtensionTemplateItem/GetRssDataAsDict.py b/bt5/erp5_knowledge_pad/ExtensionTemplateItem/GetRssDataAsDict.py index f940a2d76f..cce1bf255a 100644 --- a/bt5/erp5_knowledge_pad/ExtensionTemplateItem/GetRssDataAsDict.py +++ b/bt5/erp5_knowledge_pad/ExtensionTemplateItem/GetRssDataAsDict.py @@ -1,6 +1,6 @@ from urllib2 import HTTPPasswordMgrWithDefaultRealm, HTTPBasicAuthHandler, \ build_opener, install_opener, urlopen, HTTPError -from xml.dom.minidom import parse +from xml.dom.minidom import parseString import md5 from HTMLParser import HTMLParser @@ -24,8 +24,11 @@ def getRssDataAsDict(url, username, password): return {'title': 'Page not found.' } except : return {'title': 'Fetching Rss failed.' } + return parseRssDataAsDict(file.read()) + +def parseRssDataAsDict(rss_string): try: - xmlDoc = parse(file).documentElement + xmlDoc = parseString(rss_string).documentElement except : return {'title': 'Parsing RSS failed.' } if(xmlDoc.tagName.startswith('rss') or xmlDoc.tagName.startswith('rdf') ): diff --git a/bt5/erp5_knowledge_pad/bt/revision b/bt5/erp5_knowledge_pad/bt/revision index 25493604ef..50b04dff0e 100644 --- a/bt5/erp5_knowledge_pad/bt/revision +++ b/bt5/erp5_knowledge_pad/bt/revision @@ -1 +1 @@ -395 \ No newline at end of file +402 \ No newline at end of file -- 2.30.9