Files
endoflife-date-release-data/src/rhel.py
Marc Wrobel 391d65ad8a Simplify argument parsing (#459)
With the current state of automation scripts, this is not possible anymore to launch script with multiple auto configs.
2025-07-06 22:42:01 +02:00

25 lines
923 B
Python

import re
from common import dates, http
from common.releasedata import ProductData, config_from_argv
# https://regex101.com/r/877ibq/1
VERSION_PATTERN = re.compile(r"RHEL (?P<major>\d)(\. ?(?P<minor>\d+))?(( Update (?P<minor2>\d))| GA)?")
config = config_from_argv()
with ProductData(config.product) as product_data:
html = http.fetch_html(config.url)
for tr in html.findAll("tr"):
td_list = tr.findAll("td")
if len(td_list) == 0:
continue
version_str = td_list[0].get_text().strip()
version_match = VERSION_PATTERN.match(version_str).groupdict()
version = version_match["major"]
version += ("." + version_match["minor"]) if version_match["minor"] else ""
version += ("." + version_match["minor2"]) if version_match["minor2"] else ""
date = dates.parse_date(td_list[1].get_text())
product_data.declare_version(version, date)