_check_loading_path¶
- pyhelpers.store._check_loading_path(path, verbose=False, msg_prefix='', state_verb='Loading', msg_suffix='', end=' ... ', indent=None, return_info=False, **kwargs)[source]¶
Verifies a file path for loading and prints status to the console.
- Parameters:
path_to_file (str | bytes | pathlib.Path) – Path to the target file.
verbose (bool | int) – Whether to print status; defaults to
False.msg_prefix (str) – Text prepended to the message; defaults to
"".state_verb (str) – Action verb; defaults to
"Loading".msg_suffix (str) – Text appended to the message; defaults to
"".end (str) – Print end character; defaults to
" ... ".indent (int | str | None) – Indentation level; defaults to
None.return_info (bool) – If
True, returns path metadata; defaults toFalse.
- Returns:
(Absolute path, Parent directory, Extension) if
return_infoelseNone.- Return type:
tuple | None
Tests:
>>> from pyhelpers.store import _check_loading_path >>> from pyhelpers._cache import _check_relative_pathname >>> from pyhelpers.dirs import cd >>> from pathlib import Path >>> path_to_file = cd("test_func.py") >>> _check_loading_path(path, verbose=True); print("Passed.") Loading "./test_func.py" ... Passed. >>> file_path, rel_dir, file_ext = _check_loading_path(path, return_info=True) >>> _check_relative_pathname(file_path) 'test_func.py' >>> _check_relative_pathname(rel_dir) '.' >>> file_ext '.py' >>> path_to_file = Path("C:\Windows\pyhelpers.pkg") >>> _check_loading_path(path, verbose=True); print("Passed.") Loading "C:/Windows/pyhelpers.pkg" ... Passed. >>> file_path, rel_dir, file_ext = _check_loading_path(path, return_info=True) >>> _check_relative_pathname(file_path) 'C:/Windows/pyhelpers.pkg' >>> _check_relative_pathname(rel_dir) 'C:/Windows' >>> file_ext '.pkg'