aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/utils.py')
-rwxr-xr-xpyaggr3g470r/utils.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index 1880aaa0..50549587 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -38,6 +38,7 @@ import re
import glob
import opml
import json
+import logging
import datetime
import operator
import urllib
@@ -59,8 +60,7 @@ url_finders = [
re.compile("'\\<((mailto:)|)[-A-Za-z0-9\\.]+@[-A-Za-z0-9\\.]+") \
]
-#import log
-#pyaggr3g470r_log = log.Log()
+logger = logging.getLogger(__name__)
@contextmanager
@@ -76,15 +76,16 @@ def opened_w_error(filename, mode="r"):
f.close()
-def import_opml(email, opml_file):
+def import_opml(email, opml_content):
"""
Import new feeds from an OPML file.
"""
user = User.query.filter(User.email == email).first()
try:
- subscriptions = opml.parse(opml_file)
- except Exception as e:
- raise e
+ subscriptions = opml.from_string(opml_content)
+ except:
+ logger.exception("Parsing OPML file failed:")
+ raise
def read(subsubscription, nb=0):
"""
@@ -191,7 +192,7 @@ def clean_url(url):
return urlunparse([
parsed_url.scheme,
parsed_url.netloc,
- parsed_url.path,
+ urllib.quote(urllib.unquote(parsed_url.path)),
parsed_url.params,
urllib.urlencode(filtered, doseq=True),
parsed_url.fragment
bgstack15