Simplify endoflife.list_products usage (#292)

Make endoflife.list_products return product instead of just the product name, to avoid having to reload the product a second time to get more information.
This commit is contained in:
Marc Wrobel
2024-02-03 00:26:23 +01:00
committed by GitHub
parent e4fc52c2a9
commit 8f6efad2cc
9 changed files with 49 additions and 55 deletions

View File

@@ -5,16 +5,15 @@ from common import dates, endoflife, http, releasedata
METHOD = "npm"
p_filter = sys.argv[1] if len(sys.argv) > 1 else None
for product_name in endoflife.list_products(METHOD, p_filter):
product = releasedata.Product(product_name)
product_frontmatter = endoflife.ProductFrontmatter(product.name)
for config in product_frontmatter.get_auto_configs(METHOD):
for product in endoflife.list_products(METHOD, p_filter):
product_data = releasedata.Product(product.name)
for config in product.get_auto_configs(METHOD):
data = http.fetch_url(f"https://registry.npmjs.org/{config.url}").json()
for version_str in data["versions"]:
version_match = config.first_match(version_str)
if version_match:
version = config.render(version_match)
date = dates.parse_datetime(data["time"][version_str])
product.declare_version(version, date)
product_data.declare_version(version, date)
product.write()
product_data.write()