Files
endoflife-date-release-data/src/maven.py
Marc Wrobel 959b1865bf [maven] Refactor script (#234)
Make the script more readable, mostly by:

- using the Product and AutoConfig classes,
- removing the use of functions when unnecessary,
- a little bit of renaming and documentation.

This auto method also now support custom regexes and template.
2023-12-11 21:24:02 +01:00

34 lines
1.1 KiB
Python

import datetime
import sys
from common import http
from common import endoflife
METHOD = "maven"
p_filter = sys.argv[1] if len(sys.argv) > 1 else None
for product_name, configs in endoflife.list_products(METHOD, p_filter).items():
print(f"::group::{product_name}")
product = endoflife.Product(product_name, load_product_data=True)
for config in product.get_auto_configs(METHOD):
start = 0
group_id, artifact_id = config.url.split("/")
while True:
url = f"https://search.maven.org/solrsearch/select?q=g:{group_id}+AND+a:{artifact_id}&core=gav&wt=json&start={start}&rows=100"
data = http.fetch_url(url).json()
for row in data["response"]["docs"]:
version_match = config.first_match(row["v"])
if version_match:
version = config.render(version_match)
date = datetime.datetime.utcfromtimestamp(row["timestamp"] / 1000)
product.declare_version(version, date)
start += 100
if data["response"]["numFound"] <= start:
break
product.write()
print("::endgroup::")