def reset(self): """ init internal data here Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text """ self.layer = 0 self.start = AssTime() self.end = AssTime() self.style = "" self.name = "" self.marginl = 0 self.marginr = 0 self.marginv = 0 self.effect = "" self.text = AssText()
def reset(self): """ init internal data here Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text """ self.layer = 0 self.start = AssTime() self.end = AssTime() self.style = '' self.name = '' self.marginl = 0 self.marginr = 0 self.marginv = 0 self.effect = '' self.text = AssText()
class AssEntryDialogue(AssEntry): """ AssDialogue类 实现[Events] Section中的Dialogue项目存储和操作 """ def __init__(self, data, section, version): AssEntry.__init__(self, data, section) self.type = ENTRY_DIALOGUE self.reset() self.comment = False self.need_update = False self.parse(self.data, version) def reset(self): """ init internal data here Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text """ self.layer = 0 self.start = AssTime() self.end = AssTime() self.style = "" self.name = "" self.marginl = 0 self.marginr = 0 self.marginv = 0 self.effect = "" self.text = AssText() # self.layer, self.start, self.end, self.style, self.name, self.marginl, self.marginr, self.marginv, self.effect, self.text def get_type(self): return ENTRY_DIALOGUE def parse(self, line, version): try: event_list = line.split(":", 1) if event_list[0].lower() == "dialogue": self.comment = False elif event_list[0].lower() == "comment": self.comment = True else: # self.reset() raise InvaildDataError("Invaild Data <%s>" % (line)) return event_list = event_list[1].split(",", 9) i = 0 if version == 0 or event_list[i].strip().startswith("marked"): self.layer = 0 else: self.layer = int(event_list[i]) # 0 i += 1 self.start.set(event_list[i].strip()) # 1 i += 1 self.end.set(event_list[i].strip()) # 2 i += 1 self.style = event_list[i].strip() # 3 i += 1 self.name = event_list[i].strip() # 4 i += 1 self.marginl = int(event_list[i]) # 5 i += 1 self.marginr = int(event_list[i]) # 6 i += 1 self.marginv = int(event_list[i]) # 7 i += 1 self.effect = event_list[i].strip() # 8 i += 1 self.text.set(event_list[i]) # 9 except IndexError, msg: print IndexError, ":", msg else:
class AssEntryDialogue(AssEntry): """ AssDialogue类 实现[Events] Section中的Dialogue项目存储和操作 """ def __init__(self, data, section, version): AssEntry.__init__(self, data, section) self.type = ENTRY_DIALOGUE self.reset() self.comment = False self.need_update = False self.parse(self.data, version) def reset(self): """ init internal data here Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text """ self.layer = 0 self.start = AssTime() self.end = AssTime() self.style = '' self.name = '' self.marginl = 0 self.marginr = 0 self.marginv = 0 self.effect = '' self.text = AssText() #self.layer, self.start, self.end, self.style, self.name, self.marginl, self.marginr, self.marginv, self.effect, self.text def get_type(self): return ENTRY_DIALOGUE def parse(self, line, version): try: event_list = line.split(':', 1) if event_list[0].lower() == 'dialogue': self.comment = False elif event_list[0].lower() == 'comment': self.comment = True else: #self.reset() raise InvaildDataError('Invaild Data <%s>' % (line)) return event_list = event_list[1].split(',', 9) i = 0 if version == 0 or event_list[i].strip().startswith('marked'): self.layer = 0 else: self.layer = int(event_list[i]) #0 i += 1 self.start.set(event_list[i].strip()) #1 i += 1 self.end.set(event_list[i].strip()) #2 i += 1 self.style = event_list[i].strip() #3 i += 1 self.name = event_list[i].strip() #4 i += 1 self.marginl = int(event_list[i]) #5 i += 1 self.marginr = int(event_list[i]) #6 i += 1 self.marginv = int(event_list[i]) #7 i += 1 self.effect = event_list[i].strip() #8 i += 1 self.text.set(event_list[i]) #9 except IndexError, msg: print IndexError, ':', msg else: