#NEWLINE# def _add_middleware( self , mw ) : #NEWLINE# #INDENT# if hasattr ( self , 'open_spider' ) : #NEWLINE# #INDENT# self . methods [ 'open_spider' ] . append ( mw . open_spider ) #NEWLINE# #UNINDENT# if hasattr ( mw , 'close_spider' ) : #NEWLINE# #INDENT# self . methods [ 'close_spider' ] . insert ( 0 , mw . close_spider )