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.3KB

  1. #! /usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. #https://github.com/lkiesow/python-feedgen
  4. #Package in Arch [Communiy] python-feedgen . Not python-feedgenerator
  5. #https://feedgen.kiesow.be/api.entry.html
  6. try:
  7. from zoneinfo import ZoneInfo
  8. except ModuleNotFoundError:
  9. from backports.zoneinfo import ZoneInfo
  10. from datetime import datetime, timezone, tzinfo
  11. import sys
  12. from feedgen.feed import FeedGenerator
  13. try:
  14. datetime.fromisoformat
  15. except AttributeError:
  16. import backports.datetime_fromisoformat
  17. from backports.datetime_fromisoformat import MonkeyPatch
  18. MonkeyPatch.patch_fromisoformat()
  19. fg = FeedGenerator()
  20. descs = {
  21. "patroneo" : """Patroneo is an easy to use, pattern based midi sequencer.""",
  22. "laborejo" : """Laborejo is a MIDI sequencer based on classical music notation.""",
  23. "fluajho" : """Fluajho is a simple, standalone sf2 soundfont host/player.""",
  24. "agordejo" : """Agordejo is a music and audio production session manager based on NSM.""",
  25. }
  26. 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"):
  27. raise ValueError("Wrong number or wrong arguments: ./atomfeedgen.py patroneo /home/nils/lss/patroneo/CHANGELOG out/patroneo/feed.atom" )
  28. project = sys.argv[1]
  29. CHANGELOGFILE = sys.argv[2]
  30. assert project in descs
  31. description = descs[project]
  32. print (f"Atom Feed Generation: {project}")
  33. fg.id(f"https://laborejo.org/{project}/")
  34. fg.title(f"{project.title()} Releases")
  35. fg.author( {'name':'Laborejo Software Suite','email':'info@laborejo.org'} )
  36. fg.link( href=f"https://laborejo.org/{project}/", rel='alternate' )
  37. fg.logo(f"https://laborejo.org/images/{project}.png")
  38. fg.subtitle(description)
  39. fg.link( href=f"https://laborejo.org/{project}/feed.atom", rel="self" )
  40. fg.language('en')
  41. with open(CHANGELOGFILE) as fcl:
  42. changelogData = fcl.read()
  43. for cl in changelogData.split("\n\n\n"):
  44. firstLine, changelog = cl.split("\n", maxsplit=1)
  45. if firstLine.startswith("#Changelog"):
  46. #preamble. skip
  47. continue
  48. # Format:## YYYY-MM-DD major.minor.patch
  49. assert "##" in firstLine, firstLine
  50. markdownTitle, date, semVersion = firstLine.split(" ")
  51. assert markdownTitle == "##", markdownTitle
  52. assert date.count("-") == 2, date
  53. assert semVersion.count(".") == 2, semVersion
  54. print(firstLine, "parsed as date:", date, "with version:", semVersion)
  55. semVersion = semVersion.strip()
  56. isodate = datetime.fromisoformat(date.strip())
  57. isodate = isodate.replace(tzinfo=ZoneInfo("UTC"))
  58. fe = fg.add_entry()
  59. fe.id(f"https://laborejo.org/downloads/{project}-{semVersion}")
  60. fe.title(f"{project.title()} Version {semVersion}")
  61. #fe.link(href=f"https://laborejo.org/downloads/{project}-{semVersion}.tar.gz")
  62. fe.link(href=f"https://laborejo.org/{project}")
  63. #fe.pubDate(isodate)
  64. fe.updated(isodate)
  65. fe.rights("GPL3+")
  66. cl = "</li>".join("<li>" + line.lstrip() for line in changelog.split("\n"))
  67. desc = f"""
  68. Download: <a href="https://laborejo.org/downloads/{project}-{semVersion}.tar.gz">https://laborejo.org/downloads/{project}-{semVersion}.tar.gz</a>
  69. <p>
  70. Changelog:
  71. <ul>
  72. {cl}
  73. </ul>
  74. </p>
  75. """
  76. fe.content(desc, type="html")
  77. atomfeed = fg.atom_str(pretty=True) # Get the ATOM feed as string
  78. fg.atom_file(sys.argv[3]) # Write the ATOM feed to a file