diff options
author | Cédric Bonhomme <kimble.mandel+bitbucket@gmail.com> | 2014-06-09 19:05:32 +0200 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel+bitbucket@gmail.com> | 2014-06-09 19:05:32 +0200 |
commit | 1b73a3a4a73f231f6c1c2a3258e561b1301ca6af (patch) | |
tree | ea21bacea92a0a267f8286eb12f2d81cefa1a3c4 /pyaggr3g470r/utils.py | |
parent | A problem with urllib.quote() has been detected with the url: http://standblo... (diff) | |
parent | fixing parsing for already quoted url as well (diff) | |
download | newspipe-1b73a3a4a73f231f6c1c2a3258e561b1301ca6af.tar.gz newspipe-1b73a3a4a73f231f6c1c2a3258e561b1301ca6af.tar.bz2 newspipe-1b73a3a4a73f231f6c1c2a3258e561b1301ca6af.zip |
Merged in jaesivsm/pyaggr3g470r (pull request #2)
making pyagregator runnable by apache
Diffstat (limited to 'pyaggr3g470r/utils.py')
-rwxr-xr-x | pyaggr3g470r/utils.py | 15 |
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 |