Fix report.py

This commit is contained in:
Marc Wrobel
2024-02-22 21:32:00 +01:00
parent 621e8fea74
commit d1a4918534
3 changed files with 313 additions and 315 deletions

View File

@@ -1,34 +1,20 @@
import sys
import time
from pathlib import Path
import frontmatter
from src.common import endoflife
products = {}
count = 0
count_auto = 0
products_dir = Path(sys.argv[1] if len(sys.argv) > 1 else 'website/products/')
for product_file in sorted(products_dir.glob('*.md')):
with product_file.open() as f:
data = frontmatter.load(f)
count += 1
title = data['title']
permalink = data['permalink']
if 'auto' in data:
count_auto += 1
method = list(data['auto'][0].keys())[0]
products[title] = [permalink, '✔️', method]
else:
products[title] = [permalink, '', 'n/a']
products = endoflife.list_products()
count_auto = len([product for product in products if product.auto_configs()])
print(f"As of {time.strftime('%Y-%m-%d')}, {count_auto} of the {count} products"
print(f"As of {time.strftime('%Y-%m-%d')}, {count_auto} of the {len(products)} products"
f" tracked by endoflife.date have automatically tracked releases:")
print()
print('| Product | Permalink | Auto | Method |')
print('|---------|-----------|------|--------|')
for product in sorted(products.keys(), key=str.lower):
permalink, auto, method = products[product]
print(f"| {product} | [`{permalink}`](https://endoflife.date{permalink}) | {auto} | {method} |")
print('| Product | Permalink | Auto | Method(s) |')
print('|---------|-----------|------|-----------|')
for product in products:
title = product.get_title()
permalink = product.get_permalink()
auto = '✔️' if product.has_auto_configs() else ''
methods = ', '.join(sorted({config.method for config in product.auto_configs()}))
print(f"| {title} | [`{permalink}`](https://endoflife.date{permalink}) | {auto} | {methods} |")
print()
print('This table has been generated by [report.py](/report.py).')