From 3a6dfd358ded4c26998c86e2a76d34f337c237f8 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Fri, 16 Apr 2010 21:10:11 +0200 Subject: Minor enhancement. --- utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils.py b/utils.py index 5a262412..aaac0754 100755 --- a/utils.py +++ b/utils.py @@ -16,6 +16,7 @@ except: IMPORT_ERROR.append("pylab") import sqlite3 import hashlib +import operator import smtplib from email.mime.text import MIMEText @@ -97,9 +98,10 @@ def tag_cloud(tags): """ Generates a tags cloud. """ - tags.sort(lambda x,y: cmp(x[0], y[0])) - return ' '.join([('%s' % \ - (min(1+p*7/max([tag[1] for tag in tags]), 7), x, x)) for (x, p) in tags]) + tags.sort(key=operator.itemgetter(0)) + return ' '.join([('%s\n' % \ + (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word, word)) \ + for (word, count) in tags]) def create_histogram(words, file_name="./var/histogram.png"): """ -- cgit