mirror of
https://github.com/simple-login/app.git
synced 2025-02-23 07:13:18 +08:00
Generate the word list in several lines
This commit is contained in:
parent
23796197f7
commit
7fd4b1d2ee
2 changed files with 8126 additions and 8 deletions
8118
app/words.py
8118
app/words.py
File diff suppressed because one or more lines are too long
|
@ -10,16 +10,18 @@ from app import config # noqa: E402
|
||||||
from app.log import LOG # noqa: E402
|
from app.log import LOG # noqa: E402
|
||||||
|
|
||||||
LOG.i(f"Reading {config.WORDS_FILE_PATH} file")
|
LOG.i(f"Reading {config.WORDS_FILE_PATH} file")
|
||||||
words = [
|
words = sorted(
|
||||||
|
[
|
||||||
word.strip()
|
word.strip()
|
||||||
for word in open(config.WORDS_FILE_PATH, "r").readlines()
|
for word in open(config.WORDS_FILE_PATH, "r").readlines()
|
||||||
if word.strip()
|
if word.strip()
|
||||||
]
|
]
|
||||||
|
)
|
||||||
|
|
||||||
destFile = os.path.join(rootDir, "app", "words.py")
|
destFile = os.path.join(rootDir, "app", "words.py")
|
||||||
LOG.i(f"Writing {destFile}")
|
LOG.i(f"Writing {destFile}")
|
||||||
|
|
||||||
serialized_words = json.dumps(words)
|
serialized_words = json.dumps(words, indent=2)
|
||||||
with open(destFile, "wb") as fd:
|
with open(destFile, "wb") as fd:
|
||||||
fd.write(
|
fd.write(
|
||||||
f"""#
|
f"""#
|
||||||
|
@ -29,7 +31,7 @@ with open(destFile, "wb") as fd:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
safe_words = json.loads(
|
safe_words = json.loads(
|
||||||
'{serialized_words}'
|
\"\"\"{serialized_words}\"\"\"
|
||||||
)
|
)
|
||||||
""".encode("utf-8")
|
""".encode("utf-8")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue