eit.py

changeset 17
842120f00078
parent 9
1bf778001041
equal deleted inserted replaced
16:ace8005f02cf 17:842120f00078
144 """ 144 """
145 def __init__(self, path=None): 145 def __init__(self, path=None):
146 self.eit_file = None 146 self.eit_file = None
147 147
148 self.eit = {} 148 self.eit = {}
149 self.iso = None 149 #self.iso = None
150 150
151 self.load(path) 151 self.load(path)
152 152
153 def load(self, path): 153 def load(self, path):
154 self.eit = {}
155 self.eit_file = None
154 if path: 156 if path:
155 self.eit_file = path 157 self.eit_file = path
156 self._read_file() 158 self._read_file()
157 159
158 def get_genre(self): 160 def get_genre(self):
186 return mkint(length) 188 return mkint(length)
187 189
188 def get_date(self): 190 def get_date(self):
189 return todate(self.get_startdate(), self.get_starttime()) 191 return todate(self.get_startdate(), self.get_starttime())
190 192
191 def dumpEit(self): 193 def dump(self):
192 print self.eit 194 """Module docstring.
195 Read Eit File and show the information.
196 """
197 if len(self.eit) == 0:
198 return None
199 out = "Movie name: %s" % self.get_name()
200 out += "\nGenre: %s" % self.get_genre()
201 out += "\nComponents: %s" % self.get_components()
202 out += "\nStartDate: %s" % self.get_date()
203 out += "\nDescription: %s" % self.get_description()
204 out += "\nDuration: %02i:%02i:%02i" % self.get_duration()
205 out += " (%s minutes)" % (self.get_duration_seconds() / 60)
206
207 print out
208 return out
193 209
194 ############################################################################## 210 ##############################################################################
195 ## File IO Functions 211 ## File IO Functions
196 def _read_file(self): 212 def _read_file(self):
197 data = "" 213 data = ""
353 else: 369 else:
354 # No data clear all 370 # No data clear all
355 self.eit = {} 371 self.eit = {}
356 372
357 373
358 def readeit(eitfile):
359 """Module docstring.
360 Read Eit File and show the information.
361 """
362 eitlist = eitinfo(eitfile)
363 if len(eitlist.eit) == 0:
364 return None
365 out = "Movie name: %s" % eitlist.get_name()
366 out += "\nGenre: %s" % eitlist.get_genre()
367 out += "\nComponents: %s" % eitlist.get_components()
368 out += "\nStartDate: %s" % eitlist.get_date()
369 out += "\nDescription: %s" % eitlist.get_description()
370 out += "\nDuration: %02i:%02i:%02i" % eitlist.get_duration()
371 out += " (%s minutes)" % (eitlist.get_duration_seconds() / 60)
372
373 print out
374 return out
375 374
376 def main(): 375 def main():
377 # parse command line options 376 # parse command line options
378 try: 377 try:
379 opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) 378 opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
385 for o, a in opts: 384 for o, a in opts:
386 if o in ("-h", "--help"): 385 if o in ("-h", "--help"):
387 print __doc__ 386 print __doc__
388 sys.exit(0) 387 sys.exit(0)
389 # process arguments 388 # process arguments
389 info = eitinfo()
390 for arg in args: 390 for arg in args:
391 readeit(arg) # process() is defined elsewhere 391 info.load(arg)
392 info.dump()
392 393
393 if __name__ == "__main__": 394 if __name__ == "__main__":
394 main() 395 main()
395 396

mercurial