<s> from urllib import urlopen <EOL> from pyth . plugins . rtf15 . reader import Rtf15Reader <EOL> from pyth . plugins . xhtml . writer import XHTMLWriter <EOL> from tempfile import TemporaryFile <EOL> import sys , traceback , logging <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> def rtf ( url ) : <EOL> '''<STR_LIT>''' <EOL> remote = urlopen ( url ) <EOL> data = remote . read ( ) <EOL> remote . close ( ) <EOL> temp = TemporaryFile ( ) <EOL> temp . write ( data ) <EOL> temp . seek ( <NUM_LIT:0> ) <EOL> try : <EOL> doc = Rtf15Reader . read ( temp , errors = '<STR_LIT:ignore>' ) <EOL> xhtml = XHTMLWriter . write ( doc , pretty = True ) . read ( ) <EOL> except : <EOL> xhtml = False <EOL> exceptionType , exceptionValue , exceptionTraceback = sys . exc_info ( ) <EOL> logger . warn ( '<STR_LIT>' . join ( traceback . format_exception ( exceptionType , exceptionValue , exceptionTraceback ) ) ) <EOL> temp . close ( ) <EOL> return xhtml </s>
