Skip to content

Commit 589f36e

Browse files
authored
2.1.0rc5 (#63)
1 parent 340f465 commit 589f36e

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

pyhelpers/store/utils.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ def _check_saving_path(path_to_file, verbose=False, print_prefix="", state_verb=
4141
>>> from pyhelpers.store import _check_saving_path
4242
>>> from pyhelpers.dirs import cd
4343
>>> path_to_file = cd()
44-
>>> try:
45-
... _check_saving_path(path_to_file, verbose=True)
46-
... except AssertionError as e:
47-
... print(e)
48-
The input for `path_to_file` may not be a file path.
44+
>>> _check_saving_path(path_to_file, verbose=True)
45+
Traceback (most recent call last):
46+
...
47+
AssertionError: The input for `path_to_file` may not be a file path.
4948
>>> path_to_file = "pyhelpers.pdf"
5049
>>> _check_saving_path(path_to_file, verbose=True); print("Passed.")
5150
Saving "pyhelpers.pdf" ... Passed.
@@ -63,17 +62,11 @@ def _check_saving_path(path_to_file, verbose=False, print_prefix="", state_verb=
6362
abs_path_to_file = pathlib.Path(path_to_file).absolute()
6463
assert not abs_path_to_file.is_dir(), "The input for `path_to_file` may not be a file path."
6564

66-
filename = pathlib.Path(abs_path_to_file).name if abs_path_to_file.suffix else ""
67-
6865
try:
69-
rel_dir_path = pathlib.Path(os.path.relpath(abs_path_to_file.parent))
66+
rel_dir_path = abs_path_to_file.parent.relative_to(pathlib.Path.cwd())
7067

71-
if rel_dir_path.is_relative_to("."):
72-
pass
73-
elif rel_dir_path == rel_dir_path.parent:
68+
if rel_dir_path.is_relative_to(".") and rel_dir_path == rel_dir_path.parent:
7469
rel_dir_path = abs_path_to_file.parent
75-
else: # In case the specified path does not exist
76-
os.makedirs(abs_path_to_file.parent, exist_ok=True)
7770

7871
except ValueError:
7972
if verbose == 2:
@@ -83,13 +76,17 @@ def _check_saving_path(path_to_file, verbose=False, print_prefix="", state_verb=
8376

8477
rel_dir_path = abs_path_to_file.parent
8578

79+
rel_dir_path.mkdir(parents=True, exist_ok=True) # In case the specified path does not exist
80+
81+
filename = abs_path_to_file.name if abs_path_to_file.suffix else ""
82+
8683
if verbose:
87-
if os.path.exists(abs_path_to_file):
84+
if os.path.isfile(abs_path_to_file):
8885
state_verb, state_prep = "Updating", "at"
8986

9087
end = print_end if print_end else "\n"
9188

92-
if (rel_dir_path == rel_dir_path.parent and
89+
if (rel_dir_path == rel_dir_path.parent or rel_dir_path == abs_path_to_file.parent) and (
9390
rel_dir_path.absolute().drive == pathlib.Path.cwd().drive):
9491
msg = f'{print_prefix}{state_verb} "{filename}"{print_suffix}'
9592
print(msg, end=end)

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ pyproj==3.7.0
2323
pytest-cov==6.0.0
2424
python-rapidjson==1.20
2525
rapidfuzz==3.11.0
26-
scikit-learn==1.6.0
26+
scikit-learn==1.6.1
2727
shapely==2.0.6
2828
sphinx-copybutton==0.5.2
2929
sphinx-new-tab-link==0.6.1
3030
sphinx-toggleprompt==0.5.2
31-
sqlalchemy==2.0.36
31+
sqlalchemy==2.0.37
3232
tinycss2==1.4.0
3333
tomli==2.0.1
3434
twine==6.0.1

0 commit comments

Comments
 (0)