From: Edward Delaporte Date: Mon, 19 Jan 2026 18:31:51 +0000 (-0600) Subject: Add helper script for school assignments X-Git-Url: https://apps.delaporte.us/gitweb/dotfiles.git/commitdiff_plain/d6d2d8e00c52d4f2dc6ad1ef3a91a013a9b7058c?ds=inline Add helper script for school assignments --- diff --git a/invoke/school/tasks.py b/invoke/school/tasks.py new file mode 100644 index 0000000..b1dbdca --- /dev/null +++ b/invoke/school/tasks.py @@ -0,0 +1,111 @@ +# This file is meant to sit in ~ for use from all shells. +from invoke import task +from pandas_ods_reader import read_ods +import pandas as pd + +from datetime import datetime as dt +from datetime import timedelta +import os + +HOME = os.path.expanduser('~') +DATE_FORMAT = '%Y-%m-%d' +TODAY = dt.now().strftime(DATE_FORMAT) + +SCHOOL_DIR = f'{HOME}/School/Assignments' +ODS_FILE = f'{HOME}/School/Assignments/tasks.ods' +BIN = f'{HOME}/envs/invoke/bin' +STUDENTS = os.environ.get('STUDENTS').split('|') + + +@task +def dump_ods(c): + df = read_ods(ODS_FILE) + print(df) + + +@task +def print_week(c, person, monday): + print(f'# {person}\'s Assignements for Week of {monday}') + + day = dt.strptime(monday, DATE_FORMAT) + for i in range(0,5): + print_day(c, person, day.strftime(DATE_FORMAT)) + day = day + timedelta(days=1) + +@task +def md_week(c, person, monday): + c.run(f'cd {SCHOOL_DIR};{BIN}/invoke print-week {person} {monday} > {person}.{monday}.md') + + +@task +def show_all(c, monday): + for person in STUDENTS: + md_week(c, person, monday) + c.run(f'codium {person}.{monday}.md') + +@task +def html_all(c, monday): + for person in STUDENTS: + md_week(c, person, monday) + c.run(f'cd {SCHOOL_DIR};{BIN}/markdown_py {person}.{monday}.md > {person}.{monday}.html') + c.run(f'librewolf {person}.{monday}.html') + + +def get_todays_assignments(df, date, person): + mine = df[df['person'] == person] + today = mine[mine['date'] == date] + return today + +@task +def missing_on_day(c, person, day): + df = read_ods(ODS_FILE) + today = get_todays_assignments(df, day, person) + for subject in ['College Prep', 'Life Skills', 'Job Prep']: + if not subject in today['subject'].values: + print(f'Missing {subject} for {person} on {day}') + +@task +def missing(c, monday, person=None): + + if not person: + for person in STUDENTS: + missing(c, monday, person) + else: + day = dt.strptime(monday, DATE_FORMAT) + for i in range(0,5): + missing_on_day(c, person, day.strftime(DATE_FORMAT)) + day = day + timedelta(days=1) + +@task +def print_day(c, person, date): + df = read_ods(ODS_FILE) + # df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d') + # today = df.loc(df['date'] >= '2026-01-12') + mine = df[df['person'] == person] + today = mine[mine['date'] == date] + + weekday = dt.strptime(date, DATE_FORMAT).strftime('%A') + + print() + print() + print(f"## {person}'s Assignments for {weekday}, {date}") + + for _, row in today.iterrows(): + print() + print() + print(f'### {row["subject"]}') + print() + print(row['task']) + if(row['tip']): + print() + print(f'> Tip: {row["tip"]}') + + if(row['when_done']): + print() + print(f'**When done**: {row["when_done"]}') + +@task +def files(c): + c.run('dolphin .') + +