File size: 973 Bytes
e94c8f8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #!/usr/bin/env python3
"""Fetch one draft year from Basketball-Reference and rebuild the panel.
Usage:
python extend_year.py --year 2021
python extend_year.py --year 2027 --force
"""
from __future__ import annotations
import argparse
import subprocess
import sys
from pathlib import Path
SCRIPTS = Path(__file__).resolve().parent
def main() -> None:
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument("--year", type=int, required=True)
ap.add_argument("--force", action="store_true", help="refetch player pages")
args = ap.parse_args()
fetch = [
sys.executable,
str(SCRIPTS / "fetch_bbref_draft_hs.py"),
"--years",
str(args.year),
]
if args.force:
fetch.append("--force")
subprocess.check_call(fetch)
subprocess.check_call([sys.executable, str(SCRIPTS / "build_panel.py")])
print(f"Extended panel with draft year {args.year}")
if __name__ == "__main__":
main()
|