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
7 from datetime
import datetime
as dt
8 from datetime
import timedelta
11 HOME
= os
.path
.expanduser('~')
12 DATE_FORMAT
= '%Y-%m-%d'
13 TODAY
= dt
.now().strftime(DATE_FORMAT
)
15 SCHOOL_DIR
= f
'{HOME}/School/Assignments'
16 ARCHIVE
= f
'{SCHOOL_DIR}/archive'
17 ODS_FILE
= f
'{HOME}/School/Assignments/assignments.ods'
18 BIN
= f
'{HOME}/envs/invoke/bin'
19 STUDENTS
= os
.environ
.get('STUDENTS').split('|')
22 c
.run(f
"librewolf {url}", asynchronous
=True)
26 c
.run(f
"codium {path}")
30 c
.run(f
'dolphin {path}', asynchronous
=True)
31 # c.run(f"nemo {path}")
41 df
= read_ods(ODS_FILE
)
46 def print_week(c
, person
, monday
):
47 print(f
'# {person}\'s Assignements for Week of {monday}')
49 motd
= open(f
'{SCHOOL_DIR}/motd.txt', 'r').read()
53 day
= dt
.strptime(monday
, DATE_FORMAT
)
55 print_day(c
, person
, day
.strftime(DATE_FORMAT
))
56 day
= day
+ timedelta(days
=1)
59 def md_week(c
, person
, monday
):
60 c
.run(f
'cd {SCHOOL_DIR};{BIN}/invoke print-week {person} {monday} > {SCHOOL_DIR}/{person}.{monday}.md')
64 def md_all(c
, monday
):
65 for person
in STUDENTS
:
66 md_week(c
, person
, monday
)
67 c
.run(f
'codium {SCHOOL_DIR}/{person}.{monday}.md')
70 def html_all(c
, monday
):
71 for person
in STUDENTS
:
72 missing(c
, monday
, person
) # Warn on any missing subjects.
73 md_week(c
, person
, monday
)
74 c
.run(f
'cd {SCHOOL_DIR};{BIN}/markdown_py {person}.{monday}.md > {SCHOOL_DIR}/{person}.{monday}.html')
75 c
.run(f
'cat {SCHOOL_DIR}/style.htm >> {SCHOOL_DIR}/{person}.{monday}.html')
78 def preview_all(c
, monday
):
80 for person
in STUDENTS
:
81 c
.run(f
'librewolf {SCHOOL_DIR}/{person}.{monday}.html', asynchronous
=True)
84 def make_all(c
, monday
):
86 for person
in STUDENTS
:
87 pdfkit
.from_file(f
'{SCHOOL_DIR}/{person}.{monday}.html', f
'{SCHOOL_DIR}/{person}.{monday}.pdf', options
={"enable-local-file-access": True}
)
89 def get_todays_assignments(df
, date
, person
):
90 mine
= df
[df
['person'] == person
]
91 today
= mine
[mine
['date'] == date
]
95 def missing_on_day(c
, person
, day
):
96 df
= read_ods(ODS_FILE
)
97 today
= get_todays_assignments(df
, day
, person
)
98 for subject
in ['College Prep', 'Life Skills', 'Job Prep']:
99 if not 'All Day Event' in today
['subject'].values
and not subject
in today
['subject'].values
:
100 print(f
'Missing {subject} for {person} on {day}')
103 def missing(c
, monday
, person
=None):
106 for person
in STUDENTS
:
107 missing(c
, monday
, person
)
109 day
= dt
.strptime(monday
, DATE_FORMAT
)
111 missing_on_day(c
, person
, day
.strftime(DATE_FORMAT
))
112 day
= day
+ timedelta(days
=1)
115 def print_day(c
, person
, date
):
116 df
= read_ods(ODS_FILE
)
117 # df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d')
118 # today = df.loc(df['date'] >= '2026-01-12')
119 mine
= df
[df
['person'] == person
]
120 today
= mine
[mine
['date'] == date
]
122 weekday
= dt
.strptime(date
, DATE_FORMAT
).strftime('%A')
126 print(f
"## {person}'s Assignments for {weekday}, {date}")
129 for subject
, row
in today
.groupby('subject'):
132 print(f
'### {row["subject"].values[0]}')
134 for task
in row
['task'].values
:
136 print(f
'- [ ] {task}')
137 if(len(row
['tip'].values
) > 0):
138 for tip
in row
['tip'].values
:
141 print(f
'> Tip: {tip}')
143 if(len(row
['when_done'].values
) > 0):
144 for tip
in row
['when_done'].values
:
147 print(f
'**When done**: {tip}')
156 c
.run(f
'mv {SCHOOL_DIR}/*.md {ARCHIVE}')
157 c
.run(f
'mv {SCHOOL_DIR}/*.html {ARCHIVE}')
158 c
.run(f
'mv {SCHOOL_DIR}/*.pdf {ARCHIVE}')