コード例 #1
0
def search(search_text, repo: AbstractRepository):
    result_dict = {}
    search_text = search_text.strip().lower()
    count = 0
    #find related movie
    for movie in repo.get_movies():
        if search_text in movie.title.lower():
            count += 1
            if "Movie" not in result_dict:
                result_dict["Movie"] = [movie]
            else:
                result_dict["Movie"].append(movie)
    #find related actor
    for actor in repo.get_actors():
        if search_text in actor.actor_full_name.lower():
            count += 1
            if "Actor" not in result_dict:
                result_dict["Actor"] = [actor]
            else:
                result_dict["Actor"].append(actor)
    #find related director
    for director in repo.get_directors():
        if search_text in director.director_full_name.lower():
            count += 1
            if "Director" not in result_dict:
                result_dict["Director"] = [director]
            else:
                result_dict["Director"].append(director)
    return result_dict, count
コード例 #2
0
ファイル: services.py プロジェクト: clintonmuldoon/Movieapp
def get_actor_names(repo: AbstractRepository):
    actors = repo.get_actors()
    actor_names = [actor.actor_name for actor in actors]

    return actor_names