diff options
-rwxr-xr-x | pyAggr3g470r.py | 10 | ||||
-rwxr-xr-x | utils.py | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index e5f0cd98..79d204f3 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -258,12 +258,12 @@ class Root: html += """<form method=get action="/add_feed/"><input type="url" name="url" placeholder="URL of a site" maxlength=2048 autocomplete="off">\n<input type="submit" value="OK"></form>\n""" - if self.articles: + if self.feeds: html += "<h1>Delete Feeds</h1>\n" html += """<form method=get action="/remove_feed/"><select name="feed_id">\n""" - for feed_id in self.feeds.keys(): + for feed in self.feeds.values(): html += """\t<option value="%s">%s</option>\n""" % \ - (feed_id, feed.feed_title.encode('utf-8')) + (feed.feed_id, feed.feed_title.encode('utf-8')) html += """</select><input type="submit" value="OK"></form>\n""" html += """<p>Active e-mail notifications: <a href="/notifications/">%s</a></p>\n""" % \ (self.nb_mail_notifications,) @@ -291,8 +291,8 @@ class Root: html += "<hr />\n\n" # Some statistics - if self.articles: - self.top_words = utils.top_words(self.articles, n=50, size=int(word_size)) + if self.feeds: + self.top_words = utils.top_words(self.feeds, n=50, size=int(word_size)) html += "<h1>Statistics</h1>\n<br />\n" # Tags cloud html += 'Minimum size of a word:' @@ -155,15 +155,15 @@ def normalize_filename(name): file_name = strip_accents(file_name, "utf-8") return os.path.normpath(file_name) -def top_words(dic_articles, n=10, size=5): +def top_words(feeds, n=10, size=5): """ Return the n most frequent words in a list. """ words = Counter() wordre = re.compile(r'\b\w{%s,}\b' % size, re.I) - for rss_feed_id in dic_articles.keys(): - for article in dic_articles[rss_feed_id]: - for word in wordre.findall(clear_string(article[4].encode('utf-8'))): + for feed in feeds.values(): + for article in feed.articles.values(): + for word in wordre.findall(clear_string(article.article_description.encode('utf-8'))): words[word.lower()] += 1 return words.most_common(n) |