From 5f1be2df473520bb3f7cd55e9111f493af93d9e0 Mon Sep 17 00:00:00 2001 From: "didierlopes.eth" Date: Thu, 17 Mar 2022 17:10:42 +0000 Subject: [PATCH] allow exe command to provide absolute path or absolute with HOME env var (#1504) --- gamestonk_terminal/helper_funcs.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gamestonk_terminal/helper_funcs.py b/gamestonk_terminal/helper_funcs.py index e12afb304b8..eab1be3e069 100644 --- a/gamestonk_terminal/helper_funcs.py +++ b/gamestonk_terminal/helper_funcs.py @@ -92,9 +92,14 @@ def check_path(path: str) -> str: # Just return empty path because this will be handled outside this function if not path: return "" - # Return string of path if such path exists + if path[0] == "~": + path = path.replace("~", os.environ["HOME"]) + # Return string of path if such relative path exists if os.path.isfile(path): return path + # Return string of path if an absolute path exists + if os.path.isfile("/" + path): + return f"/{path}" logger.error("The path file '%s' does not exist.", path) console.print(f"[red]The path file '{path}' does not exist.\n[/red]") return ""