Skip to content

Commit

Permalink
Update safe_path function signature
Browse files Browse the repository at this point in the history
Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Jun 11, 2022
1 parent 5f31bb3 commit 58acb67
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/commoncode/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Build OS-portable and safer paths


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

segments = [s.strip() for s in path.split(path_sep) if s.strip()]
segments = [portable_filename(s, preserve_spaces=preserve_spaces) for s in segments]
segments = [
portable_filename(
s,
preserve_spaces=preserve_spaces,
posix_only=posix_only
) for s in segments
]

if not segments:
return '_'
Expand Down

0 comments on commit 58acb67

Please sign in to comment.