From 122baa744157db0082d02f2d6a1ffeda9245c2d5 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 4 Mar 2012 10:06:33 +0100 Subject: Minor stupid bub fix... --- pyAggr3g470r.py | 98 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 4a9280fc..21818515 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -110,17 +110,17 @@ class Root: def __init__(self): """ """ - self.articles = mongodb.Articles() + self.mongo = mongodb.Articles() def index(self): """ Main page containing the list of feeds and articles. """ - feeds = self.articles.get_all_collections() + feeds = self.mongo.get_all_collections() # if there are unread articles, display the number in the tab of the browser - html = htmlheader((self.articles.nb_unread_articles() and \ - ['(' + str(self.articles.nb_unread_articles()) +') '] or \ + html = htmlheader((self.mongo.nb_unread_articles() and \ + ['(' + str(self.mongo.nb_unread_articles()) +') '] or \ [""])[0]) html += htmlnav html += self.create_right_menu() @@ -132,21 +132,21 @@ class Root: html += '      \n' html += """\n""" % \ - (self.articles.nb_favorites(),) + (self.mongo.nb_favorites(),) html += """\n""" % \ - (self.articles.nb_mail_notifications(),) + (self.mongo.nb_mail_notifications(),) html += '      ' - if self.articles.nb_unread_articles != 0: + if self.mongo.nb_unread_articles != 0: html += '\n' html += """\n""" % \ - (self.articles.nb_unread_articles(),) + (self.mongo.nb_unread_articles(),) html += '\n' #for feed in feeds: - #for article in self.articles.get_articles_from_collection(feed["collection_id"]): + #for article in self.mongo.get_articles_from_collection(feed["collection_id"]): #try: #print article["article_title"], article["article_date"], article["article_readed"] #except: @@ -162,7 +162,7 @@ class Root: feed["feed_link"], feed["feed_image"]) # The main page display only 10 articles by feeds. - for article in self.articles.get_articles_from_collection(feed["feed_id"])[:10]: + for article in self.mongo.get_articles_from_collection(feed["feed_id"])[:10]: if article["article_readed"] == False: # not readed articles are in bold not_read_begin, not_read_end = "", "" @@ -197,9 +197,9 @@ class Root: # some options for the current feed html += """All articles   """ % (feed["feed_id"],) html += """Feed summary   """ % (feed["feed_id"],) - if self.articles.nb_unread_articles(feed["feed_id"]) != 0: + if self.mongo.nb_unread_articles(feed["feed_id"]) != 0: html += """  Mark all as read""" % (feed["feed_id"],) - html += """     Unread article(s) (%s)""" % (feed["feed_id"], self.articles.nb_unread_articles(feed["feed_id"])) + html += """     Unread article(s) (%s)""" % (feed["feed_id"], self.mongo.nb_unread_articles(feed["feed_id"])) if feed["mail"] == "0": html += """
\nStay tuned""" % (feed["feed_id"],) else: @@ -229,7 +229,7 @@ class Root: """ Create the list of feeds. """ - feeds = self.articles.get_all_collections() + feeds = self.mongo.get_all_collections() html = """" @@ -251,7 +251,7 @@ class Root: Allows adding and deleting feeds. Export functions of the SQLite data base and display some statistics. """ - feeds = self.articles.get_all_collections() + feeds = self.mongo.get_all_collections() html = htmlheader() html += htmlnav @@ -269,16 +269,16 @@ class Root: html += """\n""" html += """

Active e-mail notifications: %s

\n""" % \ - (self.articles.nb_mail_notifications(),) + (self.mongo.nb_mail_notifications(),) html += """

You like %s article(s).

\n""" % \ - (self.articles.nb_favorites(), ) + (self.mongo.nb_favorites(), ) html += "
\n" # Informations about the data base of articles html += """

