41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import argparse
|
|
import hashlib
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="Describe a reviewed wheel for the web updater."
|
|
)
|
|
parser.add_argument("wheel", type=Path)
|
|
parser.add_argument("upgrade_from", nargs="+")
|
|
args = parser.parse_args()
|
|
version_pattern = r"\d+\.\d+\.\d+(?:rc\d+)?"
|
|
match = re.fullmatch(
|
|
rf"coulobre_panel-({version_pattern})-py3-none-any\.whl",
|
|
args.wheel.name,
|
|
)
|
|
if match is None or any(
|
|
not re.fullmatch(version_pattern, item) for item in args.upgrade_from
|
|
):
|
|
parser.error("Use a Coulobre wheel and the tested installed versions.")
|
|
with args.wheel.open("rb") as wheel:
|
|
checksum = hashlib.file_digest(wheel, "sha256").hexdigest()
|
|
print(
|
|
json.dumps(
|
|
{
|
|
"schema": 1,
|
|
"version": match[1],
|
|
"upgrade_from": args.upgrade_from,
|
|
"sha256": checksum,
|
|
},
|
|
indent=2,
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|