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,7 +1,7 @@
|
||||
import re
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from common import dates, http, releasedata
|
||||
from common import dates, endoflife, http, releasedata
|
||||
|
||||
# https://regex101.com/r/zPxBqT/1
|
||||
VERSION_PATTERN = re.compile(r"\d.\d+\.\d+-gke\.\d+")
|
||||
@@ -12,17 +12,18 @@ URL_BY_PRODUCT = {
|
||||
"google-kubernetes-engine-rapid": "https://cloud.google.com/kubernetes-engine/docs/release-notes-rapid",
|
||||
}
|
||||
|
||||
for product_name, url in URL_BY_PRODUCT.items():
|
||||
with releasedata.ProductData(product_name) as product_data:
|
||||
relnotes = http.fetch_url(url)
|
||||
relnotes_soup = BeautifulSoup(relnotes.text, features="html5lib")
|
||||
for config in endoflife.list_configs_from_argv(): # noqa: B007 multiple JSON produced for historical reasons
|
||||
for product_name, url in URL_BY_PRODUCT.items():
|
||||
with releasedata.ProductData(product_name) as product_data:
|
||||
relnotes = http.fetch_url(url)
|
||||
relnotes_soup = BeautifulSoup(relnotes.text, features="html5lib")
|
||||
|
||||
for section in relnotes_soup.find_all('section', class_='releases'):
|
||||
for h2 in section.find_all('h2'): # h2 contains the date
|
||||
date = dates.parse_date(h2.get('data-text'))
|
||||
for section in relnotes_soup.find_all('section', class_='releases'):
|
||||
for h2 in section.find_all('h2'): # h2 contains the date
|
||||
date = dates.parse_date(h2.get('data-text'))
|
||||
|
||||
next_div = h2.find_next('div') # The div next to the h2 contains the notes about changes made on that date
|
||||
for li in next_div.find_all('li'):
|
||||
if "versions are now available" in li.text:
|
||||
for version in VERSION_PATTERN.findall(li.find('ul').text):
|
||||
product_data.declare_version(version, date)
|
||||
next_div = h2.find_next('div') # The div next to the h2 contains the notes about changes made on that date
|
||||
for li in next_div.find_all('li'):
|
||||
if "versions are now available" in li.text:
|
||||
for version in VERSION_PATTERN.findall(li.find('ul').text):
|
||||
product_data.declare_version(version, date)
|
||||
|
||||
Reference in New Issue
Block a user