From eed8db76ceaf9993b6ebfb44d68a7d514de41adb Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Fri, 19 Jan 2024 15:49:32 +0100 Subject: [PATCH] follow_symlink=False as default in path() --- audeer/core/path.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/audeer/core/path.py b/audeer/core/path.py index 04056d9..5406b99 100644 --- a/audeer/core/path.py +++ b/audeer/core/path.py @@ -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. @@ -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: @@ -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. @@ -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)