diff options
-rw-r--r-- | feedgetter.py | 17 | ||||
-rw-r--r-- | 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 += """<div class="right inner">\n""" + html += """<a href="f/">Fetch all feeds</a>\n<br />\n""" + html += """<a href="m/">Management of feed</a>\n""" html += """<form method=get action="q/"><input type="text" name="v" value=""><input type="submit" value="search"></form>\n""" - html += """<a href="f/">Management of feed</a>\n""" html += "<hr />\n" html += "Your feeds:<br />\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 += """</div> <div class="left inner">""" - 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 += """<h1><i>%s</i> from <a href="/all_articles/%s">%s</a></h1><br />""" % \ + (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 += "<hr />\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 += """</div> <div class="left inner">""" + html += """<h1>Articles of the feed %s</h1><br />""" % (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') + " - " + \ '<a href="' + article[3].encode('utf-8') + \ '">' + article[2].encode('utf-8') + "</a>" + \ @@ -162,6 +176,7 @@ class Root: return dic index.exposed = True + m.exposed = True f.exposed = True description.exposed = True all_articles.exposed = True |