Ejemplo n.º 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
Ejemplo n.º 2
0
def get_director_names(repo: AbstractRepository):
    directors = repo.get_directors()
    director_names = [director.director_name for director in directors]

    return director_names