<s> """<STR_LIT>""" <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> import warnings <EOL> from cStringIO import StringIO <EOL> from email . feedparser import FeedParser <EOL> from email . message import Message <EOL> class Parser : <EOL> def __init__ ( self , * args , ** kws ) : <EOL> """<STR_LIT>""" <EOL> if len ( args ) >= <NUM_LIT:1> : <EOL> if '<STR_LIT>' in kws : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> kws [ '<STR_LIT>' ] = args [ <NUM_LIT:0> ] <EOL> if len ( args ) == <NUM_LIT:2> : <EOL> if '<STR_LIT:strict>' in kws : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> kws [ '<STR_LIT:strict>' ] = args [ <NUM_LIT:1> ] <EOL> if len ( args ) > <NUM_LIT:2> : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in kws : <EOL> self . _class = kws [ '<STR_LIT>' ] <EOL> del kws [ '<STR_LIT>' ] <EOL> else : <EOL> self . _class = Message <EOL> if '<STR_LIT:strict>' in kws : <EOL> warnings . warn ( "<STR_LIT>" , <EOL> DeprecationWarning , <NUM_LIT:2> ) <EOL> del kws [ '<STR_LIT:strict>' ] <EOL> if kws : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> def parse ( self , fp , headersonly = False ) : <EOL> """<STR_LIT>""" <EOL> feedparser = FeedParser ( self . _class ) <EOL> if headersonly : <EOL> feedparser . _set_headersonly ( ) <EOL> while True : <EOL> data = fp . read ( <NUM_LIT> ) <EOL> if not data : <EOL> break <EOL> feedparser . feed ( data ) <EOL> return feedparser . close ( ) <EOL> def parsestr ( self , text , headersonly = False ) : <EOL> """<STR_LIT>""" <EOL> return self . parse ( StringIO ( text ) , headersonly = headersonly ) <EOL> class HeaderParser ( Parser ) : <EOL> def parse ( self , fp , headersonly = True ) : <EOL> return Parser . parse ( self , fp , True ) <EOL> def parsestr ( self , text , headersonly = True ) : <EOL> return Parser . parsestr ( self , text , True ) </s>
