-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload.py
More file actions
37 lines (25 loc) · 904 Bytes
/
load.py
File metadata and controls
37 lines (25 loc) · 904 Bytes
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
from dotenv import load_dotenv
import os
import json
from pathlib import Path
home = Path.home()
rayDir = home / ".ray"
rayDir.mkdir(parents=True, exist_ok=True)
def getConfig(file="config.json"):
with open(rayDir/file, "r") as configFile:
return json.load(configFile)
def getPassword():
load_dotenv(dotenv_path=rayDir/".env")
return os.getenv("PASSWORD")
def getEmails(file="emails.json"):
with open(rayDir/file, "r") as emailsFile:
return json.load(emailsFile)
def writeConfig(config, file="config.json"):
with open(rayDir/file, "w") as configFile:
json.dump(config, configFile, indent=4)
def writePassword(password):
with open(rayDir/".env", "w") as dotEnv:
dotEnv.write("PASSWORD="+password)
def writeEmails(emails, file="emails.json"):
with open(rayDir/file, "w") as emailsFile:
json.dump(emails, emailsFile, indent=4)