aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-09 22:09:29 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-09 22:09:29 +0100
commit2b835245140923e36f9d3ecba06442137ba2ae43 (patch)
tree7b446a52c4ba754a354b57620ff0d3c3fddf48f9
parentUpdated initialization script. (diff)
downloadnewspipe-2b835245140923e36f9d3ecba06442137ba2ae43.tar.gz
newspipe-2b835245140923e36f9d3ecba06442137ba2ae43.tar.bz2
newspipe-2b835245140923e36f9d3ecba06442137ba2ae43.zip
Improved OPML import.
-rwxr-xr-xpyaggr3g470r/utils.py6
-rw-r--r--pyaggr3g470r/views.py6
2 files changed, 8 insertions, 4 deletions
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index 4d65f14c..bb02c4df 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -81,13 +81,14 @@ def import_opml(email, opml_file):
subscriptions = opml.parse(opml_file)
except Exception as e:
raise e
+ nb = 0
for subscription in subscriptions:
try:
title = subscription.text
except:
title = ""
- print title
+
try:
description = subscription.description
except:
@@ -109,8 +110,11 @@ def import_opml(email, opml_file):
new_feed = models.Feed(title=title, description=description, link=link, site_link=site_link, email=False, enabled=True)
user.feeds.append(new_feed)
+
+ nb += 1
user.save()
+ return nb
def open_url(url):
"""
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 03ade91c..52ca3365 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -382,10 +382,10 @@ def management():
opml_path = os.path.join("./pyaggr3g470r/var/", data.filename)
data.save(opml_path)
try:
- utils.import_opml(g.user.email, opml_path)
- flash("New feeds imported", "success")
+ nb = utils.import_opml(g.user.email, opml_path)
+ flash(str(nb) + " feeds imported.", "success")
except Exception as e:
- flash("Impossible to import the new feeds."+str(e), "danger")
+ flash("Impossible to import the new feeds.", "danger")
form = AddFeedForm()
bgstack15