-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcreateEnvJson.py
More file actions
40 lines (35 loc) · 1.14 KB
/
createEnvJson.py
File metadata and controls
40 lines (35 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
LAMBDA_FUNCTIONS = [
"ApiFunction",
"OrchestratorFunction",
"SQLDocketIngestFunction",
"SQLDocumentIngestFunction",
"SQLCommentIngestFunction",
"HTMSummaryIngestFunction",
"OpenSearchCommentFunction",
"OpenSearchTextExtractFunction",
]
def main():
env_json = {function: {} for function in LAMBDA_FUNCTIONS}
try:
with open(".env", "r") as env:
print("creating .env.json from .env file")
for line in env:
line = line.strip()
if line.startswith("#"):
# skip commented out lines
continue
line_components = line.split("=")
key = line_components[0]
value = "".join(line_components[1:])
if line:
for function in LAMBDA_FUNCTIONS:
env_json[function][key] = value
except FileNotFoundError:
print("could not find .env file")
exit(1)
with open(".env.json", "w") as f:
f.write(json.dumps(env_json, indent=2))
print("created .env.json")
if __name__ == "__main__":
main()