add load_json_to_environ

This commit is contained in:
Daniel 2023-12-11 00:12:51 +01:00
parent fed7d27136
commit 2f6d0c47e5
2 changed files with 13 additions and 7 deletions

View file

@ -1,3 +1,5 @@
import json
import os
import random
import string
from dataclasses import dataclass
@ -46,3 +48,11 @@ def generate_random_string(length: int, punctuation=False) -> str:
characters += string.punctuation
random_string = "".join(random.choice(characters) for _ in range(length))
return random_string
def load_json_to_environ(cred_file: Path):
with open(cred_file, "r") as f:
CREDENTIALS = json.load(f)
for key, value in CREDENTIALS.items():
os.environ[key] = value