Files
endoflife-date-release-data/src/amazon-neptune.py
Marc Wrobel 56cc29b49d Make releasedata.Product usable in 'with' expression (#294)
This way the writing of the JSON file is handled automatically if the update does not fail.
It pave the way to further global improvements, such as a better error handling.
2024-02-04 14:48:05 +01:00

22 lines
877 B
Python

import re
import xml.dom.minidom
from common import dates, http, releasedata
"""Fetches Amazon Neptune versions from its RSS feed on docs.aws.amazon.com."""
RSS_URL = "https://docs.aws.amazon.com/neptune/latest/userguide/rssupdates.rss"
VERSION_PATTERN = re.compile(r"^Engine version (?P<version>[0-9R.]+)$")
with releasedata.ProductData("amazon-neptune") as product_data:
rss_response = http.fetch_url(RSS_URL)
rss = xml.dom.minidom.parseString(rss_response.text)
for entry in rss.getElementsByTagName("item"):
version_str = entry.getElementsByTagName("title")[0].firstChild.nodeValue
date_str = entry.getElementsByTagName("pubDate")[0].firstChild.nodeValue
version_match = VERSION_PATTERN.match(version_str)
if version_match:
product_data.declare_version(version_match['version'], dates.parse_datetime(date_str))