#!/usr/bin/env python3
import re
from datetime import datetime, timezone, date
release = re.compile("^## Release ([0-9]+\\.[0-9]+\\.[0-9]+) - ([0-9]+-[0-9]+-[0-9]+)$")
title = "SpaceBeans releases"
base_url = "https://www.usebox.net/jjm/spacebeans/"
feed_file = "releases.xml"
author = "jjm"
tz = timezone.utc
def get_entries(changes):
entries = []
with open(changes, "rt") as fd:
lines = fd.readlines()
i = 0
while i < len(lines):
line = lines[i]
m = release.match(line)
if m:
version = m.group(1)
updated_on = datetime.fromisoformat(m.group(2)).astimezone(tz)
body = ""
i += 1
while i < len(lines) and (lines[i] == "" or lines[i][0] != "#"):
body += lines[i]
i += 1
entries.append(dict(version=version, updated_on=updated_on, body=body))
else:
i += 1
entries.sort(key=lambda o: o["updated_on"], reverse=True)
return entries
def to_atom(post):
return """\
{title}{url}{updated_on}