

def parse_change_event(change_type, message):
    ' Parses change event. '
    evt = {
        
    }
    values = {
        'user': message['change']['user']['name'],
        'subject': (message['data']['subject'] if ('subject' in list(message['data'].keys())) else message['data']['name']),
    }
    if (change_type in ['description', 'points']):
        event_type = change_type
    elif (change_type in ['milestone', 'assigned_to']):
        (old, new) = get_old_and_new_values(change_type, message)
        if (not old):
            event_type = ('set_' + change_type)
            values['new'] = new
        else:
            event_type = ('changed_' + change_type)
            values.update({
                'old': old,
                'new': new,
            })
    elif (change_type == 'is_blocked'):
        if message['change']['diff']['is_blocked']['to']:
            event_type = 'blocked'
        else:
            event_type = 'unblocked'
    elif (change_type == 'is_closed'):
        if message['change']['diff']['is_closed']['to']:
            event_type = 'closed'
        else:
            event_type = 'reopened'
    elif (change_type == 'user_story'):
        (old, new) = get_old_and_new_values(change_type, message)
        event_type = 'changed_us'
        values.update({
            'old': old,
            'new': new,
        })
    elif (change_type in ['subject', 'name']):
        event_type = 'renamed'
        (old, new) = get_old_and_new_values(change_type, message)
        values.update({
            'old': old,
            'new': new,
        })
    elif (change_type in ['estimated_finish', 'estimated_start']):
        (old, new) = get_old_and_new_values(change_type, message)
        if (not (old == new)):
            event_type = change_type
            values.update({
                'old': old,
                'new': new,
            })
        else:
            return None
    elif (change_type in ['priority', 'severity', 'type', 'status']):
        event_type = ('changed_' + change_type)
        (old, new) = get_old_and_new_values(change_type, message)
        values.update({
            'old': old,
            'new': new,
        })
    else:
        return None
    evt.update({
        'type': message['type'],
        'event': event_type,
        'values': values,
    })
    return evt

dataset/ETHPy150Open zulip/zulip/zerver/views/webhooks/taiga.py parse_change_event/original