[coldfusion] Refactor script (#217)

Make the script more readable, mostly by:

- using the endoflife.Product class,
- removing some unnecessary use of functions,
- a little bit of renaming and documentation.
This commit is contained in:
Marc Wrobel
2023-12-10 16:45:14 +01:00
committed by GitHub
parent 0836c270ea
commit 328ddc3823

View File

@@ -3,16 +3,13 @@ from bs4 import BeautifulSoup
from common import http
from common import dates
from common import endoflife
from datetime import datetime
# Release dates are not available in the release notes, so we have to set them manually.
RELEASE_DATES = {
"10.0.0": "2012-05-15", # https://en.wikipedia.org/wiki/Adobe_ColdFusion#Adobe_ColdFusion_10
"11.0.0": "2014-04-29", # https://en.wikipedia.org/wiki/Adobe_ColdFusion#Adobe_ColdFusion_11
"2016.0.0": "2016-02-16", # https://en.wikipedia.org/wiki/Adobe_ColdFusion#Adobe_ColdFusion_(2016_Release)
"2018.0.0": "2018-07-12", # https://coldfusion.adobe.com/2018/07/new-coldfusion-release-adds-performance-monitoring-toolset-for-measuring-monitoring-and-managing-high-performing-web-apps/
"2021.0.0": "2020-11-11", # https://community.adobe.com/t5/coldfusion-discussions/introducing-adobe-coldfusion-2021-release/m-p/11585468
"2023.0.0": "2022-05-16", # https://coldfusion.adobe.com/2023/05/coldfusion2023-release/
}
"""Fetches versions from Adobe ColdFusion release notes on helpx.adobe.com.
x.y.0 release dates are unfortunately not available in the release notes and have to updated them manually each time a
new minor version is released.
"""
URLS = [
"https://helpx.adobe.com/coldfusion/kb/coldfusion-10-updates.html",
@@ -23,22 +20,32 @@ URLS = [
"https://helpx.adobe.com/coldfusion/kb/coldfusion-2023-updates.html"
]
PRODUCT = "coldfusion"
REGEX = r"[r|R]elease [d|D]ate[,|:]? (.*?)\).*?Build Number: (.*?)$"
VERSION_AND_DATE_PATTERN = re.compile(r"Release Date[,|:]? (.*?)\).*?Build Number: (.*?)$",
re.DOTALL | re.MULTILINE | re.IGNORECASE)
print(f"::group::{PRODUCT}")
versions = RELEASE_DATES | {}
# .0 release dates are not available in the release notes.
FIXED_VERSIONS = {
"10.0.0": datetime(2012, 5, 15), # https://en.wikipedia.org/wiki/Adobe_ColdFusion#Adobe_ColdFusion_10
"11.0.0": datetime(2014, 4, 29), # https://en.wikipedia.org/wiki/Adobe_ColdFusion#Adobe_ColdFusion_11
"2016.0.0": datetime(2016, 2, 16), # https://en.wikipedia.org/wiki/Adobe_ColdFusion#Adobe_ColdFusion_(2016_Release)
"2018.0.0": datetime(2018, 7, 12), # https://coldfusion.adobe.com/2018/07/new-coldfusion-release-adds-performance-monitoring-toolset-for-measuring-monitoring-and-managing-high-performing-web-apps/
"2021.0.0": datetime(2020, 11, 11), # https://community.adobe.com/t5/coldfusion-discussions/introducing-adobe-coldfusion-2021-release/m-p/11585468
"2023.0.0": datetime(2022, 5, 16), # https://coldfusion.adobe.com/2023/05/coldfusion2023-release/
}
for response in http.fetch_urls(URLS):
soup = BeautifulSoup(response.text, features="html5lib")
for p in soup.findAll("div", class_="text"):
text = p.get_text().strip().replace('\xa0', ' ')
matches = re.findall(REGEX, text, re.DOTALL | re.MULTILINE)
for m in matches:
date = dates.parse_date(m[0]).strftime("%Y-%m-%d")
version = m[1].strip().replace(",",".")
versions[version] = date
print(f"{version}: {date}")
product = endoflife.Product("coldfusion")
print(f"::group::{product.name}")
endoflife.write_releases(PRODUCT, versions)
for changelog in http.fetch_urls(URLS):
changelog_soup = BeautifulSoup(changelog.text, features="html5lib")
for p in changelog_soup.findAll("div", class_="text"):
version_and_date_str = p.get_text().strip().replace('\xa0', ' ')
for (date_str, version_str) in VERSION_AND_DATE_PATTERN.findall(version_and_date_str):
date = dates.parse_date(date_str)
version = version_str.strip().replace(",", ".") # 11,0,0,289974 -> 11.0.0.289974
product.declare_version(version, date)
product.declare_versions(FIXED_VERSIONS)
product.write()
print("::endgroup::")