def set_message(data):
    success = data['success']
    message = ""
    if success:
        if 'message' in data and len(data['message']) == 2:
            hash_map = data['message'][0]
            message_code = data['message'][1]
            data['message'] = getattr(g, hash_map)(message_code)
    else:
        if 'errors' in data and len(data['errors']) > 0:
            error_tuple = data['errors'][0].get('code')
            if error_tuple and len(error_tuple) == 2:
                hash_map = error_tuple[0]
                error_code = error_tuple[1]
                data['errors'][0]['code'] = error_code
                data['errors'][0]['message'] = getattr(g, hash_map)(error_code)
    return data
Compact whitespace in a string.
dataset/ETHPy150Open Opentaste/bombolone/bombolone/core/utils/message.py/set_message--crossover with--dataset/ETHPy150Open xolox/python-humanfriendly/humanfriendly/text.py/compact