Package medite :: Package MediteAppli :: Module blocTexte
[hide private]
[frames] | no frames]

Source Code for Module medite.MediteAppli.blocTexte

 1  # -*- coding: iso-8859-1 -*- 
 2  # Copyright 20003 - 2008: Julien Bourdaillet (julien.bourdaillet@lip6.fr), Jean-Gabriel Ganascia (jean-gabriel.ganascia@lip6.fr) 
 3  # This file is part of MEDITE. 
 4  # 
 5  #    MEDITE is free software; you can redistribute it and/or modify 
 6  #    it under the terms of the GNU General Public License as published by 
 7  #    the Free Software Foundation; either version 2 of the License, or 
 8  #    (at your option) any later version. 
 9  # 
10  #    MEDITE is distributed in the hope that it will be useful, 
11  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  #    GNU General Public License for more details. 
14  # 
15  #    You should have received a copy of the GNU General Public License 
16  #    along with Foobar; if not, write to the Free Software 
17  #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
18   
19   
20 -class bloc :
21 """représente un bloc de texte 22 23 Les attributs sont publics, il n'y a pas d'accesseurs ni de mutateurs : attention a ne pas modifier les champs 24 utilisations : bloc(val,posd,posF,index) pour les listes de blocs du texte 25 bloc(val,index) pour les listes A et B (1.(a), 1.(b) ) 26 """ 27
28 - def __init__(self,val,posD=None,posF=None,index=None):
29 """Constructeur 30 """ 31 self.val = val #le hash du bloc, ou la lettre si c'est un caractere 32 self.debut = posD #la position de début du bloc dans le texte 33 self.fin = posF #la position de fin du bloc dans le texte +1 (ainsi txt[debut:fin] renvoie le texte du bloc) 34 self.index = index #la position du bloc dans la liste de blocs
35
36 - def __repr__ (self):
37 """Pour l'affichage 38 """ 39 ret ="" 40 if self.index != None: 41 ret += str(self.index) + " > " 42 ret += str(self.val) 43 if self.debut != None : 44 ret += " ["+str(self.debut) 45 if self.fin != None : 46 ret += ":"+str(self.fin) 47 ret += "]" 48 return ret
49
50 - def __call__(self,val,posD=None,posF=None,index=None):
51 """Crée une nouvelle instance.""" 52 return bloc(val,posD,posF,index)
53