Align custom scripts with generic scripts (#445)
Align custom scripts with generic scripts, making them configurable. This has a few advantages: - script code is more unified, - no more hard-coded method names in scripts, which is less error prone and make it easier to rename scripts, - no more hard coded product names in scripts, which is less error prone and make it easier to rename products, - less hard-coded URLs and regexes in scripts, which makes auto-configuration more expressive / updatable, Also added method `endoflife.list_configs_from_argv()` so that it is easier to manipulate scripts arguments.
This commit is contained in:
@@ -1,41 +1,42 @@
|
||||
import logging
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from common import dates, http, releasedata
|
||||
from common import dates, endoflife, http, releasedata
|
||||
|
||||
"""Fetches RedHat JBoss EAP version data for JBoss 7"""
|
||||
|
||||
with releasedata.ProductData("red-hat-jboss-eap") as product_data:
|
||||
response = http.fetch_url("https://access.redhat.com/articles/2332721")
|
||||
soup = BeautifulSoup(response.text, features="html5lib")
|
||||
for config in endoflife.list_configs_from_argv():
|
||||
with releasedata.ProductData(config.product) as product_data:
|
||||
response = http.fetch_url(config.url)
|
||||
soup = BeautifulSoup(response.text, features="html5lib")
|
||||
|
||||
for h4 in soup.find_all("h4"):
|
||||
title = h4.get_text(strip=True)
|
||||
if not title.startswith("7."):
|
||||
continue
|
||||
|
||||
release = title[:3]
|
||||
version_table = h4.find_next("table")
|
||||
if not version_table:
|
||||
logging.warning(f"Version table not found for {title}")
|
||||
continue
|
||||
|
||||
for (i, row) in enumerate(version_table.find_all("tr")):
|
||||
if i == 0: # Skip the first row (header)
|
||||
for h4 in soup.find_all("h4"):
|
||||
title = h4.get_text(strip=True)
|
||||
if not title.startswith("7."):
|
||||
continue
|
||||
|
||||
columns = row.find_all("td")
|
||||
# Get the version name without the content of the <sup> tag, if present
|
||||
name_str = ''.join([content for content in columns[0].contents if isinstance(content, str)]).strip()
|
||||
date_str = columns[1].text.strip()
|
||||
|
||||
if date_str == "TBD" or date_str == "TDB": # Placeholder for a future release
|
||||
release = title[:3]
|
||||
version_table = h4.find_next("table")
|
||||
if not version_table:
|
||||
logging.warning(f"Version table not found for {title}")
|
||||
continue
|
||||
|
||||
if date_str == "[July 21, 2021][d7400]":
|
||||
# Temporary fix for a typo in the source page
|
||||
date_str = "July 21 2021"
|
||||
for (i, row) in enumerate(version_table.find_all("tr")):
|
||||
if i == 0: # Skip the first row (header)
|
||||
continue
|
||||
|
||||
name = name_str.replace("GA", "Update 0").replace("Update ", release + ".")
|
||||
date = dates.parse_date(date_str)
|
||||
product_data.declare_version(name, date)
|
||||
columns = row.find_all("td")
|
||||
# Get the version name without the content of the <sup> tag, if present
|
||||
name_str = ''.join([content for content in columns[0].contents if isinstance(content, str)]).strip()
|
||||
date_str = columns[1].text.strip()
|
||||
|
||||
if date_str == "TBD" or date_str == "TDB": # Placeholder for a future release
|
||||
continue
|
||||
|
||||
if date_str == "[July 21, 2021][d7400]":
|
||||
# Temporary fix for a typo in the source page
|
||||
date_str = "July 21 2021"
|
||||
|
||||
name = name_str.replace("GA", "Update 0").replace("Update ", release + ".")
|
||||
date = dates.parse_date(date_str)
|
||||
product_data.declare_version(name, date)
|
||||
|
||||
Reference in New Issue
Block a user