cal: add event name to filename

This commit is contained in:
knoflook 2022-02-03 12:50:15 +01:00
parent 3297991d83
commit 1f21d0475f
Signed by untrusted user: knoflook
GPG Key ID: D6A1D0E8FC4FEF1C

View File

@ -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