#NEWLINE# def read_dynamic( stream , repair = False ) : #NEWLINE# #INDENT# type = ord ( stream . read ( 1 ) ) #NEWLINE# try : #NEWLINE# #INDENT# if ( type == 1 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == 2 ) : #NEWLINE# #INDENT# format = '>d' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == 3 ) : #NEWLINE# #INDENT# format = '?' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == 4 ) : #NEWLINE# #INDENT# return read_varlen_number_signed ( stream ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == 5 ) : #NEWLINE# #INDENT# return read_string ( stream ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == 6 ) : #NEWLINE# #INDENT# return read_list ( stream , repair ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == 7 ) : #NEWLINE# #INDENT# return read_map ( stream , repair ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'Unknown dynamic type 0x%02X' % type ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# if repair : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# return struct . unpack ( format , stream . read ( struct . calcsize ( format ) ) ) [ 0 ]