#!/usr/bin/env python3 """Render a dated class-schedule screenshot (default: Penn State LionPATH look). python docgen.py --first Nikita --last Reformov --out schedule.png The term label and copyright year are derived from the current date so the document never carries a stale semester (the first thing a reviewer flags). """ import argparse import os import random import sys from datetime import datetime MAJORS = ["Mechanical Engineering (BS)", "Computer Science (BS)", "Information Sciences and Technology (BS)", "Electrical Engineering (BS)"] COURSES = [ ("14920", "CMPSC 465", "Data Structures and Algorithms", "MoWeFr 10:10AM - 11:00AM", "Willard 062", "3.00"), ("18233", "MATH 230", "Calculus and Vector Analysis", "TuTh 1:35PM - 2:50PM", "Thomas 102", "4.00"), ("20491", "CMPSC 473", "Operating Systems Design", "MoWe 2:30PM - 3:45PM", "Westgate E201", "3.00"), ("11029", "ENGL 202C", "Technical Writing", "Fr 1:25PM - 2:15PM", "Boucke 304", "3.00"), ("15502", "STAT 318", "Elementary Probability", "TuTh 9:05AM - 10:20AM", "Osmond 112", "3.00"), ] def term(): now = datetime.now() if now.month >= 8: return f"Fall {now.year}", "Aug 24 - Dec 11" if now.month >= 5: return f"Summer {now.year}", "May 18 - Aug 7" return f"Spring {now.year}", "Jan 12 - May 1" def build_html(first, last, school_name="Penn State", psu_id=None): now = datetime.now() t_label, t_span = term() psu_id = psu_id or f"9{random.randint(10000000, 99999999)}" major = random.choice(MAJORS) rows = "".join( f"{a}{b}{c}{d}{e}{f}" for a, b, c, d, e, f in COURSES) return f"""
{school_name} | LionPATH
Welcome, {first} {last}  |  Sign Out
Student Home
My Class Schedule
Academics
Finances
Campus Life

My Class Schedule

Term: {t_label} ({t_span})
Student name
{first} {last}
PSU ID
{psu_id}
Academic program
{major}
Enrollment status
Enrolled
Data retrieved
{now.strftime('%m/%d/%Y, %I:%M:%S %p')}
{rows}
Class NbrCourseTitleDays & TimesRoomUnits
© {now.year} The Pennsylvania State University. All rights reserved.
LionPATH is the student information system for Penn State.
""" def main(): ap = argparse.ArgumentParser() ap.add_argument("--first", required=True) ap.add_argument("--last", required=True) ap.add_argument("--out", default="schedule.png") ap.add_argument("--html", default="", help="also dump the html") a = ap.parse_args() html = build_html(a.first, a.last) if a.html: open(a.html, "w", encoding="utf-8").write(html) from playwright.sync_api import sync_playwright with sync_playwright() as p: b = p.chromium.launch(headless=True) pg = b.new_page(viewport={"width": 1200, "height": 900}) pg.set_content(html, wait_until="load") pg.wait_for_timeout(400) pg.screenshot(path=a.out, type="png", full_page=True) b.close() print("WROTE", a.out, os.path.getsize(a.out), "bytes") if __name__ == "__main__": main()