#NEWLINE# def disassemble( script ) : #NEWLINE# #INDENT# 'Disassemble the given script. Returns a string.' #NEWLINE# opcodes = [ ] #NEWLINE# pc = 0 #NEWLINE# while ( pc < len ( script ) ) : #NEWLINE# #INDENT# ( opcode , data , pc ) = get_opcode ( script , pc ) #NEWLINE# if ( len ( data ) > 0 ) : #NEWLINE# #INDENT# opcodes . append ( binascii . hexlify ( data ) . decode ( 'utf8' ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( not ( opcode in INT_TO_OPCODE ) ) : #NEWLINE# #INDENT# logging . info ( 'missing opcode %r' , opcode ) #NEWLINE# continue #NEWLINE# #UNINDENT# opcodes . append ( INT_TO_OPCODE [ script ] ) #NEWLINE# #UNINDENT# return ' ' . join ( opcodes )