Skip to content

Commit 6434fdf

Browse files
committed
Update safe_path function signature
Signed-off-by: Jono Yang <[email protected]>
1 parent f37a07b commit 6434fdf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/commoncode/paths.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# Build OS-portable and safer paths
2727

2828

29-
def safe_path(path, posix=False, preserve_spaces=False):
29+
def safe_path(path, posix=False, preserve_spaces=False, posix_only=False):
3030
"""
3131
Convert `path` to a safe and portable POSIX path usable on multiple OSes.
3232
The returned path is an ASCII-only byte string, resolved for relative
@@ -52,7 +52,13 @@ def safe_path(path, posix=False, preserve_spaces=False):
5252
_pathmod, path_sep = path_handlers(path, posix)
5353

5454
segments = [s.strip() for s in path.split(path_sep) if s.strip()]
55-
segments = [portable_filename(s, preserve_spaces=preserve_spaces) for s in segments]
55+
segments = [
56+
portable_filename(
57+
s,
58+
preserve_spaces=preserve_spaces,
59+
posix_only=posix_only
60+
) for s in segments
61+
]
5662

5763
if not segments:
5864
return '_'

0 commit comments

Comments
 (0)