Suppress empty bodies in prettyprinting

This commit is contained in:
Manuel Ebert 2012-05-31 11:33:28 +02:00
parent e21cdd7e69
commit 7a8b847bd7

View file

@ -46,10 +46,13 @@ class Entry:
title = date_str + " " + self.title
body = self.body.strip()
# Suppress bodies that are just blanks and new lines.
has_body = len(self.body) > 20 or not all(char in (" ", "\n") for char in self.body)
return "{title}{sep}{body}\n".format(
title=title,
sep="\n" if self.body else "",
body=body
sep="\n" if has_body else "",
body=body if has_body else "",
)
def __repr__(self):