MCPcopy Index your code
hub / github.com/python/cpython / _path_join

Function _path_join

Lib/importlib/_bootstrap_external.py:101–128  ·  view source on GitHub ↗

Replacement for os.path.join().

(*path_parts)

Source from the content-addressed store, hash-verified

99
100if _MS_WINDOWS:
101 def _path_join(*path_parts):
102 """Replacement for os.path.join()."""
103 if not path_parts:
104 return ""
105 if len(path_parts) == 1:
106 return path_parts[0]
107 root = ""
108 path = []
109 for new_root, tail in map(_os._path_splitroot, path_parts):
110 if new_root.startswith(path_sep_tuple) or new_root.endswith(path_sep_tuple):
111 root = new_root.rstrip(path_separators) or root
112 path = [path_sep + tail]
113 elif new_root.endswith(':'):
114 if root.casefold() != new_root.casefold():
115 # Drive relative paths have to be resolved by the OS, so we reset the
116 # tail but do not add a path_sep prefix.
117 root = new_root
118 path = [tail]
119 else:
120 path.append(tail)
121 else:
122 root = new_root or root
123 path.append(tail)
124 path = [p.rstrip(path_separators) for p in path if p]
125 if len(path) == 1 and not path[0]:
126 # Avoid losing the root's trailing separator when joining with nothing
127 return root + path_sep
128 return root + path_sep.join(path)
129
130else:
131 def _path_join(*path_parts):

Callers 7

check_joinMethod · 0.90
_path_abspathFunction · 0.85
cache_from_sourceFunction · 0.85
source_from_cacheFunction · 0.85
set_dataMethod · 0.85
find_specMethod · 0.85
create_moduleMethod · 0.85

Calls 6

casefoldMethod · 0.80
startswithMethod · 0.45
endswithMethod · 0.45
rstripMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by 1

check_joinMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…