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,4 +1,3 @@
import json
import re
from bs4 import BeautifulSoup
from common import endoflife
@@ -7,11 +6,11 @@ URL = "https://access.redhat.com/articles/3078"
# https://regex101.com/r/877ibq/1
regex = r"RHEL (?P<major>\d)(\. ?(?P<minor>\d+))?(( Update (?P<minor2>\d))| GA)?"
versions = {}
print("::group::rhel")
response = endoflife.fetch_url(URL)
soup = BeautifulSoup(response, features="html5lib")
versions = {}
for tr in soup.findAll("tr"):
td_list = tr.findAll("td")
if len(td_list) > 0:
@@ -25,7 +24,6 @@ for tr in soup.findAll("tr"):
date = td_list[1].get_text()
versions[version] = date
print("%s: %s" % (version, date))
print("::endgroup::")
with open("releases/redhat.json", "w") as f:
f.write(json.dumps(versions, indent=2))
endoflife.write_releases('redhat', versions)
print("::endgroup::")