MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / path_handlers

Function path_handlers

src/commoncode/paths.py:68–79  ·  view source on GitHub ↗

Return a path module and path separator to use for handling (e.g. split and join) `path` using either POSIX or Windows conventions depending on the `path` content. Force usage of POSIX conventions if `posix` is True.

(path, posix=True)

Source from the content-addressed store, hash-verified

66
67
68def path_handlers(path, posix=True):
69 """
70 Return a path module and path separator to use for handling (e.g. split and
71 join) `path` using either POSIX or Windows conventions depending on the
72 `path` content. Force usage of POSIX conventions if `posix` is True.
73 """
74 # determine if we use posix or windows path handling
75 is_posix = is_posixpath(path)
76 use_posix = posix or is_posix
77 pathmod = use_posix and posixpath or ntpath
78 path_sep = "/" if use_posix else "\\"
79 return pathmod, path_sep
80
81
82def resolve(path, posix=True):

Callers 2

safe_pathFunction · 0.85
resolveFunction · 0.85

Calls 1

is_posixpathFunction · 0.90

Tested by

no test coverage detected