From 587e2a1df1f89879552f510253fd7c91061b99cc Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 2 Feb 2010 22:19:42 +0100 Subject: Release 0.5. Added : a link _Fetch all feeds_ manually (when you want, without cron). Improvements of the navigation. --- feedgetter.py | 17 ++++++++--------- pyAggr3g470r.py | 31 +++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/feedgetter.py b/feedgetter.py index 8316a200..a16585d8 100644 --- a/feedgetter.py +++ b/feedgetter.py @@ -2,8 +2,8 @@ #-*- coding: utf-8 -*- __author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.4 $" -__date__ = "$Date: 2010/02/01 $" +__version__ = "$Revision: 0.5 $" +__date__ = "$Date: 2010/02/02 $" __copyright__ = "Copyright (c) 2010 Cedric Bonhomme" __license__ = "GPLv3" @@ -33,6 +33,11 @@ class FeedGetter(object): """ Initializes the base and variables. """ + try: + self.feeds_file = open("./var/feed.lst") + except: + print "./feed.lst not found" + exit(0) # Create the base if not exists. self.conn = sqlite3.connect("./var/feed.db", isolation_level = None) self.c = self.conn.cursor() @@ -50,7 +55,7 @@ class FeedGetter(object): """ Parse the file 'feeds.lst' and launch a thread for each RSS feed. """ - for a_feed in feeds_file.readlines(): + for a_feed in self.feeds_file.readlines(): # test if the URL is well formed for url_regexp in url_finders: if url_regexp.match(a_feed): @@ -118,11 +123,5 @@ class FeedGetter(object): if __name__ == "__main__": # Point of entry in execution mode - try: - feeds_file = open("./var/feed.lst") - except: - print "./feed.lst not found" - exit(0) - feed_getter = FeedGetter() feed_getter.retrieve_feed() \ No newline at end of file diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index f91ac258..fe2ad47b 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -2,8 +2,8 @@ #-*- coding: utf-8 -*- __author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.4 $" -__date__ = "$Date: 2010/02/01 $" +__version__ = "$Revision: 0.5 $" +__date__ = "$Date: 2010/02/02 $" __copyright__ = "Copyright (c) 2010 Cedric Bonhomme" __license__ = "GPLv3" @@ -15,6 +15,8 @@ import ConfigParser from datetime import datetime from cherrypy.lib.static import serve_file +import feedgetter + config = ConfigParser.RawConfigParser() config.read("./cfg/pyAggr3g470r.cfg") path = config.get('global','path') @@ -49,9 +51,10 @@ class Root: html = htmlheader html += htmlnav html += """
\n""" + html += """Fetch all feeds\n
\n""" + html += """Management of feed\n""" html += """
\n""" - html += """Management of feed\n""" html += "
\n" html += "Your feeds:
\n" for rss_feed in self.dic.keys(): @@ -79,11 +82,19 @@ class Root: html += htmlfooter return html - def f(self): + def m(self): """ """ return "Hello world !" + def f(self): + """ + Fetch all feeds + """ + feed_getter = feedgetter.FeedGetter() + feed_getter.retrieve_feed() + return self.index() + def description(self, article_id): """ Display the description of an article in a new Web page. @@ -91,9 +102,11 @@ class Root: html = htmlheader html += htmlnav html += """
""" - for rss_feed in self.dic.keys(): - for article in self.dic[rss_feed]: + for rss_feed_id in self.dic.keys(): + for article in self.dic[rss_feed_id]: if article_id == article[0]: + html += """

%s from %s


""" % \ + (article[2].encode('utf-8'), rss_feed_id, article[5].encode('utf-8')) description = article[4].encode('utf-8') if description: html += description @@ -103,15 +116,16 @@ class Root: html += "
\n" + htmlfooter return html - def all_articles(self, feed_title): + def all_articles(self, feed_id): """ Display all articles of a feed ('feed_title'). """ html = htmlheader html += htmlnav html += """
""" + html += """

Articles of the feed %s


""" % (self.dic[feed_id][0][5].encode('utf-8')) - for article in self.dic[feed_title]: + for article in self.dic[feed_id]: html += article[1].encode('utf-8') + " - " + \ '' + article[2].encode('utf-8') + "" + \ @@ -162,6 +176,7 @@ class Root: return dic index.exposed = True + m.exposed = True f.exposed = True description.exposed = True all_articles.exposed = True -- cgit