An assortment of scripts and programs that pulls in info from our repositories and puts out a website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

102 lines
3.4 KiB

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#https://github.com/lkiesow/python-feedgen
#Package in Arch [Communiy] python-feedgen . Not python-feedgenerator
#https://feedgen.kiesow.be/api.entry.html
try:
from zoneinfo import ZoneInfo
except ModuleNotFoundError:
from backports.zoneinfo import ZoneInfo
from datetime import datetime, timezone, tzinfo
import sys
from feedgen.feed import FeedGenerator
try:
datetime.fromisoformat
except AttributeError:
import backports.datetime_fromisoformat
from backports.datetime_fromisoformat import MonkeyPatch
MonkeyPatch.patch_fromisoformat()
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.""",
"tembro" : """Tembro is a virtual software instrument based on samples. All instruments are permanently built-in.""",
}
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\n"):
firstLine, changelog = cl.split("\n", maxsplit=1)
if firstLine.startswith("#Changelog"):
#preamble. skip
continue
# Format:## YYYY-MM-DD major.minor.patch
assert "##" in firstLine, firstLine
markdownTitle, date, semVersion = firstLine.split(" ")
assert markdownTitle == "##", markdownTitle
assert date.count("-") == 2, date
assert semVersion.count(".") == 2, semVersion
print(firstLine, "parsed as date:", date, "with version:", semVersion)
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.updated(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