-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv_loader.py
More file actions
31 lines (22 loc) · 722 Bytes
/
Copy pathenv_loader.py
File metadata and controls
31 lines (22 loc) · 722 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
import os
class GetEnvs:
def __init__(self, list_env):
self.list_env = list_env
self.env_dict = {}
def load_envs(self, list_env=None):
if list_env is not None:
self.list_env = list_env
self.env_dict = {}
for env in self.list_env:
temp_env_variable = os.environ.get(env)
if temp_env_variable is None:
return None
else:
self.env_dict[env] = temp_env_variable
return True
def get_env_vars(self, var_name=None):
if len(self.env_dict) == 0:
return None
if var_name is not None:
return self.env_dict[var_name]
return self.env_dict