From dc902942803d9f966639c9665cfefb0a9b7c65db Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Mon, 5 Jul 2010 11:15:54 +0200 Subject: Now pyAggr3g470r only works with Python 2.7. OrderedDict are used in order to sort the feeds alphabetically in a simple way. --- utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index b3c464bb..1c699b34 100755 --- a/utils.py +++ b/utils.py @@ -4,8 +4,8 @@ from __future__ import with_statement __author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.7 $" -__date__ = "$Date: 2010/06/10 $" +__version__ = "$Revision: 0.8 $" +__date__ = "$Date: 2010/07/05 $" __copyright__ = "Copyright (c) 2010 Cedric Bonhomme" __license__ = "GPLv3" @@ -31,6 +31,7 @@ from BeautifulSoup import BeautifulSoup from datetime import datetime from string import punctuation from collections import defaultdict +from collections import OrderedDict from StringIO import StringIO @@ -279,10 +280,11 @@ def load_feed(): # article_language, like) # feeds[feed_id] = (nb_article, nb_article_unreaded, feed_image, # feed_title, feed_link, feed_site_link, mail) - articles, feeds = {}, {} + articles, feeds = {}, OrderedDict() if list_of_feeds != []: sha1_hash = hashlib.sha1() - for feed in list_of_feeds: + print sorted(list_of_feeds) + for feed in sorted(list_of_feeds): list_of_articles = c.execute(\ "SELECT * FROM articles WHERE feed_link='" + \ feed[2] + "'").fetchall() @@ -322,6 +324,7 @@ def load_feed(): if article[5]=="0"]), \ feed[3], feed[0], feed[2], feed[1] , feed[4]\ ) + c.close() LOCKER.release() return (articles, feeds) -- cgit