Nils
3 years ago
2 changed files with 90 additions and 1 deletions
@ -0,0 +1,79 @@ |
|||
#! /usr/bin/env python3 |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
#https://github.com/lkiesow/python-feedgen |
|||
#Package in Arch [Communiy] python-feedgen . Not python-feedgenerator |
|||
|
|||
from zoneinfo import ZoneInfo |
|||
from datetime import datetime, timezone, tzinfo |
|||
import sys |
|||
from feedgen.feed import FeedGenerator |
|||
|
|||
|
|||
fg = FeedGenerator() |
|||
|
|||
descs = { |
|||
"patroneo" : """Patroneo is an easy to use, pattern based midi sequencer.""", |
|||
"laborejo" : """Laborejo is a MIDI sequencer based on classical music notation.""", |
|||
"fluajho" : """Fluajho is a simple, standalone sf2 soundfont host/player.""", |
|||
"agordejo" : """Agordejo is a music and audio production session manager based on NSM.""", |
|||
} |
|||
|
|||
if (not len(sys.argv) == 4) or not sys.argv[1] in descs or not sys.argv[2].endswith("/CHANGELOG") or not sys.argv[3].endswith("feed.atom"): |
|||
raise ValueError("Wrong number or wrong arguments: ./atomfeedgen.py patroneo /home/nils/lss/patroneo/CHANGELOG" "out/patroneo/feed.atom" ) |
|||
|
|||
project = sys.argv[1] |
|||
CHANGELOGFILE = sys.argv[2] |
|||
assert project in descs |
|||
description = descs[project] |
|||
|
|||
print (f"Atom Feed Generation: {project}") |
|||
|
|||
fg.id(f"https://laborejo.org/{project}/") |
|||
fg.title(f"{project.title()} Releases") |
|||
fg.author( {'name':'Laborejo Software Suite','email':'info@laborejo.org'} ) |
|||
fg.link( href=f"https://laborejo.org/{project}/", rel='alternate' ) |
|||
fg.logo(f"https://laborejo.org/images/{project}.png") |
|||
fg.subtitle(description) |
|||
fg.link( href=f"https://laborejo.org/{project}/feed.atom", rel="self" ) |
|||
fg.language('en') |
|||
|
|||
|
|||
|
|||
with open(CHANGELOGFILE) as fcl: |
|||
changelogData = fcl.read() |
|||
|
|||
|
|||
for cl in changelogData.split("\n\n"): |
|||
|
|||
firstLine, changelog = cl.split("\n", maxsplit=1) |
|||
print(firstLine) |
|||
date, semVersion = firstLine.split("Version") |
|||
semVersion = semVersion.strip() |
|||
isodate = datetime.fromisoformat(date.strip()) |
|||
isodate = isodate.replace(tzinfo=ZoneInfo("UTC")) |
|||
|
|||
|
|||
fe = fg.add_entry() |
|||
fe.id(f"https://laborejo.org/downloads/{project}-{semVersion}") |
|||
fe.title(f"{project.title()} Version {semVersion}") |
|||
#fe.link(href=f"https://laborejo.org/downloads/{project}-{semVersion}.tar.gz") |
|||
fe.link(href=f"https://laborejo.org/{project}") |
|||
fe.pubDate(isodate) |
|||
fe.rights("GPL3+") |
|||
|
|||
cl = "</li>".join("<li>" + line.lstrip() for line in changelog.split("\n")) |
|||
|
|||
desc = f""" |
|||
Download: <a href="https://laborejo.org/downloads/{project}-{semVersion}.tar.gz">https://laborejo.org/downloads/{project}-{semVersion}.tar.gz</a> |
|||
<p> |
|||
Changelog: |
|||
<ul> |
|||
{cl} |
|||
</ul> |
|||
</p> |
|||
""" |
|||
fe.content(desc, type="html") |
|||
|
|||
atomfeed = fg.atom_str(pretty=True) # Get the ATOM feed as string |
|||
fg.atom_file(sys.argv[3]) # Write the ATOM feed to a file |
Loading…
Reference in new issue