Skip to content

Commit

Permalink
FIX: Fix files.to_abspath new feature...
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Nov 21, 2022
1 parent 7038a9f commit 9bc6955
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 1.XX.Y (20YY-MM-DD)

## 1.19.5 (2022-11-21)

- FIX: Fix `files.to_abspath` new feature...

## 1.19.4 (2022-11-21)

- FIX: Allow the user to choose if `files.to_abspath` raise a FileNotFoundError if the file doesn't exist.
Expand Down
2 changes: 1 addition & 1 deletion sertit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.. include:: ../README.md
"""

__version__ = "1.19.4"
__version__ = "1.19.5"
__title__ = "sertit"
__description__ = ("SERTIT python library for generic tools",)
__author__ = "ICube-SERTIT"
Expand Down
9 changes: 5 additions & 4 deletions sertit/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ def to_abspath(
abs_path = AnyPath(path).resolve()

if not abs_path.exists():
if raise_file_not_found and abs_path.suffix:
# If the path specifies a file (with extension), it raises an exception
raise FileNotFoundError(f"Non existing file: {abs_path}")
if abs_path.suffix:
if raise_file_not_found:
# If the path specifies a file (with extension), it raises an exception
raise FileNotFoundError(f"Non existing file: {abs_path}")

# If the path specifies a folder, it creates it
if create:
elif create:
abs_path.mkdir()

return abs_path
Expand Down

0 comments on commit 9bc6955

Please sign in to comment.