Add a script to update Flatpak description and add version changes (#6439)

This commit is contained in:
Michael
2023-01-03 23:43:37 +08:00
committed by GitHub
parent 1d9e66fb36
commit 6fb51957de
3 changed files with 2260 additions and 1 deletions
+1 -1
View File
@@ -1978,7 +1978,7 @@ version 0.8 (26 July 2020)
- fix multiple memory leaks
- add double quotes to surrender dialog
version 0.7 (18th April 2020)
version 0.7 (18 April 2020)
- add an edge of the World Map
- complete hero movement cell if a player stops it by any keyboard button
- add hotkey 'N' to start a new game within the World Map like in the original game
File diff suppressed because it is too large Load Diff
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
import argparse
import datetime
import re
import sys
from xml.sax.saxutils import escape
#
# Appstream file could be validated with 'appstream-util validate io.github.ihhub.Fheroes2.appdata.xml'
#
class CustomArgumentParser(argparse.ArgumentParser):
def error(self, message):
self.print_usage(sys.stderr)
self.exit(1, "%(prog)s: error: %(message)s\n" %
{"prog": self.prog, "message": message})
def parse_arguments():
parser = CustomArgumentParser()
parser.add_argument("changelog_file", help="changelog.txt file")
parser.add_argument("appdata_file", help="*.appdata.xml file")
return parser.parse_args()
def main():
args = parse_arguments()
changelog = open(args.changelog_file, encoding='utf-8').read()
appdata = open(args.appdata_file, encoding='utf-8').read()
tpl = '''
<release date="{}" version="v{}">
<url>https://github.com/ihhub/fheroes2/releases/tag/{}</url>
<description>
<p>Changes in v{} ({}):</p>
<ul>
{}
</ul>
</description>
</release>\n'''.lstrip("\r\n")
tmp = ''
regex = r"version ([\d.]+) \(([\w ]+)\)\n(.*?)[\n]{2}"
for match in re.findall(regex, changelog, re.MULTILINE | re.DOTALL):
tmp += tpl.format(
datetime.datetime.strptime(match[1], '%d %B %Y').strftime('%Y-%m-%d'),
match[0],
match[0],
match[0],
match[1],
re.sub(r'- (.*)', r' <li>\1</li>', escape(match[2]))
)
new_appdata = re.sub(r'<releases>(.*?)</releases>', r'<releases>\n' + tmp + ' </releases>',
appdata,
flags=re.MULTILINE | re.DOTALL
)
open(args.appdata_file, 'w', encoding='utf-8').write(new_appdata)
if __name__ == "__main__":
main()