Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

follow_symlink=False as default in path() #140

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions audeer/core/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def path(
path: typing.Union[str, bytes],
*paths: typing.Sequence[typing.Union[str, bytes]],
follow_symlink: bool = True,
follow_symlink: bool = False,
) -> str:
"""Expand and normalize to absolute path.

Expand Down Expand Up @@ -55,12 +55,10 @@ def path(
>>> file = audeer.touch("file.txt")
>>> link = path("link.txt")
>>> os.symlink(file, link)
>>> file = path(link)
>>> os.path.basename(file)
'file.txt'
>>> file = path(link, follow_symlink=False)
>>> os.path.basename(file)
>>> os.path.basename(path(link))
'link.txt'
>>> os.path.basename(path(link, follow_symlink=True))
'file.txt'

"""
if paths:
Expand All @@ -85,7 +83,7 @@ def path(
def safe_path(
path: typing.Union[str, bytes],
*paths: typing.Sequence[typing.Union[str, bytes]],
follow_symlink: bool = True,
follow_symlink: bool = False,
) -> str:
"""Expand and normalize to absolute path.

Expand Down Expand Up @@ -127,12 +125,10 @@ def safe_path(
>>> file = audeer.touch("file.txt")
>>> link = path("link.txt")
>>> os.symlink(file, link)
>>> file = path(link)
>>> os.path.basename(file)
'file.txt'
>>> file = path(link, follow_symlink=False)
>>> os.path.basename(file)
>>> os.path.basename(path(link))
'link.txt'
>>> os.path.basename(path(link, follow_symlink=True))
'file.txt'

"""
return _path(path, *paths)
return _path(path, *paths, follow_symlink=follow_symlink)