Пример #1
0
    def read_csv_file(self):
        with open(
                self.__file_name, mode='r', encoding='utf-8-sig'
        ) as csvfile:  #i delete "datafiles/"+ before posting to coderunner, if this isnt here then my IDE, vscode, doesnt find it
            movie_file_reader = csv.DictReader(csvfile)

            for row in movie_file_reader:
                if Movie(row['Title'],
                         int(row['Year'])) not in self.__dataset_of_movies:
                    self.__dataset_of_movies.append(
                        Movie(row['Title'], int(row['Year'])))
                #description = row['Description']

                self.__dataset_of_directors.add(Director(row['Director']))
                self.dataset_of_movies[-1].director = Director(row['Director'])
                self.dataset_of_movies[-1].description = row['Description']
                self.dataset_of_movies[-1].runtime = int(
                    row['Runtime (Minutes)'])
                self.dataset_of_movies[-1].rating = float(row['Rating'])

                for g in row['Genre'].split(","):
                    self.__dataset_of_genres.add(Genre(g.strip()))
                    self.dataset_of_movies[-1].add_genre(Genre(g.strip()))

                for a in row['Actors'].split(","):
                    self.__dataset_of_actors.add(Actor(a.strip()))
                    self.dataset_of_movies[-1].add_actor(Actor(a.strip()))
Пример #2
0
 def testGenres(self):
     print("Genre testing:")
     movie1 = Movie("Moana", 2016)
     movie1.add_genre(Genre("Cheesy"))
     movie1.add_genre(Genre("Action"))
     movie1.remove_genre(Genre("Cheesy"))
     print(movie1.genres)
Пример #3
0
 def testInit(self):
     genre1 = Genre("Horror")
     print(genre1.genre_name == "Horror")
     genre2 = Genre("")
     print(genre2.genre_name == None)
     genre3 = Genre(42)
     print(genre3.genre_name == None)
Пример #4
0
 def testEq(self):
     print("= Testing:")
     genre1 = Genre("Horror")
     genre2 = Genre("Comedy")
     genre3 = Genre("HORROR")
     print((genre1 == genre2) is False)
     print((genre1 == genre3) is True)
Пример #5
0
def genre():
    return Genre()
Пример #6
0
 def testLt(self):
     print("< Testing:")
     genre1 = Genre("Action")
     genre2 = Genre("Horror")
     print((genre1 < genre2) is True)
     print((genre2 < genre1) is False)
Пример #7
0
 def testRepr(self):
     genre1 = Genre("Horror")
     genre2 = Genre("Comedy")
     print(genre1)
     print("The genre is "+ genre2.genre_name)