From 2490c416c84261470be1abe87e4f4c3b07daad51 Mon Sep 17 00:00:00 2001 From: Robert Barron Date: Mon, 31 Jul 2023 19:19:34 -0700 Subject: [PATCH] allow files to have comment lines --- scripts/wildcards.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/wildcards.py b/scripts/wildcards.py index 1434b84..80ca6f1 100644 --- a/scripts/wildcards.py +++ b/scripts/wildcards.py @@ -24,7 +24,9 @@ def replace_wildcard(self, text, gen): replacement_file = os.path.join(wildcards_dir, f"{text}.txt") if os.path.exists(replacement_file): with open(replacement_file, encoding="utf8") as f: - return gen.choice(f.read().splitlines()) + choices = f.read().splitlines() + choices = [x for x in choices if not x.startswith("#")] + return gen.choice(choices) else: if replacement_file not in warned_about_files: print(f"File {replacement_file} not found for the __{text}__ wildcard.", file=sys.stderr)