def find(user_id=None,
         username=None,
         email=None,
         rank=None,
         lan=None,
         expand_rank=False,
         sorted_by='username',
         sort_ascending=True,
         only_one=False,
         my_rank=None,
         my_id=None):
    """
    Returns a list of users or a single user, if user_id or only_one are specified.

    user_id: a single user identifier (a string or an ObjectId) or a list of them
    username: the unique user's name
    sort_ascending: if True, sorts the results from first to last, if False sorts them the other way
    only_one: if True, returns one tag at most
    
    """
    def denormalize(user):
        if user is None:
            return user

        if expand_rank:
            user['rank_name'] = { x['rank'] : x['name'] for x in model.ranks.find() }[user['rank']]

        # Data we want to show to our Soft Eng or the private user
        if isinstance(my_rank, int) and my_rank <= 70:
            return user

        # Data we want to show to our private user
        if str(my_id) == str(user["_id"]):
            return user

        # Data we want to show after sign in, to all
        user_to_show = {
            "_id" : user.get("_id", None),
            "rank": user.get("rank", None),
            "description": user.get("description", ""),
            "image": user.get("image", ""),
            "location": user.get("location", ""),
            "name": user.get("name", ""),
            "username": user.get("username", ""),
            "web": user.get("web", "")
        }
        return user_to_show

    if username:
        if is_iterable(username):
            list_users = list(db.users.find({"username" : {"$in": list(username)}}))
            return [ denormalize(u) for u in list_users ]
        else:
            regex = re.compile('^'+username+'$', re.IGNORECASE)
            return denormalize(db.users.find_one({"username" : regex}))


    # First, builds the filter conditions list
    conditions = []

    if email:
        email = email.lower()
        conditions.append({'email': email})

    if rank:
        conditions.append({'rank': rank})

    if lan:
        conditions.append({'lan': lan})

    return db_engine(collection=db.users, 
                     item_id=user_id,
                     only_one=only_one, 
                     conditions=conditions,
                     sorted_by=sorted_by,
                     sort_ascending=sort_ascending,
                     denormalize=denormalize)
dataset/ETHPy150Open Opentaste/bombolone/bombolone/model/users.py/find/original