Generate the word list in several lines

This commit is contained in:
Adrià Casajús 2025-01-15 18:37:31 +01:00
parent 23796197f7
commit 7fd4b1d2ee
No known key found for this signature in database
GPG key ID: F0033226A5AFC9B9
2 changed files with 8126 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,18 @@ from app import config # noqa: E402
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"""#
@ -29,7 +31,7 @@ with open(destFile, "wb") as fd:
import json
safe_words = json.loads(
'{serialized_words}'
\"\"\"{serialized_words}\"\"\"
)
""".encode("utf-8")
)