Refractored exporting

This commit is contained in:
Manuel Ebert 2012-07-05 12:31:50 +02:00
parent af2c592700
commit 44c1f55dea
3 changed files with 28 additions and 22 deletions

View file

@ -149,26 +149,6 @@ class Journal:
pp)
return pp
def to_json(self):
"""Returns a JSON representation of the Journal."""
return json.dumps([e.to_dict() for e in self.entries], indent=2)
def to_md(self):
"""Returns a markdown representation of the Journal"""
out = []
year, month = -1, -1
for e in self.entries:
if not e.date.year == year:
year = e.date.year
out.append(str(year))
out.append("=" * len(str(year)) + "\n")
if not e.date.month == month:
month = e.date.month
out.append(e.date.strftime("%B"))
out.append('-' * len(e.date.strftime("%B")) + "\n")
out.append(e.to_md())
return "\n".join(out)
def __repr__(self):
return "<Journal with %d entries>" % len(self.entries)