Refactor scripts arguments handling (#456)
- remove the use of environment variables to get directory paths, - make use of arguments / argparse instead of environment variables in `update.py` and `report.py`, - automatically guess the data directory in `latest.py` based on the script's location, - propagate log level to auto scripts, - move `list_configs_from_argv` from `endoflife` module to `releasedata` module, - use `list_products` in `latest.py` to load the product's frontmatters.
This commit is contained in:
38
report.py
38
report.py
@@ -1,20 +1,28 @@
|
||||
import argparse
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from src.common import endoflife
|
||||
|
||||
products = endoflife.list_products()
|
||||
count_auto = len([product for product in products if product.auto_configs()])
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Create report on product automation.')
|
||||
parser.add_argument('-p', '--product-dir', required=True, help='path to the product directory')
|
||||
args = parser.parse_args()
|
||||
|
||||
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(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).')
|
||||
products_dir = Path(args.product_dir)
|
||||
products = endoflife.list_products(products_dir)
|
||||
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 {len(products)} products"
|
||||
f" tracked by endoflife.date have automatically tracked releases:")
|
||||
print()
|
||||
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).')
|
||||
|
||||
Reference in New Issue
Block a user