Skip to content

Commit

Permalink
Added ESBMC_AI_CFG_PATH expansion in load env
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiannis128 committed Jan 31, 2024
1 parent a6cea98 commit a2dcc23
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions esbmc_ai_lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ def load_envs() -> None:
2. .env file in the current directory, moving upwards in the directory tree.
3. esbmc-ai.env file in the current directory, moving upwards in the directory tree.
4. esbmc-ai.env file in $HOME/.config/ for Linux/macOS and %userprofile% for Windows.
Note: ESBMC_AI_CFG_PATH undergoes tilde user expansion and also environment
variable expansion.
"""

def get_env_vars() -> None:
Expand Down Expand Up @@ -240,12 +243,14 @@ def get_env_vars() -> None:
)

global cfg_path
value = os.getenv("ESBMC_AI_CFG_PATH")
if value != None:
if os.path.exists(value):
cfg_path = str(value)
_cfg_path = os.getenv("ESBMC_AI_CFG_PATH")
if _cfg_path != None:
_cfg_path = os.path.expanduser(_cfg_path)
_cfg_path = os.path.expandvars(_cfg_path)
if os.path.exists(_cfg_path):
cfg_path = str(_cfg_path)
else:
print(f"Error: Invalid ESBMC_AI_CFG_PATH value: {value}")
print(f"Error: Invalid ESBMC_AI_CFG_PATH value: {_cfg_path}")
sys.exit(4)
else:
print(
Expand Down

0 comments on commit a2dcc23

Please sign in to comment.