Read Creds from DotEnv

wrapper for the python-dotenv library that reads creds into a .env file.

source

read_creds_from_dotenv

 read_creds_from_dotenv (env_path:str='.env', params:list[str]=None)

use_prod = false will replace all PROD values with matching TEST values

Type Default Details
env_path str .env
params list None list of params you’re expecting in the env file,
Returns DictDot

source

ReadCreds_EnvFileNotExist

 ReadCreds_EnvFileNotExist (env_path)

Common base class for all non-exit exceptions.

sample implementation of read creds

# import json

# TEST_ENV_PATH = '_test_env.txt'

# params = ["APPLICATION_ID", "DATASET_ID", "ACCOUNT_ID", "SAMPLE_ARRAY"]

# env = read_creds_from_dotenv(TEST_ENV_PATH, params = params)

# print(env)
# print(json.loads(env.SAMPLE_ARRAY))
# # | export
# def split_creds(env: utils_dd.DictDot, key_starts_with: str, env_var_list: list[str]):
#     env_lines_to_split = [getattr(env, key) for key in dir(
#         env) if key.startswith(key_starts_with)]

#     return [utils_dd.split_str_to_obj(env_string=line, value_split_keys=env_var_list) for line in env_lines_to_split]