def find_by_name(name):
    try:
        parts = re.split(r'\s+', name.strip())
    except:
        return None
    if len(parts) < 2:
        return None
    users = User.find(
        reduce(
            lambda acc, value: acc & value,
            [
                Q('fullname', 'icontains', part.decode('utf-8', 'ignore'))
                for part in parts
            ]
        )
    ).sort('-date_created')
    if not users:
        return None
    if len(users) > 1:
        logger.warn('Multiple users found for name {}'.format(name))
    return users[0]
dataset/ETHPy150Open CenterForOpenScience/osf.io/scripts/annotate_rsvps.py/find_by_name/original