2021-07-12 02:22:10 +10:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import html
|
|
|
|
import re
|
|
|
|
from pathlib import Path
|
|
|
|
|
2023-10-27 20:25:20 +11:00
|
|
|
root = Path(__file__).resolve().parent.parent
|
2021-07-12 02:22:10 +10:00
|
|
|
title_pattern = re.compile(r"## (\d+\.\d+\.\d+) \((\d{4}-\d\d-\d\d)\)")
|
|
|
|
release_lines = [" <releases>"]
|
|
|
|
|
|
|
|
for line in (root / "docs" / "CHANGELOG.md").read_text().splitlines():
|
2023-10-27 20:25:20 +11:00
|
|
|
match = title_pattern.match(line)
|
2021-07-12 02:22:10 +10:00
|
|
|
|
2023-10-27 20:25:20 +11:00
|
|
|
if match:
|
|
|
|
args = (html.escape(match.group(1)), html.escape(match.group(2)))
|
|
|
|
release_lines.append(' <release version="%s" date="%s"/>' % args)
|
2021-07-12 02:22:10 +10:00
|
|
|
|
2023-10-27 20:25:20 +11:00
|
|
|
appdata = root / "packaging" / "moment.metainfo.xml"
|
2021-07-12 02:22:10 +10:00
|
|
|
in_releases = False
|
|
|
|
final_lines = []
|
|
|
|
|
|
|
|
for line in appdata.read_text().splitlines():
|
2023-10-27 20:25:20 +11:00
|
|
|
if line == " <releases>":
|
|
|
|
in_releases = True
|
|
|
|
final_lines += release_lines
|
|
|
|
elif line == " </releases>":
|
|
|
|
in_releases = False
|
|
|
|
|
|
|
|
if not in_releases:
|
|
|
|
final_lines.append(line)
|
2021-07-12 02:22:10 +10:00
|
|
|
|
|
|
|
appdata.write_text("\n".join(final_lines))
|