diff options
author | Blaise Thompson <blaise@untzag.com> | 2024-09-08 20:00:28 -0500 |
---|---|---|
committer | Blaise Thompson <blaise@untzag.com> | 2024-09-08 20:00:28 -0500 |
commit | 085435b289badabc6791982486c5f6d330730405 (patch) | |
tree | 30722b0d4c5b4c2b739535a404affbebca27ec7b /build.py | |
parent | bab7f737c637e8b3be373abeb6db545018ae5d9f (diff) |
Diffstat (limited to 'build.py')
-rw-r--r-- | build.py | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -17,7 +17,7 @@ latest_scheduled = datetime.date.today() class Event: - def __init__(self, line): + def __init__(self, line, prefix=""): global latest_scheduled # timestamp (start time) year, month, day = (int(s) for s in line.split("<")[1][0:10].split("-")) @@ -35,7 +35,7 @@ class Event: # time of day tod = line[line.find("<") + 1 : line.find(">")][15:] # description - self.description = " ".join(filter(None, [tod, line.split(">")[-1].strip()])) + self.description = " ".join(filter(None, [tod, prefix, line.split(">")[-1].strip()])) org_fp = "/home/nginx/org/agenda.org" @@ -72,7 +72,20 @@ with open(org_fp, "r") as org: continue if ":info:" in line: continue - events.append(Event(line)) + events.append(Event(line, prefix="⚗️")) + + +# sort ------------------------------------------------------------------------------------------- + + +def get_timestamp(event): + if event.description[0].isdigit(): + return f"__{event.description}" + else: + return event.description + + +sorted_events = sorted(events, key=get_timestamp) # create html ------------------------------------------------------------------------------------- @@ -117,7 +130,7 @@ with open(__here__ / "public" / "index.html", "w") as html: html.write( f"<h3 id={id}><a href=#{id}>{day.isoformat()} {day.strftime('%A')}</a></h3>" ) - for event in events: + for event in sorted_events: try: total = event.end - event.timestamp assert total.days > 0 |