<s> """<STR_LIT>""" <EOL> import asyncio <EOL> import logging <EOL> log = logging . getLogger ( __name__ ) <EOL> class GrowlerProtocol ( asyncio . Protocol ) : <EOL> """<STR_LIT>""" <EOL> transport = None <EOL> responders = None <EOL> is_done_transmitting = False <EOL> def __init__ ( self , loop , responder_factory ) : <EOL> self . make_responder = responder_factory <EOL> self . loop = loop if ( loop is not None ) else asyncio . get_event_loop ( ) <EOL> def connection_made ( self , transport ) : <EOL> """<STR_LIT>""" <EOL> self . transport = transport <EOL> self . responders = [ self . make_responder ( self ) ] <EOL> try : <EOL> good_func = callable ( self . responders [ <NUM_LIT:0> ] . on_data ) <EOL> except AttributeError : <EOL> good_func = False <EOL> if not good_func : <EOL> err_str = "<STR_LIT>" <EOL> raise TypeError ( err_str ) <EOL> log_info = ( id ( self ) , self . remote_hostname , self . remote_port ) <EOL> log . info ( "<STR_LIT>" % log_info ) <EOL> def connection_lost ( self , exc ) : <EOL> """<STR_LIT>""" <EOL> if exc : <EOL> log . error ( "<STR_LIT>" % ( id ( self ) , exc ) ) <EOL> else : <EOL> log . info ( "<STR_LIT>" % id ( self ) ) <EOL> def data_received ( self , data ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . responders [ - <NUM_LIT:1> ] . on_data ( data ) <EOL> except Exception as error : <EOL> self . handle_error ( error ) <EOL> def eof_received ( self ) : <EOL> """<STR_LIT>""" <EOL> self . is_done_transmitting = True <EOL> log . info ( "<STR_LIT>" % id ( self ) ) <EOL> def handle_error ( self , error ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> @ property <EOL> def socket ( self ) : <EOL> return self . transport . get_extra_info ( '<STR_LIT>' ) <EOL> @ property <EOL> def cipher ( self ) : <EOL> return self . transport . get_extra_info ( '<STR_LIT>' ) <EOL> @ property <EOL> def remote_hostname ( self ) : <EOL> return self . transport . get_extra_info ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> @ property <EOL> def remote_port ( self ) : <EOL> return self . transport . get_extra_info ( '<STR_LIT>' ) [ <NUM_LIT:1> ] <EOL> @ property <EOL> def peername ( self ) : <EOL> return self . transport . get_extra_info ( '<STR_LIT>' ) <EOL> @ classmethod <EOL> def factory ( cls , * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return cls ( * args , ** kw ) <EOL> @ classmethod <EOL> def get_factory ( cls , * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return lambda : cls . factory ( * args , ** kw ) </s>
