From 34d60875803e642f1964770eb014a9291dd174d2 Mon Sep 17 00:00:00 2001 From: idomic Date: Thu, 20 Jan 2022 10:25:58 -0500 Subject: [PATCH] Additional function to get home dir --- src/ploomber/telemetry/telemetry.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ploomber/telemetry/telemetry.py b/src/ploomber/telemetry/telemetry.py index cd080c0b2..b717582eb 100644 --- a/src/ploomber/telemetry/telemetry.py +++ b/src/ploomber/telemetry/telemetry.py @@ -218,20 +218,25 @@ def parse_dag(dag): return None +def get_home_dir(): + """ + Checks if ploomber home was set through the env variable. + returns the actual home_dir path. + """ + return PLOOMBER_HOME_DIR if PLOOMBER_HOME_DIR else DEFAULT_HOME_DIR + + def check_dir_exist(input_location=None): """ Checks if a specific directory exists, creates if not. In case the user didn't set a custom dir, will turn to the default home """ - if PLOOMBER_HOME_DIR: - final_location = PLOOMBER_HOME_DIR - else: - final_location = DEFAULT_HOME_DIR + home_dir = get_home_dir() if input_location: - p = Path(final_location, input_location) + p = Path(home_dir, input_location) else: - p = Path(final_location) + p = Path(home_dir) p = p.expanduser()