From 7f031eef09ae58ffe5c005d9b1431966745ca298 Mon Sep 17 00:00:00 2001 From: lub Date: Fri, 1 May 2020 18:15:56 +0200 Subject: [PATCH] make description in body optional --- scrape.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/scrape.py b/scrape.py index 25973e0..a7117ca 100644 --- a/scrape.py +++ b/scrape.py @@ -55,20 +55,25 @@ def get_blog(): return blog def get_body(post): - return ( - post['title']+ - "\n"+ - post['description']+ - "\n"+ - post['url'] - ) + body = post['title']+"\n" + + if post['description'] != '': + body += post['description']+"\n" + + body += post['url'] + + return body def get_formatted_body(post): - return ( - ''+ - '
'+post['title']+'
'+ - '
'+ - '

'+post['description']+'

' - ) + formatted_body = '' + formatted_body += '
'+post['title']+'
' + formatted_body += '
' + + if post['description'] != '': + formatted_body += '

'+post['description']+'

' + + formatted_body += post['url'] + + return formatted_body homeserver = environ['HOMESERVER_URL']