From 1f21d0475ff94aefd7fd8f7e28940ce389669db5 Mon Sep 17 00:00:00 2001 From: knoflook Date: Thu, 3 Feb 2022 12:50:15 +0100 Subject: [PATCH] cal: add event name to filename --- lumbunglib/cloudcal.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lumbunglib/cloudcal.py b/lumbunglib/cloudcal.py index d3d482f..fd27482 100644 --- a/lumbunglib/cloudcal.py +++ b/lumbunglib/cloudcal.py @@ -110,6 +110,11 @@ def localize_time(date): ) return localized_begins +def sanitize_name(name): + sanitized = "".join([c if c.isalnum() or c == " " else "-" for c in name]) + if len(sanitized) > 20: + return sanitized[:20] + return sanitized def create_event_post(post_dir, event): """ @@ -186,7 +191,7 @@ def update_event_post(post_dir, event): def main(): for event in list(cal.events): - post_dir = os.path.join(output_dir, event.uid) + post_dir = os.path.join(output_dir, sanitize_name(event.name) + "-" + event.uid) if event.uid not in existing_posts: # if there is an event we dont already have, make it