Package Subtitles :: Module Line
[hide private]
[frames] | no frames]

Source Code for Module Subtitles.Line

 1  #!/usr/bin/env python 
 2  # 
 3  #       Line.py 
 4  #        
 5  #       Copyright 2008 Joao Mesquita <jmesquita@gmail.com> 
 6  #        
 7  #       This program is free software; you can redistribute it and/or modify 
 8  #       it under the terms of the GNU General Public License as published by 
 9  #       the Free Software Foundation; either version 3 of the License, or 
10  #       (at your option) any later version. 
11  #        
12  #       This program is distributed in the hope that it will be useful, 
13  #       but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  #       GNU General Public License for more details. 
16  #        
17  #       You should have received a copy of the GNU General Public License 
18  #       along with this program; if not, write to the Free Software 
19  #       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
20  #       MA 02110-1301, USA. 
21   
22   
23 -class Line:
24 """ 25 Each line of a subtile will have its own class to control 26 the number of characters and other features 27 """
28 - def __init__(self, text):
29 """ 30 Each line has its own text 31 """ 32 self.text = text 33 self.length = self._count(text)
34
35 - def _count(self, text):
36 """ 37 We have to make our own count 38 function because of pango markups 39 and end of lines. 40 """ 41 t = text.strip('\n') 42 return len(t)
43