From 72e26f791228ad95c4cc5bd67eba4e0d23396f63 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 Jan 2022 00:11:31 -0800 Subject: [PATCH] Replace slashes in puzzle name to create a filename Otherwise, the open will fail with a "directory does not exist" error message. Thanks to MH 2021 for including a puzzle with a '/' in its name to exercise this bug. --- html_generator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/html_generator.py b/html_generator.py index de1265c..3ee751c 100644 --- a/html_generator.py +++ b/html_generator.py @@ -16,6 +16,7 @@ Requires sorttable.js, which should be included """ import boto3 from boto3.dynamodb.conditions import Key +import re website = "https://halibut.cworth.org/" #change this if we're using AWS or some other subdomain instead @@ -326,7 +327,8 @@ def puzzle_overview(puzzle): '\n', '\n', '\n'] - underscored = "_".join(name.split()) + # Replace all spaces and slashes in the name with underscores + underscored = re.sub(r'[ /]', '_', name) file = "{}.html".format(underscored) f = open(file, "w") for line in html: -- 2.43.0