Files
endoflife-date-release-data/src/rds.py
Marc Wrobel d704e5f1f6 [rds] Refactor script (#242)
Make the script more readable, mostly by:

- using the Product class,
- a little bit of renaming and documentation.
2023-12-12 07:40:55 +01:00

39 lines
1.4 KiB
Python

import re
from bs4 import BeautifulSoup
from common import http
from common import dates
from common import endoflife
"""Fetches Amazon RDS versions from the version management pages on AWS docs.
Pages parsed by this script are expected to have version tables with a version in the first column and its release date
in the third column (usually named 'RDS release date').
"""
PRODUCTS = {
"amazon-rds-mysql": "https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Concepts.VersionMgmt.html",
"amazon-rds-postgresql": "https://docs.aws.amazon.com/AmazonRDS/latest/PostgreSQLReleaseNotes/postgresql-release-calendar.html",
}
VERSION_REGEX = re.compile(r"(?P<version>\d+(?:\.\d+)*)", flags=re.IGNORECASE) # https://regex101.com/r/BY1vwV/1
for product_name, url in PRODUCTS.items():
print(f"::group::{product_name}")
product = endoflife.Product(product_name)
response = http.fetch_url(url)
soup = BeautifulSoup(response.text, features="html5lib")
for table in soup.find_all("table"):
for row in table.find_all("tr"):
columns = row.find_all("td")
if len(columns) <= 3:
continue
version_match = VERSION_REGEX.search(columns[0].text.strip())
if version_match:
version = version_match.group("version")
date = dates.parse_date(columns[2].text)
product.declare_version(version, date)
product.write()
print("::endgroup::")