]> us-delaporte.pagekite.me Git - dotfiles.git/blob - invoke/school/tasks.py
Add helper script for school assignments
[dotfiles.git] / invoke / school / tasks.py
1 # This file is meant to sit in ~ for use from all shells.
2 from invoke import task
3 from pandas_ods_reader import read_ods
4 import pandas as pd
5
6 from datetime import datetime as dt
7 from datetime import timedelta
8 import os
9
10 HOME = os.path.expanduser('~')
11 DATE_FORMAT = '%Y-%m-%d'
12 TODAY = dt.now().strftime(DATE_FORMAT)
13
14 SCHOOL_DIR = f'{HOME}/School/Assignments'
15 ODS_FILE = f'{HOME}/School/Assignments/tasks.ods'
16 BIN = f'{HOME}/envs/invoke/bin'
17 STUDENTS = os.environ.get('STUDENTS').split('|')
18
19
20 @task
21 def dump_ods(c):
22 df = read_ods(ODS_FILE)
23 print(df)
24
25
26 @task
27 def print_week(c, person, monday):
28 print(f'# {person}\'s Assignements for Week of {monday}')
29
30 day = dt.strptime(monday, DATE_FORMAT)
31 for i in range(0,5):
32 print_day(c, person, day.strftime(DATE_FORMAT))
33 day = day + timedelta(days=1)
34
35 @task
36 def md_week(c, person, monday):
37 c.run(f'cd {SCHOOL_DIR};{BIN}/invoke print-week {person} {monday} > {person}.{monday}.md')
38
39
40 @task
41 def show_all(c, monday):
42 for person in STUDENTS:
43 md_week(c, person, monday)
44 c.run(f'codium {person}.{monday}.md')
45
46 @task
47 def html_all(c, monday):
48 for person in STUDENTS:
49 md_week(c, person, monday)
50 c.run(f'cd {SCHOOL_DIR};{BIN}/markdown_py {person}.{monday}.md > {person}.{monday}.html')
51 c.run(f'librewolf {person}.{monday}.html')
52
53
54 def get_todays_assignments(df, date, person):
55 mine = df[df['person'] == person]
56 today = mine[mine['date'] == date]
57 return today
58
59 @task
60 def missing_on_day(c, person, day):
61 df = read_ods(ODS_FILE)
62 today = get_todays_assignments(df, day, person)
63 for subject in ['College Prep', 'Life Skills', 'Job Prep']:
64 if not subject in today['subject'].values:
65 print(f'Missing {subject} for {person} on {day}')
66
67 @task
68 def missing(c, monday, person=None):
69
70 if not person:
71 for person in STUDENTS:
72 missing(c, monday, person)
73 else:
74 day = dt.strptime(monday, DATE_FORMAT)
75 for i in range(0,5):
76 missing_on_day(c, person, day.strftime(DATE_FORMAT))
77 day = day + timedelta(days=1)
78
79 @task
80 def print_day(c, person, date):
81 df = read_ods(ODS_FILE)
82 # df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d')
83 # today = df.loc(df['date'] >= '2026-01-12')
84 mine = df[df['person'] == person]
85 today = mine[mine['date'] == date]
86
87 weekday = dt.strptime(date, DATE_FORMAT).strftime('%A')
88
89 print()
90 print()
91 print(f"## {person}'s Assignments for {weekday}, {date}")
92
93 for _, row in today.iterrows():
94 print()
95 print()
96 print(f'### {row["subject"]}')
97 print()
98 print(row['task'])
99 if(row['tip']):
100 print()
101 print(f'> Tip: {row["tip"]}')
102
103 if(row['when_done']):
104 print()
105 print(f'**When done**: {row["when_done"]}')
106
107 @task
108 def files(c):
109 c.run('dolphin .')
110
111