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