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.
24 lines
946 B
Python
24 lines
946 B
Python
from datetime import datetime, timezone
|
|
|
|
from common import endoflife, http, releasedata
|
|
|
|
for config in endoflife.list_configs_from_argv():
|
|
with releasedata.ProductData(config.product) as product_data:
|
|
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.fromtimestamp(row["timestamp"] / 1000, tz=timezone.utc)
|
|
product_data.declare_version(version, date)
|
|
|
|
start += 100
|
|
if data["response"]["numFound"] <= start:
|
|
break
|