]> us-delaporte.pagekite.me Git - dotfiles.git/blob - invoke/school/tasks.py
Update fix for Firefox
[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/assignments.ods'
16 BIN = f'{HOME}/envs/invoke/bin'
17 STUDENTS = os.environ.get('STUDENTS').split('|')
18
19 @task
20 def open_assignments(c):
21 print("LibreOffice does not like to be launched this way.")
22 # c.run(f'libreoffice {ODS_FILE}', asynchronous=True)
23
24
25 @task
26 def dump_ods(c):
27 df = read_ods(ODS_FILE)
28 print(df)
29
30
31 @task
32 def print_week(c, person, monday):
33 print(f'# {person}\'s Assignements for Week of {monday}')
34
35 day = dt.strptime(monday, DATE_FORMAT)
36 for i in range(0,5):
37 print_day(c, person, day.strftime(DATE_FORMAT))
38 day = day + timedelta(days=1)
39
40 @task
41 def md_week(c, person, monday):
42 c.run(f'cd {SCHOOL_DIR};{BIN}/invoke print-week {person} {monday} > {SCHOOL_DIR}/{person}.{monday}.md')
43
44
45 @task
46 def show_all(c, monday):
47 for person in STUDENTS:
48 md_week(c, person, monday)
49 c.run(f'codium {SCHOOL_DIR}/{person}.{monday}.md')
50
51 @task
52 def html_all(c, monday):
53 for person in STUDENTS:
54 md_week(c, person, monday)
55 c.run(f'cd {SCHOOL_DIR};{BIN}/markdown_py {person}.{monday}.md > {SCHOOL_DIR}/{person}.{monday}.html')
56 c.run(f'cat {SCHOOL_DIR}/style.html >> {SCHOOL_DIR}/{person}.{monday}.html')
57 c.run(f'librewolf {SCHOOL_DIR}/{person}.{monday}.html', asynchronous=True)
58
59
60 def get_todays_assignments(df, date, person):
61 mine = df[df['person'] == person]
62 today = mine[mine['date'] == date]
63 return today
64
65 @task
66 def missing_on_day(c, person, day):
67 df = read_ods(ODS_FILE)
68 today = get_todays_assignments(df, day, person)
69 for subject in ['College Prep', 'Life Skills', 'Job Prep']:
70 if not 'All Day Event' in today['subject'].values and not subject in today['subject'].values:
71 print(f'Missing {subject} for {person} on {day}')
72
73 @task
74 def missing(c, monday, person=None):
75
76 if not person:
77 for person in STUDENTS:
78 missing(c, monday, person)
79 else:
80 day = dt.strptime(monday, DATE_FORMAT)
81 for i in range(0,5):
82 missing_on_day(c, person, day.strftime(DATE_FORMAT))
83 day = day + timedelta(days=1)
84
85 @task
86 def print_day(c, person, date):
87 df = read_ods(ODS_FILE)
88 # df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d')
89 # today = df.loc(df['date'] >= '2026-01-12')
90 mine = df[df['person'] == person]
91 today = mine[mine['date'] == date]
92
93 weekday = dt.strptime(date, DATE_FORMAT).strftime('%A')
94
95 print()
96 print()
97 print(f"## {person}'s Assignments for {weekday}, {date}")
98
99 for subject, row in today.groupby('subject'):
100 print()
101 print()
102 print(f'### {row["subject"].values[0]}')
103 print()
104 for task in row['task'].values:
105 print()
106 print(f'- [ ] {task}')
107 if(len(row['tip'].values) > 0):
108 for tip in row['tip'].values:
109 if tip:
110 print()
111 print(f'> Tip: {tip}')
112
113 if(len(row['when_done'].values) > 0):
114 for tip in row['when_done'].values:
115 if tip:
116 print()
117 print(f'**When done**: {tip}')
118
119 @task
120 def files(c):
121 c.run('dolphin .')
122
123