-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.py
76 lines (72 loc) · 2.08 KB
/
storage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import bsddb3
import pickle
import movie_pb2
db = bsddb3.hashopen('movies.db','c')
for key in db.keys():
#print key
movie = movie_pb2.Movie();
movie = pickle.loads(db[key])
print movie.name
temp = ""
for actor in movie.actors:
temp += actor + ","
print "Actors: " + temp
temp = ""
for director in movie.directors:
temp += director + ","
print "Directors: " + temp
temp = "Genres: " ;
for genre in movie.genres :
if genre == movie_pb2.ADVENTURE :
temp += "Adventure, "
elif genre == movie_pb2.SCI_FI :
temp += "Sci_fi, "
elif genre == movie_pb2.DRAMA :
temp += "Drama, "
print temp
temp = "Languages: " ;
for language in movie.languages :
temp += language + ", "
print temp
print "Run time: " + str(movie.runTime)
if movie.productionHouse != "" :
print "Production House: " + movie.productionHouse
if movie.country != "" :
print "Country: " + movie.country
temp = "Release Date: " + str(movie.releaseDate.day) + "/"
mon = movie.releaseDate.month ;
if mon == movie_pb2.JANUARY:
temp += "01"
elif mon == movie_pb2.FEBRUARY:
temp += "02"
elif mon == movie_pb2.MARCH:
temp += "03"
elif mon == movie_pb2.APRIL:
temp += "04"
elif mon == movie_pb2.MAY:
temp += "05"
elif mon == movie_pb2.JUNE:
temp += "06"
elif mon == movie_pb2.JULY:
temp += "07"
elif mon == movie_pb2.AUGUST:
temp += "08"
elif mon == movie_pb2.SEPTEMBER:
temp += "09"
elif mon == movie_pb2.OCTOBER:
temp += "10"
elif mon == movie_pb2.NOVEMBER:
temp += "11"
elif mon == movie_pb2.DECEMBER:
temp += "12"
temp += "/" + str(movie.releaseDate.year)
print temp
print "Reviews: "
flag = True
for review in movie.reviews :
flag = False
print "User: " + review.userName
print "Rating: " +str(review.rating)
print "Comment: " + review.comment + "\n"
if flag:
print "None to show\n"