From a01ba77a8ecde766ebb0568b086dd6709453b684 Mon Sep 17 00:00:00 2001 From: Olivier Iffrig Date: Tue, 18 Mar 2014 10:54:13 +0100 Subject: [PATCH] [whos] Reformatage de la fonction d'affichage de l'historique --- gestion/whos.py | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/gestion/whos.py b/gestion/whos.py index 822f47e4..88b93cda 100755 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -930,33 +930,33 @@ def _info(clas) : f += u'\n' return f -def _hist(clas) : +def _hist(clas): """ Formatage de l'historique de la classe fournie """ - if limit_aff_historique==0 : return '' - f=u'' + if limit_aff_historique == 0: + return u'' + f = u'' h = clas.historique() - h.reverse() - if h : - f += coul(u'Historique : ','gras') - for i in xrange(0,limit_aff_historique) : - try : - a = h[i] # Produit une erreur si i trop grand - if i !=0 : f += ' ' - try: - # on force l'encodage ici sinon il est fait au moment de l'impression a - # l'ecran et il empeche l'affichage de toutes les infos - f += u'%s\n' % a - except Exception, e: - if debug: - f += coul(u'*** non affichable [%s] ***\n' % str(e), 'rouge') - else: - f += coul(u'*** non affichable ***\n', 'rouge') - except : - break - try : - if h[i+1] : f += ' [...]\n' - except : - None + if h: + f += coul(u'Historique : ', 'gras') + notfirst = False + lim = - (limit_aff_historique + 1) + for a in h[:lim:-1]: # les `limit_aff_historique` (au plus) derniers éléments, en partant du dernier + if notfirst: + f += u' ' + else: + notfirst = True + try: + # TODO: clarifier ça, a priori `a` c'est déjà un unicode + # on force l'encodage ici sinon il est fait au moment de l'impression a + # l'ecran et il empeche l'affichage de toutes les infos + f += u'%s\n' % a + except Exception, e: + if debug: + f += coul(u'*** non affichable [%s] ***\n' % str(e), 'rouge') + else: + f += coul(u'*** non affichable ***\n', 'rouge') + if len(h) > limit_aff_historique: + f += u' [...]\n' return f