@@ -1,3 +1,9 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import dotenv
|
||||
|
||||
|
||||
def merge_dicts(target: dict, enhancer: dict) -> dict:
|
||||
for key, val in enhancer.items():
|
||||
if key not in target:
|
||||
@@ -9,3 +15,10 @@ def merge_dicts(target: dict, enhancer: dict) -> dict:
|
||||
else:
|
||||
target[key] = val
|
||||
return target
|
||||
|
||||
|
||||
def get_environ(path: Path) -> dict[str, str]:
|
||||
result = os.environ.copy()
|
||||
if (env_file := path / ".env").exists():
|
||||
result.update(dotenv.dotenv_values(env_file))
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user