def encode_table(pieces, table):
 table = (table or {})
 length_index = len(pieces)
 pieces.append(None)
 tablesize = 0
 for (key, value) in table.items():
  tablesize += encode_short_string(pieces, key)
  tablesize += encode_value(pieces, value)
 pieces[length_index] = struct.pack('>I', tablesize)
 return (tablesize + 4)

def encode_table ( pieces , table ) : table = ( table or { } ) length_index = len ( pieces ) pieces . append ( None ) tablesize = 0 for ( key , value ) in table . items ( ) : tablesize += encode_short_string ( pieces , key ) tablesize += encode_value ( pieces , value ) pieces [ length_index ] = struct . pack ( '>I' , tablesize ) return ( tablesize + 4 )
encode a dict as an amqp table appending the encded table to the pieces list passed in .