From 085435b289badabc6791982486c5f6d330730405 Mon Sep 17 00:00:00 2001 From: Blaise Thompson Date: Sun, 8 Sep 2024 20:00:28 -0500 Subject: sorted --- build.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'build.py') diff --git a/build.py b/build.py index 8427010..24fe7b2 100644 --- a/build.py +++ b/build.py @@ -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"

{day.isoformat()} {day.strftime('%A')}

" ) - for event in events: + for event in sorted_events: try: total = event.end - event.timestamp assert total.days > 0 -- cgit v1.2.3