Skip to content

Commit

Permalink
Additional function to get home dir
Browse files Browse the repository at this point in the history
  • Loading branch information
idomic committed Jan 20, 2022
1 parent a6e9313 commit 34d6087
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/ploomber/telemetry/telemetry.py
Expand Up @@ -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()

Expand Down

0 comments on commit 34d6087

Please sign in to comment.