-
-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have words as a python file to avoid import errors in components depe…
…nding on this one
- Loading branch information
Showing
3 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import sys | ||
import json | ||
|
||
from app import config | ||
from app.log import LOG | ||
|
||
rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
sys.path.append(rootDir) | ||
|
||
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() | ||
] | ||
|
||
destFile = os.path.join(rootDir, "app", "words.py") | ||
LOG.i(f"Writing {destFile}") | ||
|
||
serialized_words = json.dumps(words) | ||
with open(destFile, "wb") as fd: | ||
fd.write( | ||
f"""# | ||
#This file is auto-generated. Please run {sys.argv[0]} to re-generate it | ||
# | ||
import json | ||
safe_words = json.loads('{serialized_words}') | ||
""".encode("utf-8") | ||
) |