]>
apps.delaporte.us Git - dotfiles.git/blob - 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
6 from datetime
import datetime
as dt
7 from datetime
import timedelta
10 HOME
= os
.path
.expanduser('~')
11 DATE_FORMAT
= '%Y-%m-%d'
12 TODAY
= dt
.now().strftime(DATE_FORMAT
)
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('|')
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)
27 df
= read_ods(ODS_FILE
)
32 def print_week(c
, person
, monday
):
33 print(f
'# {person}\'s Assignements for Week of {monday}')
35 day
= dt
.strptime(monday
, DATE_FORMAT
)
37 print_day(c
, person
, day
.strftime(DATE_FORMAT
))
38 day
= day
+ timedelta(days
=1)
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')
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')
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)
60 def get_todays_assignments(df
, date
, person
):
61 mine
= df
[df
['person'] == person
]
62 today
= mine
[mine
['date'] == date
]
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}')
74 def missing(c
, monday
, person
=None):
77 for person
in STUDENTS
:
78 missing(c
, monday
, person
)
80 day
= dt
.strptime(monday
, DATE_FORMAT
)
82 missing_on_day(c
, person
, day
.strftime(DATE_FORMAT
))
83 day
= day
+ timedelta(days
=1)
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
]
93 weekday
= dt
.strptime(date
, DATE_FORMAT
).strftime('%A')
97 print(f
"## {person}'s Assignments for {weekday}, {date}")
99 for subject
, row
in today
.groupby('subject'):
102 print(f
'### {row["subject"].values[0]}')
104 for task
in row
['task'].values
:
106 print(f
'- [ ] {task}')
107 if(len(row
['tip'].values
) > 0):
108 for tip
in row
['tip'].values
:
111 print(f
'> Tip: {tip}')
113 if(len(row
['when_done'].values
) > 0):
114 for tip
in row
['when_done'].values
:
117 print(f
'**When done**: {tip}')