%s article(s) are loaded from the database with %s unread article(s).
\n""" % \ - (self.articles.nb_articles(), self.articles.nb_unread_articles()) + (self.mongo.nb_articles(), self.mongo.nb_unread_articles()) #html += """Database: %s.\n
Size: %s bytes.
\n""" % \ #(os.path.abspath(utils.sqlite_base), os.path.getsize(utils.sqlite_base)) html += 'Advanced statistics.

\n' @@ -434,9 +434,9 @@ class Root: """ try: feed_id, article_id = param.split(':') - feed = self.articles.get_collection(feed_id) - articles = self.articles.get_articles_from_collection(feed_id) - article = self.articles.get_article(feed_id, article_id) + feed = self.mongo.get_collection(feed_id) + articles = self.mongo.get_articles_from_collection(feed_id) + article = self.mongo.get_article(feed_id, article_id) except: return self.error_page("Bad URL. This article do not exists.") html = htmlheader() @@ -573,19 +573,19 @@ class Root: favourite articles for the current feed. """ try: - feed = self.articles.get_collection(feed_id) - articles = self.articles.get_articles_from_collection(feed_id) + feed = self.mongo.get_collection(feed_id) + articles = self.mongo.get_articles_from_collection(feed_id) except KeyError: return self.error_page("This feed do not exists.") html = htmlheader() html += htmlnav html += """
""" - html += "

The feed " + feed["feed_title"] + " contains " + str(self.articles.nb_articles(feed_id)) + " articles. " - html += "Representing " + str((round(float(self.articles.nb_articles(feed_id)) / 1000, 4)) * 100) + " % of the total " #hack + html += "

The feed " + feed["feed_title"] + " contains " + str(self.mongo.nb_articles(feed_id)) + " articles. " + html += "Representing " + str((round(float(self.mongo.nb_articles(feed_id)) / 1000, 4)) * 100) + " % of the total " #hack html += "(" + str(1000) + ").

" if articles != []: - html += "

" + (self.articles.nb_unread_articles(feed_id) == 0 and ["All articles are read"] or [str(self.articles.nb_unread_articles(feed_id)) + \ - " unread article" + (self.articles.nb_unread_articles(feed_id) == 1 and [""] or ["s"])[0]])[0] + ".

" + html += "

" + (self.mongo.nb_unread_articles(feed_id) == 0 and ["All articles are read"] or [str(self.mongo.nb_unread_articles(feed_id)) + \ + " unread article" + (self.mongo.nb_unread_articles(feed_id) == 1 and [""] or ["s"])[0]])[0] + ".

" if feed["mail"] == True: html += """

You are receiving articles from this feed to the address: %s. """ % \ (utils.mail_to, utils.mail_to) @@ -594,14 +594,14 @@ class Root: if articles != []: last_article = utils.string_to_datetime(str(articles[0]["article_date"])) - first_article = utils.string_to_datetime(str(articles[self.articles.nb_articles(feed_id)-2]["article_date"])) + first_article = utils.string_to_datetime(str(articles[self.mongo.nb_articles(feed_id)-2]["article_date"])) delta = last_article - first_article delta_today = datetime.datetime.fromordinal(datetime.date.today().toordinal()) - last_article html += "

The last article was posted " + str(abs(delta_today.days)) + " day(s) ago.

" if delta.days > 0: - html += """

Daily average: %s,""" % (str(round(float(self.articles.nb_articles(feed_id))/abs(delta.days), 2)),) + html += """

Daily average: %s,""" % (str(round(float(self.mongo.nb_articles(feed_id))/abs(delta.days), 2)),) html += """ between the %s and the %s.

\n""" % \ - (str(articles[self.articles.nb_articles(feed_id)-2]["article_date"])[:10], str(articles[0]["article_date"])[:10]) + (str(articles[self.mongo.nb_articles(feed_id)-2]["article_date"])[:10], str(articles[0]["article_date"])[:10]) html += "

Recent articles

" for article in articles[:10]: @@ -680,7 +680,7 @@ class Root: dic = {} #dic[feed.feed_id] = self.feeds[feed.feed_id] - top_words = utils.top_words(articles = self.articles.get_articles_from_collection(feed_id), n=50, size=int(word_size)) + top_words = utils.top_words(articles = self.mongo.get_articles_from_collection(feed_id), n=50, size=int(word_size)) html += "

Tag cloud

\n
\n" # Tags cloud html += 'Minimum size of a word:' @@ -703,7 +703,7 @@ class Root: This page displays all articles of a feed. """ try: - feed = self.articles.get_articles_from_collection(feed_id) + feed = self.mongo.get_articles_from_collection(feed_id) except KeyError: return self.error_page("This feed do not exists.") html = htmlheader() @@ -755,11 +755,11 @@ class Root: """ This page displays all unread articles of a feed. """ - feeds = self.articles.get_all_collections() + feeds = self.mongo.get_all_collections() html = htmlheader() html += htmlnav html += """
""" - if self.articles.nb_unread_articles() != 0: + if self.mongo.nb_unread_articles() != 0: # List unread articles of all the database if feed_id == "": @@ -770,7 +770,7 @@ class Root: nb_unread = 0 # For all unread article of the current feed. - for article in self.articles.get_articles_from_collection(feed["feed_id"], condition=("article_readed", False)): + for article in self.mongo.get_articles_from_collection(feed["feed_id"], condition=("article_readed", False)): nb_unread += 1 if new_feed_section is True: new_feed_section = False @@ -790,7 +790,7 @@ class Root: """%s%s
\n""" % \ (feed["feed_id"], article["article_id"], article["article_title"][:150], description) - if nb_unread == self.articles.nb_unread_articles(feed["feed_id"]): + if nb_unread == self.mongo.nb_unread_articles(feed["feed_id"]): html += """
\nMark all articles from this feed as read\n""" % \ (feed["feed_id"],) html += """
\nMark articles as read\n""" @@ -798,14 +798,14 @@ class Root: # List unread articles of a feed else: try: - feed = self.articles.get_collection(feed_id) + feed = self.mongo.get_collection(feed_id) except: self.error_page("This feed do not exists.") html += """

