MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / join

Function join

tools/python-3.11.9-amd64/Lib/posixpath.py:71–92  ·  view source on GitHub ↗

Join two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.

(a, *p)

Source from the content-addressed store, hash-verified

69# Insert a '/' unless the first part is empty or already ends in '/'.
70
71def join(a, *p):
72 """Join two or more pathname components, inserting '/' as needed.
73 If any component is an absolute path, all previous path components
74 will be discarded. An empty last part will result in a path that
75 ends with a separator."""
76 a = os.fspath(a)
77 sep = _get_sep(a)
78 path = a
79 try:
80 if not p:
81 path[:0] + sep #23780: Ensure compatible data type even if p is null.
82 for b in map(os.fspath, p):
83 if b.startswith(sep):
84 path = b
85 elif not path or path.endswith(sep):
86 path += b
87 else:
88 path += sep + b
89 except (TypeError, AttributeError, BytesWarning):
90 genericpath._check_arg_types('join', a, *p)
91 raise
92 return path
93
94
95# Split a path in head (everything up to the last '/') and tail (the

Callers 4

ismountFunction · 0.70
abspathFunction · 0.70
_joinrealpathFunction · 0.70
relpathFunction · 0.70

Calls 4

_get_sepFunction · 0.85
startswithMethod · 0.80
endswithMethod · 0.80
mapFunction · 0.50

Tested by

no test coverage detected