#NEWLINE# def _reconstruct( x , info , deep , memo = None ) : #NEWLINE# #INDENT# if isinstance ( info , str ) : #NEWLINE# #INDENT# return x #NEWLINE# #UNINDENT# assert isinstance ( info , tuple ) #NEWLINE# if ( memo is None ) : #NEWLINE# #INDENT# memo = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# n = len ( info ) #NEWLINE# assert ( n in ( 2 , 3 , 4 , 5 ) ) #NEWLINE# ( callable , args ) = info [ : 2 ] #NEWLINE# if ( n > 2 ) : #NEWLINE# #INDENT# state = info [ 2 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# state = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( n > 3 ) : #NEWLINE# #INDENT# listiter = info [ 3 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# listiter = None #NEWLINE# #UNINDENT# if ( n > 4 ) : #NEWLINE# #INDENT# dictiter = info [ 4 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dictiter = None #NEWLINE# #UNINDENT# if deep : #NEWLINE# #INDENT# args = deepcopy ( args , memo ) #NEWLINE# #UNINDENT# y = callable ( * args ) #NEWLINE# memo [ id ( x ) ] = y #NEWLINE# if state : #NEWLINE# #INDENT# if deep : #NEWLINE# #INDENT# state = deepcopy ( state , memo ) #NEWLINE# #UNINDENT# if hasattr ( y , '__setstate__' ) : #NEWLINE# #INDENT# y . __setstate__ ( state ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( state , tuple ) and ( len ( state ) == 2 ) ) : #NEWLINE# #INDENT# ( state , slotstate ) = state #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# slotstate = None #NEWLINE# #UNINDENT# if ( state is not None ) : #NEWLINE# #INDENT# y . __dict__ . update ( state ) #NEWLINE# #UNINDENT# if ( slotstate is not None ) : #NEWLINE# #INDENT# for ( key , value ) in slotstate . items ( ) : #NEWLINE# #INDENT# setattr ( y , key , value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( listiter is not None ) : #NEWLINE# #INDENT# for item in listiter : #NEWLINE# #INDENT# if deep : #NEWLINE# #INDENT# item = deepcopy ( item , memo ) #NEWLINE# #UNINDENT# y . append ( item ) #NEWLINE# #UNINDENT# #UNINDENT# if ( dictiter is not None ) : #NEWLINE# #INDENT# for ( key , value ) in dictiter : #NEWLINE# #INDENT# if deep : #NEWLINE# #INDENT# key = deepcopy ( key , memo ) #NEWLINE# value = deepcopy ( value , memo ) #NEWLINE# #UNINDENT# y [ key ] = value #NEWLINE# #UNINDENT# #UNINDENT# return y