Unread article(s) of the feed %s


""" % (feed_id, feed["feed_title"]) # For all unread article of the feed. - for article in self.articles.get_articles_from_collection(feed_id, condition=("article_readed", False)): + for article in self.mongo.get_articles_from_collection(feed_id, condition=("article_readed", False)): # descrition for the CSS ToolTips article_content = utils.clear_string(article["article_content"]) if article_content: @@ -835,7 +835,7 @@ class Root: """ This page enables to browse articles chronologically. """ - feeds = self.articles.get_all_collections() + feeds = self.mongo.get_all_collections() html = htmlheader() html += htmlnav html += """
\n""" @@ -861,7 +861,7 @@ class Root: timeline = Counter() for feed in feeds: new_feed_section = True - for article in self.articles.get_articles_from_collection(feed["feed_id"]): + for article in self.mongo.get_articles_from_collection(feed["feed_id"]): if querystring == "all": timeline[str(article["article_date"]).split(' ')[0].split('-')[0]] += 1 @@ -970,17 +970,17 @@ class Root: # Mark all articles as read. if param == "": - self.articles.mark_as_read(True, None, None) + self.mongo.mark_as_read(True, None, None) # Mark all articles from a feed as read. elif param == "Feed" or param == "Feed_FromMainPage": - self.articles.mark_as_read(True, identifiant, None) + self.mongo.mark_as_read(True, identifiant, None) # Mark an article as read. elif param == "Article": - self.articles.mark_as_read(True, identifiant.split(':')[1], identifiant.split(':')[0]) + self.mongo.mark_as_read(True, identifiant.split(':')[1], identifiant.split(':')[0]) if param == "" or param == "Feed_FromMainPage": return self.index() elif param == "Feed": - return self.articles(identifiant) + return self.mongo(identifiant) mark_as_read.exposed = True @@ -992,7 +992,7 @@ class Root: html = htmlheader() html += htmlnav html += """
""" - feeds = self.articles.get_all_collections(condition=("mail",True)) + feeds = self.mongo.get_all_collections(condition=("mail",True)) if feeds != []: html += "

You are receiving e-mails for the following feeds:

\n" for feed in feeds: @@ -1029,10 +1029,10 @@ class Root: """ try: like, feed_id, article_id = param.split(':') - articles = self.articles.get_article(feed_id, article_id) + articles = self.mongo.get_article(feed_id, article_id) except: return self.error_page("Bad URL. This article do not exists.") - self.articles.like_article("1"==like, feed_id, article_id) + self.mongo.like_article("1"==like, feed_id, article_id) return self.article(feed_id+":"+article_id) like.exposed = True @@ -1042,14 +1042,14 @@ class Root: """ List of favorites articles """ - feeds = self.articles.get_all_collections() + feeds = self.mongo.get_all_collections() html = htmlheader() html += htmlnav html += """
""" html += "

Your favorites articles

" for feed in feeds: new_feed_section = True - for article in self.articles.get_articles_from_collection(feed["feed_id"]): + for article in self.mongo.get_articles_from_collection(feed["feed_id"]): if article["article_like"] == True: if new_feed_section is True: new_feed_section = False -- cgit