implemented error handler to TRY to recover from parsing errors

git-svn-id: svn://svn.berlios.de/gpodder@14 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Thomas Perl 2005-11-23 19:47:33 +00:00
parent fd218c2213
commit 75d8b17735
1 changed files with 16 additions and 0 deletions

View File

@ -12,12 +12,26 @@
#
from xml.sax.saxutils import DefaultHandler
from xml.sax.handler import ErrorHandler
from xml.sax import make_parser
from string import strip
from libpodcasts import podcastChannel
from libpodcasts import podcastItem
class rssErrorHandler( ErrorHandler):
def __init__( self):
None
def error( self, exception):
print exception
def fatalError( self, exception):
print "FATAL ERROR: ", exception
def warning( self, exception):
print "warning: ", exception
class rssReader( DefaultHandler):
channel_url = ""
channel = None
@ -30,7 +44,9 @@ class rssReader( DefaultHandler):
def parseXML( self, url, filename):
self.channel_url = url
parser = make_parser()
parser.returns_unicode = True
parser.setContentHandler( self)
parser.setErrorHandler( rssErrorHandler())
parser.parse( filename)
def startElement( self, name, attrs):