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.
21 lines
961 B
Python
21 lines
961 B
Python
from bs4 import BeautifulSoup
|
|
from common import dates, endoflife, http, releasedata
|
|
|
|
for config in endoflife.list_configs_from_argv():
|
|
with releasedata.ProductData(config.product) as product_data:
|
|
response = http.fetch_url(f"https://distrowatch.com/index.php?distribution={config.url}")
|
|
soup = BeautifulSoup(response.text, features="html5lib")
|
|
|
|
for table in soup.select("td.News1>table.News"):
|
|
headline = table.select_one("td.NewsHeadline a[href]").get_text().strip()
|
|
versions_match = config.first_match(headline)
|
|
if not versions_match:
|
|
continue
|
|
|
|
# multiple versions may be released at once (e.g. Ubuntu 16.04.7 and 18.04.5)
|
|
versions = config.render(versions_match).split("\n")
|
|
date = dates.parse_date(table.select_one("td.NewsDate").get_text())
|
|
|
|
for version in versions:
|
|
product_data.declare_version(version, date)
|