Make releasedata.Product usable in 'with' expression (#294)
This way the writing of the JSON file is handled automatically if the update does not fail. It pave the way to further global improvements, such as a better error handling.
This commit is contained in:
@@ -18,23 +18,22 @@ MANUAL_VERSIONS = {
|
||||
"7.2.0": dates.date(2023, 6, 1), # https://www.couchbase.com/blog/couchbase-capella-spring-release-72/
|
||||
}
|
||||
|
||||
product = releasedata.Product("couchbase-server")
|
||||
main = http.fetch_url(f"{URLS}/current/install/install-intro.html")
|
||||
main_soup = BeautifulSoup(main.text, features="html5lib")
|
||||
with releasedata.ProductData("couchbase-server") as product_data:
|
||||
main = http.fetch_url(f"{URLS}/current/install/install-intro.html")
|
||||
main_soup = BeautifulSoup(main.text, features="html5lib")
|
||||
|
||||
minor_versions = [options.attrs["value"] for options in main_soup.find(class_="version_list").find_all("option")]
|
||||
minor_version_urls = [f"{URLS}/{minor}/release-notes/relnotes.html" for minor in minor_versions]
|
||||
minor_versions = [options.attrs["value"] for options in main_soup.find(class_="version_list").find_all("option")]
|
||||
minor_version_urls = [f"{URLS}/{minor}/release-notes/relnotes.html" for minor in minor_versions]
|
||||
|
||||
for minor_version in http.fetch_urls(minor_version_urls):
|
||||
minor_version_soup = BeautifulSoup(minor_version.text, features="html5lib")
|
||||
for minor_version in http.fetch_urls(minor_version_urls):
|
||||
minor_version_soup = BeautifulSoup(minor_version.text, features="html5lib")
|
||||
|
||||
for title in minor_version_soup.find_all("h2"):
|
||||
match = VERSION_AND_DATE_PATTERN.match(title.get_text().strip())
|
||||
if match:
|
||||
version = match["version"]
|
||||
version = f"{version}.0" if len(version.split(".")) == 2 else version
|
||||
date = dates.parse_month_year_date(match['date'])
|
||||
product.declare_version(version, date)
|
||||
for title in minor_version_soup.find_all("h2"):
|
||||
match = VERSION_AND_DATE_PATTERN.match(title.get_text().strip())
|
||||
if match:
|
||||
version = match["version"]
|
||||
version = f"{version}.0" if len(version.split(".")) == 2 else version
|
||||
date = dates.parse_month_year_date(match['date'])
|
||||
product_data.declare_version(version, date)
|
||||
|
||||
product.declare_versions(MANUAL_VERSIONS)
|
||||
product.write()
|
||||
product_data.declare_versions(MANUAL_VERSIONS)
|
||||
|
||||
Reference in New Issue
Block a user