[plesk] Refactor script (#241)

Make the script more readable, mostly by:

- using the Product class,
- removing the use of functions when unnecessary,
- a little bit of renaming and documentation.
This commit is contained in:
Marc Wrobel
2023-12-11 22:21:37 +01:00
committed by GitHub
parent c54f71b6b6
commit b6072e3ef3

View File

@@ -3,39 +3,27 @@ from common import http
from common import dates
from common import endoflife
URL = "https://docs.plesk.com/release-notes/obsidian/change-log"
PRODUCT = "plesk"
"""Fetches versions from Plesk's change log.
Only 18.0.20.3 and later will be picked up, as the format of the change log for 18.0.20 and 18.0.19 are different and
there is no entry for GA of version 18.0.18 and older."""
def make_bs_request(url):
response = http.fetch_url(url)
return BeautifulSoup(response.text, features="html5lib")
product = endoflife.Product("plesk")
print(f"::group::{product.name}")
response = http.fetch_url("https://docs.plesk.com/release-notes/obsidian/change-log")
soup = BeautifulSoup(response.text, features="html5lib")
for release in soup.find_all("div", class_="changelog-entry--obsidian"):
version = release.h2.text.strip()
if not version.startswith('Plesk Obsidian 18'):
continue
# Only 18.0.20.3 and later will be picked up :
# - format of the title for 18.0.20 and 18.0.19 are different,
# - there is not entry for GA of version 18.0.18 and older.
def fetch_releases():
result = {}
version = version.replace(' Update ', '.').replace('Plesk Obsidian ', '')
if ' ' in version:
continue
soup = make_bs_request(URL)
releases = soup.find_all("div", class_="changelog-entry--obsidian")
for release in releases:
version = release.h2.text.strip()
if not version.startswith('Plesk Obsidian 18'):
continue
date = dates.parse_date(release.p.text)
product.declare_version(version, date)
version = version.replace(' Update ', '.').replace('Plesk Obsidian ', '')
if ' ' in version:
continue
date = dates.parse_date(release.p.text).strftime("%Y-%m-%d")
result[version] = date
print(f"{version}: {date}")
return result
print(f"::group::{PRODUCT}")
versions = fetch_releases()
endoflife.write_releases(PRODUCT, versions)
product.write()
print("::endgroup::")