Skip to content

Commit

Permalink
feat: add check_path();
Browse files Browse the repository at this point in the history
  • Loading branch information
WenjieDu committed Jun 28, 2024
1 parent 4dd36e9 commit 343ac59
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tsdb/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@
from .logging import logger


def check_path(path: str) -> str:
"""Check the given path and return the absolute path.
Parameters
----------
path :
The path to be checked.
Returns
-------
checked_path:
The absolute path of the given path.
"""
# expand the home dir if the path starts with "~"
if path.startswith("~"):
checked_path = path.replace("~", os.path.expanduser("~"))
else:
checked_path = path

checked_path = os.path.abspath(checked_path)
return checked_path


def pickle_dump(data: object, path: str) -> Optional[str]:
"""Pickle the given object.
Expand Down

0 comments on commit 343ac59

Please sign in to comment.