<commit_before># coding=utf-8

# Local Modules
from common import debug, text_utils, database
from user import bibleuser_classes


# Functions for manipulation of user info
def get_user(userId):
    return database.retrieve("BibleUser", text_utils.stringify(userId))


def get_uid(userIdObj):
    try:
        userId = userIdObj.get_uid()
    except AttributeError:
        userId = userIdObj

    return userId


def set_profile(userId, uname, fname, lname):
    debug.log("Setting profile of {}", [userId])

    existingUser = get_user(userId)

    uname = text_utils.stringify(uname)
    fname = text_utils.stringify(fname)
    lname = text_utils.stringify(lname)

    if existingUser:
        existingUser.username = uname
        existingUser.firstName = fname
        existingUser.lastName = lname
        existingUser.update_last_received()
        return existingUser
    else:
        userObj = bibleuser_classes.BibleUser(
            key_name=text_utils.stringify(userId),
            username=uname,
            firstName=fname,
            lastName=lname)
        userObj.put()
        return userObj


def get_user_query():
    return bibleuser_classes.BibleUser.all()


def for_each_user(fn):
    debug.log("Running {} for each user", [fn])

    # Read user database
    query = get_user_query()
    query.filter("active =", True)
<commit_msg>adding some debug for user updating<commit_after># coding=utf-8

# Local Modules
from common import debug, text_utils, database
from user import bibleuser_classes


# Functions for manipulation of user info
def get_user(userId):
    return database.retrieve("BibleUser", text_utils.stringify(userId))


def get_uid(userIdObj):
    try:
        userId = userIdObj.get_uid()
    except AttributeError:
        userId = userIdObj

    return userId


def set_profile(userId, uname, fname, lname):
    debug.log("Setting profile of {}", [userId])

    existingUser = get_user(userId)

    uname = text_utils.stringify(uname)
    fname = text_utils.stringify(fname)
    lname = text_utils.stringify(lname)

    if existingUser:
        debug.log("User exists, updating")

        existingUser.username = uname
        existingUser.firstName = fname
        existingUser.lastName = lname
        existingUser.update_last_received()
        return existingUser
    else:
        debug.log("New user!")
        userObj = bibleuser_classes.BibleUser(
            key_name=text_utils.stringify(userId),
            username=uname,
            firstName=fname,
            lastName=lname)
        userObj.put()
        return userObj


def get_user_query():
    return bibleuser_classes.BibleUser.all()


def for_each_user(fn):
    debug.log("Running {} for each user", [fn])

    # Read user database
    query = get_user_query()
    query.filter("active =", True)

{'fraction_non_alphanumeric': 0.09100604337006754, 'fraction_numerical': 0.0007109847138286527, 'mean_word_length': 3.0085470085470085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2192082', 'n_tokens_mistral': 852, 'n_tokens_neox': 850, 'n_words': 194}