# -*- coding: iso-8859-1 -*- # Copyright 20003 - 2008: Julien Bourdaillet (julien.bourdaillet@lip6.fr), Jean-Gabriel Ganascia (jean-gabriel.ganascia@lip6.fr) # This file is part of MEDITE. # # MEDITE is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # MEDITE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Foobar; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class bloc : """représente un bloc de texte Les attributs sont publics, il n'y a pas d'accesseurs ni de mutateurs : attention a ne pas modifier les champs utilisations : bloc(val,posd,posF,index) pour les listes de blocs du texte bloc(val,index) pour les listes A et B (1.(a), 1.(b) ) """ def __init__(self,val,posD=None,posF=None,index=None): """Constructeur """ self.val = val #le hash du bloc, ou la lettre si c'est un caractere self.debut = posD #la position de début du bloc dans le texte self.fin = posF #la position de fin du bloc dans le texte +1 (ainsi txt[debut:fin] renvoie le texte du bloc) self.index = index #la position du bloc dans la liste de blocs def __repr__ (self): """Pour l'affichage """ ret ="" if self.index != None: ret += str(self.index) + " > " ret += str(self.val) if self.debut != None : ret += " ["+str(self.debut) if self.fin != None : ret += ":"+str(self.fin) ret += "]" return ret def __call__(self,val,posD=None,posF=None,index=None): """Crée une nouvelle instance.""" return bloc(val,posD,posF,index)