Skip to content

Commit

Permalink
Check if path is contained in cwd (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
phackstock authored Aug 9, 2023
1 parent 981dedc commit 226b13e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nomenclature/processor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
def get_relative_path(path: Path):
# Get the relative version of `path` relative to `path_relative_to`
# In case path does not contain `path_relative_to` it is returned unchanged
return path.relative_to(Path.cwd()) if path.is_absolute() else path
return (
path.relative_to(Path.cwd())
if path.is_absolute() and Path.cwd() in path.parents
else path
)

0 comments on commit 226b13e

Please sign in to comment.