In [5]:
from Movie import *
def read_data_movies(dname):
# Let us process data in movies.dat
with open(dname+"/movies.dat") as f:
lines = f.read().splitlines()
movies = {}
for line in lines:
mid, title, country, year = line.split(":")
m = Movie(mid, title, country, year)
movies[mid] = m
return movies
In [6]:
movies = read_data_movies("small-data")
for mid in movies:
print(movies[mid])
[m1,Star Wars,USA,1978] [m2,Gandhi,UK,1982] [m3,Ran,Japan,1972]
In [7]:
from Theater import *
def read_data_theaters(dname):
# Let us process data in theaters.dat
with open(dname+"/theaters.dat") as f:
lines = f.read().splitlines()
theaters = {}
for line in lines:
tid, tname, city = line.split(":")
t = Theater(tid, tname, city)
theaters[tid] = t
return theaters
In [8]:
theaters = read_data_theaters("small-data")
for tid in theaters:
print(theaters[tid])
[t1,Odeon,Atlanta] [t2,Multiplex I,Doraville]
In [9]:
from Screen import *
def read_data_screens(dname,theaters):
# Let us process data in screens.dat
with open(dname+"/screens.dat") as f:
lines = f.read().splitlines()
for line in lines:
tid, sid, sname = line.split(":")
t = theaters[tid]
scr = Screen(sid,sname,t)
scr.theater = t
t.screens.append(scr)
In [13]:
read_data_screens("small-data",theaters)
for t in theaters:
print(str(theaters[t]))
[t1,Odeon,Atlanta] [t2,Multiplex I,Doraville]