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,5 +1,5 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from common import dates, github, http, releasedata
|
||||
from common import dates, endoflife, github, http, releasedata
|
||||
|
||||
"""Fetch released versions from docs.chef.io and retrieve their date from GitHub.
|
||||
docs.chef.io needs to be scraped because not all tagged versions are actually released.
|
||||
@@ -7,13 +7,14 @@ docs.chef.io needs to be scraped because not all tagged versions are actually re
|
||||
More context on https://github.com/endoflife-date/endoflife.date/pull/4425#discussion_r1447932411.
|
||||
"""
|
||||
|
||||
with releasedata.ProductData("chef-inspec") as product_data:
|
||||
rn_response = http.fetch_url("https://docs.chef.io/release_notes_inspec/")
|
||||
rn_soup = BeautifulSoup(rn_response.text, features="html5lib")
|
||||
released_versions = [h2.get('id') for h2 in rn_soup.find_all('h2', id=True) if h2.get('id')]
|
||||
for config in endoflife.list_configs_from_argv():
|
||||
with releasedata.ProductData(config.product) as product_data:
|
||||
rn_response = http.fetch_url(config.url)
|
||||
rn_soup = BeautifulSoup(rn_response.text, features="html5lib")
|
||||
released_versions = [h2.get('id') for h2 in rn_soup.find_all('h2', id=True) if h2.get('id')]
|
||||
|
||||
for release in github.fetch_releases("inspec/inspec"):
|
||||
sanitized_version = release.tag_name.replace("v", "")
|
||||
if sanitized_version in released_versions:
|
||||
date = dates.parse_datetime(release.published_at)
|
||||
product_data.declare_version(sanitized_version, date)
|
||||
for release in github.fetch_releases("inspec/inspec"):
|
||||
sanitized_version = release.tag_name.replace("v", "")
|
||||
if sanitized_version in released_versions:
|
||||
date = dates.parse_datetime(release.published_at)
|
||||
product_data.declare_version(sanitized_version, date)
|
||||
|
||||
Reference in New Issue
Block a user