]> us-delaporte.pagekite.me Git - dotfiles.git/blobdiff - invoke/school/tasks.py
Fix for NaN text from ods reader
[dotfiles.git] / invoke / school / tasks.py
index 5be7ba63c8434b2cc81c740dc8bd095266424f1d..d7c89e6c34787b3d8836667300962ff969a4f14f 100644 (file)
@@ -1,8 +1,7 @@
-# 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
-import pdfkit
+from weasyprint import HTML
 
 from datetime import datetime as dt
 from datetime import timedelta
@@ -27,8 +26,9 @@ def code(c, path):
 
 
 def folder(c, path):
-    c.run(f'dolphin {path}', asynchronous=True)
+    # c.run(f'dolphin {path}', asynchronous=True)
     # c.run(f"nemo {path}")
+    c.run(f'konsole --workdir {path}',asynchronous=True)
 
 
 @task
@@ -84,7 +84,11 @@ def preview_all(c, monday):
 def make_all(c, monday):
     html_all(c, monday)
     for person in STUDENTS:
-        pdfkit.from_file(f'{SCHOOL_DIR}/{person}.{monday}.html', f'{SCHOOL_DIR}/{person}.{monday}.pdf', options={"enable-local-file-access": True})
+        html = f'{SCHOOL_DIR}/{person}.{monday}.html'
+        pdf = f'{SCHOOL_DIR}/{person}.{monday}.pdf'
+        HTML(html).write_pdf(pdf)
+        c.run(f'librewolf {SCHOOL_DIR}/{person}.{monday}.pdf', asynchronous=True)
+        
 
 def get_todays_assignments(df, date, person):
     mine = df[df['person'] == person]
@@ -95,7 +99,7 @@ def get_todays_assignments(df, date, person):
 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']:
+    for subject in ['College Prep', 'Life Skills', 'Job Prep', 'Health Science']:
         if not 'All Day Event' in today['subject'].values and not subject in today['subject'].values:
             print(f'Missing {subject} for {person} on {day}')
 
@@ -136,15 +140,17 @@ def print_day(c, person, date):
             print(f'- [ ] {task}')
         if(len(row['tip'].values) > 0):
             for tip in row['tip'].values:
-                if tip:
+                # Sometimes a float.
+                if hasattr(tip, 'strip'):
                     print()
-                    print(f'> Tip: {tip}')
+                    print(f'> Tip: {tip.strip()}')
 
         if(len(row['when_done'].values) > 0):
             for tip in row['when_done'].values:
-                if tip:
+                # Sometimes a float.
+                if hasattr(tip, 'strip'):
                     print()
-                    print(f'**When done**: {tip}')
+                    print(f'**When done**: {tip}.strip()')
 
 @task
 def files(c):
@@ -162,3 +168,12 @@ def fresh_week(c):
     c.run(f'mv {SCHOOL_DIR}/*.pdf {ARCHIVE}')
 
 
+@task
+def checklist(c):
+    print('- [ ] `fresh-week` to clean up old files.')
+    print('- [ ] start libreoffice and open `assignements.ods`')
+    print('- [ ] copy a previous sheet to be the new first sheet, and update the date Monday date.')
+    print('- [ ] `invoke missing YYYY.MM.DD` the .ods file.')
+    print('- [ ] `invoke make-all YYYY.MM.DD` to generate PDF files')
+    print('- [ ] review the PDF files and recreate if needed.')
+