aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyAggr3g470r.py6
-rw-r--r--utils.py19
2 files changed, 12 insertions, 13 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 200506bb..c197033f 100644
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -408,10 +408,12 @@ class Root:
c.execute("UPDATE articles SET article_readed=1")
# Mark all articles from a feed as read.
elif param == "Feed" or param == "Feed_FromMainPage":
- c.execute("UPDATE articles SET article_readed=1 WHERE feed_link='" + self.feeds[identifiant][4].encode('utf-8') + "'")
+ c.execute("UPDATE articles SET article_readed=1 WHERE feed_link='" + \
+ self.feeds[identifiant][4].encode('utf-8') + "'")
# Mark an article as read.
elif param == "Article":
- c.execute("UPDATE articles SET article_readed=1 WHERE article_link='" + identifiant + "'")
+ c.execute("UPDATE articles SET article_readed=1 WHERE article_link='" + \
+ identifiant + "'")
conn.commit()
c.close()
except Exception, e:
diff --git a/utils.py b/utils.py
index e2294446..b7434636 100644
--- a/utils.py
+++ b/utils.py
@@ -31,11 +31,11 @@ def top_words(dic_articles, n=10):
words = {}
articles_content = ""
for rss_feed_id in dic_articles.keys():
- for article in dic_articles[rss_feed_id]:
- articles_content += remove_html_tags(article[4].encode('utf-8'))
+ for article in dic_articles[rss_feed_id]:
+ articles_content += remove_html_tags(article[4].encode('utf-8'))
words_gen = (word.strip(punctuation).lower() \
- for word in articles_content.split() \
- if len(word) >= 5)
+ for word in articles_content.split() \
+ if len(word) >= 5)
words = defaultdict(int)
for word in words_gen:
words[word] += 1
@@ -103,13 +103,11 @@ def compare(stringtime1, stringtime2):
return -1
elif datetime1 > datetime2:
return 1
- else:
- return 0
-
+ return 0
def load_feed():
"""
- Load feeds in a dictionary.
+ Load feeds and articles in a dictionary.
"""
list_of_feeds = None
list_of_articles = None
@@ -117,11 +115,9 @@ def load_feed():
conn = sqlite3.connect("./var/feed.db", isolation_level = None)
c = conn.cursor()
list_of_feeds = c.execute("SELECT * FROM feeds").fetchall()
- #c.close()
except:
pass
- # The key of dic is the id of the feed:
# articles[feed_id] = (article_id, article_date, article_title,
# article_link, article_description, article_readed)
# feeds[feed_id] = (nb_article, nb_article_unreaded, feed_image,
@@ -149,6 +145,7 @@ def load_feed():
else:
articles[feed_id].append(article_list)
+
# sort articles by date for each feeds
for rss_feed_id in articles.keys():
articles[rss_feed_id].sort(lambda x,y: compare(y[1], x[1]))
@@ -161,4 +158,4 @@ def load_feed():
c.close()
return (articles, feeds)
- return (articles, feeds)
+ return (articles, feeds) \ No newline at end of file
bgstack15