From 88263b48ec26a01f542623e7515959482d6f7aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gil=20Gon=C3=A7alves?= Date: Fri, 6 Dec 2013 17:36:18 +0000 Subject: [PATCH] Removed prints; Little code changes --- converter.py | 17 +++++++++++------ service.py | 2 -- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/converter.py b/converter.py index 43438d9..af125f9 100644 --- a/converter.py +++ b/converter.py @@ -7,24 +7,29 @@ from html2text import html2text _READABILITY_URL = 'https://www.readability.com/api/content/v1/parser' -def readability(url): +def _readability(url): token = os.environ.get('READABILITY_TOKEN') params = {'url': url, 'token': token} r = requests.get(_READABILITY_URL, params=params) - return r.json()['content'], r.json()['title'] + decoded_content = ( + r.json()['content'], + r.json()['title'], + ) + return decoded_content -def convert(html, title=None): +def _convert(html, title=None): if title: title = '# {}'.format(title) html = '\n\n'.join([title, html]) - return html2text(html) + text_from_html = html2text(html) + return text_from_html def get_readable_content_from_url(url): try: - content, title = readability(url) - return convert(content, title=title) + content, title = _readability(url) + return _convert(content, title=title) except KeyError: return None diff --git a/service.py b/service.py index f752992..cfbe923 100644 --- a/service.py +++ b/service.py @@ -18,14 +18,12 @@ def fuck_gpl3(): type = request.args.get('type', 'markdown') content = get_readable_content_from_url(url) - print url if url: if not content: return '404 Not Found', 404 if type == 'html': - print url markdown_url_contents = _markdown_to_html(content) return render_template( 'index.html',