def _transform_messages_base64(messages, transform, key=None):
 for message in messages:
  if (key is not None):
   message = message[key]
  if ('data' in message):
   message['data'] = transform(message['data'])

def _transform_messages_base64 ( messages , transform , key = None ) : for message in messages : if ( key is not None ) : message = message [ key ] if ( 'data' in message ) : message [ 'data' ] = transform ( message [ 'data' ] )
helper for base64 encoding and decoding messages .