def create_or_update_user(params, username):
    try:
        user = User.objects.get(username__exact=username)
        for key, value in iter(params.items()):
            setattr(user, key, value)
    except __HOLE__ as e:
        log.debug(e)
        log.debug('Try to save user with params: {}'.format(params))
        user = User(**params)
    user.save()
    return user
dataset/ETHPy150Open 2gis/badger-api/authentication/backend.py/create_or_update_user