Skip to content

Commit

Permalink
Generate the word list in several lines
Browse files Browse the repository at this point in the history
  • Loading branch information
acasajus committed Jan 15, 2025
1 parent 2379619 commit 7fd4b1d
Show file tree
Hide file tree
Showing 2 changed files with 8,126 additions and 8 deletions.
8,118 changes: 8,117 additions & 1 deletion app/words.py

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions scripts/regen-words.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
from app.log import LOG # noqa: E402

LOG.i(f"Reading {config.WORDS_FILE_PATH} file")
words = [
word.strip()
for word in open(config.WORDS_FILE_PATH, "r").readlines()
if word.strip()
]
words = sorted(
[
word.strip()
for word in open(config.WORDS_FILE_PATH, "r").readlines()
if word.strip()
]
)

destFile = os.path.join(rootDir, "app", "words.py")
LOG.i(f"Writing {destFile}")

serialized_words = json.dumps(words)
serialized_words = json.dumps(words, indent=2)
with open(destFile, "wb") as fd:
fd.write(
f"""#
Expand All @@ -29,7 +31,7 @@
import json
safe_words = json.loads(
'{serialized_words}'
\"\"\"{serialized_words}\"\"\"
)
""".encode("utf-8")
)

0 comments on commit 7fd4b1d

Please sign in to comment.