Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tool to automatically add <release> tags to appdata
- Loading branch information
1 parent
0d9730d
commit 3ed601b
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/env python | ||
|
||
import sys, requests, argparse | ||
from xml.dom import minidom | ||
|
||
def fetch_date(version): | ||
tag_info = requests.get("https://api.github.com/repos/wesnoth/wesnoth/git/refs/tags/"+version) | ||
tag_info.raise_for_status() | ||
url = tag_info.json()["object"]["url"] | ||
result = requests.get(url) | ||
result.raise_for_status() | ||
return result.json()["tagger"]["date"] | ||
|
||
def update_appdata(version, appdata_path): | ||
date = fetch_date(version) | ||
|
||
doc = minidom.parse(appdata_path) | ||
releases = doc.getElementsByTagName("releases") | ||
if releases: | ||
releases = releases[0] | ||
else: | ||
releases = doc.getElementsByTagName("component")[-1].appendChild(doc.createElement("releases")) | ||
|
||
release = doc.createElement("release") | ||
release.setAttribute("version", version) | ||
release.setAttribute("date", date) | ||
releases.insertBefore(release, releases.firstChild) | ||
|
||
doc.writexml(open(appdata_path, "w")) | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('version', metavar='VERSION') | ||
parser.add_argument('appdata', metavar='APPDATA_FILE') | ||
|
||
args = parser.parse_args() | ||
update_appdata(args.version, args.appdata) |
3ed601b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be under utils/. See the READMEs.