-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
47 lines (32 loc) · 931 Bytes
/
Copy pathconfig.py
File metadata and controls
47 lines (32 loc) · 931 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from pathlib import Path
import os
from dotenv import load_dotenv
SCRIPT_DIR = Path(__file__).parent
ENV_FILE = SCRIPT_DIR / ".env"
def credentials_exist():
return ENV_FILE.exists()
def load():
load_dotenv(ENV_FILE, override=True)
wskey = os.getenv("WSKEY")
secret = os.getenv("WSKEY_SECRET")
symbol = os.getenv("INSTITUTION_SYMBOL")
missing = []
if not wskey:
missing.append("WSKEY")
if not secret:
missing.append("WSKEY_SECRET")
if not symbol:
missing.append("INSTITUTION_SYMBOL")
if missing:
raise ValueError(
f"Ontbrekende variabelen in .env: {', '.join(missing)}"
)
return {
"WSKEY": wskey,
"WSKEY_SECRET": secret,
"INSTITUTION_SYMBOL": symbol,
}
if __name__ == "__main__":
print(f".env gevonden: {ENV_FILE.exists()}")
if ENV_FILE.exists():
print(f"Locatie: {ENV_FILE}")