aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2010-04-16 21:10:11 +0200
committercedricbonhomme <devnull@localhost>2010-04-16 21:10:11 +0200
commit3a6dfd358ded4c26998c86e2a76d34f337c237f8 (patch)
tree185fc1934728685141a6a90b677565eafffe6c41 /utils.py
parentAdded tags cloud. (diff)
downloadnewspipe-3a6dfd358ded4c26998c86e2a76d34f337c237f8.tar.gz
newspipe-3a6dfd358ded4c26998c86e2a76d34f337c237f8.tar.bz2
newspipe-3a6dfd358ded4c26998c86e2a76d34f337c237f8.zip
Minor enhancement.
Diffstat (limited to 'utils.py')
-rwxr-xr-xutils.py8
1 files 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([('<font size="%d"><a href="/q/?querystring=%s">%s</a></font>' % \
- (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([('<font size="%d"><a href="/q/?querystring=%s">%s</a></font>\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"):
"""
bgstack15