def save_admin_log(build, **kwargs):
    """Saves an action to the admin log."""
    message = kwargs.pop('message', None)
    release = kwargs.pop('release', None)
    run = kwargs.pop('run', None)

    if not len(kwargs) == 1:
        raise TypeError('Must specify a LOG_TYPE argument')

    log_enum = kwargs.keys()[0]
    log_type = getattr(models.AdminLog, log_enum.upper(), None)
    if not log_type:
        raise TypeError(log_enum % 'Bad log_type argument: %s')

    if current_user.is_anonymous():
        user_id = None
    else:
        user_id = current_user.get_id()

    log = models.AdminLog(
        build_id=build.id,
        log_type=log_type,
        message=message,
        user_id=user_id)

    if release:
        log.release_id = release.id

    if run:
        log.run_id = run.id
        log.release_id = run.release_id

    db.session.add(log)
dataset/ETHPy150Open bslatkin/dpxdt/dpxdt/server/auth.py/save_admin_log/swapped operands of `%`