Refactor product releases writing

Create a common function to write resulting JSON files to the releases directory.
It makes this task simpler to read and maintain, while making it modifiable at a central point in the future.
One example of such modification could be the sorting of the versions in a uniform way for all the scripts.
This commit is contained in:
Marc Wrobel
2023-05-20 11:00:47 +02:00
parent a16d9090d3
commit 6ba7828f96
22 changed files with 103 additions and 190 deletions

View File

@@ -1,6 +1,5 @@
import re
import sys
import json
import subprocess
from common import endoflife
@@ -72,8 +71,7 @@ def update_product(product_name, configs):
config = config if "regex" in config else config | {"regex": REGEX}
releases = releases | fetch_releases(config[METHOD], config["regex"])
with open(f"releases/{product_name}.json", "w") as f:
f.write(json.dumps(releases, indent=2))
endoflife.write_releases(product_name, releases)
p_filter = sys.argv[1] if len(sys.argv) > 1 else None