1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import string
22
23 from Line import *
24
26 """
27 The Sub class, is the class that handles each subtitle
28 individually
29 """
30
32 """
33 Init all the variables
34 """
35 self.lines = []
36
37
38 self.nLines = 1
39 self.start_time=None
40 self.start_frame=0
41 self.end_time=None
42 self.end_frame=0
43 self.number=None
44 self._processText(text)
45
47 """
48 Is it time to display a subtitle?
49 """
50 if( (time>=self.start_time) and (time<=self.end_time) ):
51 return 1
52 else:
53 return 0
54
55 - def _processText(self,text):
56 """
57 We should parse the full text of a subtitle and divide it
58 line by line.
59 Another getSub method exists to retrieve the full text
60 """
61 lines = text.splitlines(True)
62 self.nLines = len(lines)
63 for i in xrange(0, len(lines)):
64 self.lines.append( Line(lines[i]) )
65 return
66
67 - def getSubText(self):
68 """
69 Retrieve the full subtitle text.
70 The data model is yet to be defined.
71 """
72 fullText = ''
73 for i in range(0, self.nLines):
74 fullText += self.lines[i].text
75 return fullText
76
77 - def setSubText(self, text):
78 """
79 Set the subtitle text and this method will rearrange the
80 structure of lines as well as all other attributes.
81 """
82 pass
83