Skip to content

Commit e6c534e

Browse files
authored
follow_symlink=False as default in path() (#140)
1 parent dc375de commit e6c534e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

audeer/core/path.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def path(
1818
path: typing.Union[str, bytes],
1919
*paths: typing.Sequence[typing.Union[str, bytes]],
20-
follow_symlink: bool = True,
20+
follow_symlink: bool = False,
2121
) -> str:
2222
"""Expand and normalize to absolute path.
2323
@@ -55,12 +55,10 @@ def path(
5555
>>> file = audeer.touch("file.txt")
5656
>>> link = path("link.txt")
5757
>>> os.symlink(file, link)
58-
>>> file = path(link)
59-
>>> os.path.basename(file)
60-
'file.txt'
61-
>>> file = path(link, follow_symlink=False)
62-
>>> os.path.basename(file)
58+
>>> os.path.basename(path(link))
6359
'link.txt'
60+
>>> os.path.basename(path(link, follow_symlink=True))
61+
'file.txt'
6462
6563
"""
6664
if paths:
@@ -85,7 +83,7 @@ def path(
8583
def safe_path(
8684
path: typing.Union[str, bytes],
8785
*paths: typing.Sequence[typing.Union[str, bytes]],
88-
follow_symlink: bool = True,
86+
follow_symlink: bool = False,
8987
) -> str:
9088
"""Expand and normalize to absolute path.
9189
@@ -127,12 +125,10 @@ def safe_path(
127125
>>> file = audeer.touch("file.txt")
128126
>>> link = path("link.txt")
129127
>>> os.symlink(file, link)
130-
>>> file = path(link)
131-
>>> os.path.basename(file)
132-
'file.txt'
133-
>>> file = path(link, follow_symlink=False)
134-
>>> os.path.basename(file)
128+
>>> os.path.basename(path(link))
135129
'link.txt'
130+
>>> os.path.basename(path(link, follow_symlink=True))
131+
'file.txt'
136132
137133
"""
138-
return _path(path, *paths)
134+
return _path(path, *paths, follow_symlink=follow_symlink)

0 commit comments

Comments
 (0)