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

Function isabs

tools/python-3.11.9-amd64/Lib/ntpath.py:87–103  ·  view source on GitHub ↗

Test whether a path is absolute

(s)

Source from the content-addressed store, hash-verified

85# starts with a slash or backslash.
86
87def isabs(s):
88 """Test whether a path is absolute"""
89 s = os.fspath(s)
90 if isinstance(s, bytes):
91 sep = b'\\'
92 altsep = b'/'
93 colon_sep = b':\\'
94 else:
95 sep = '\\'
96 altsep = '/'
97 colon_sep = ':\\'
98 s = s[:3].replace(altsep, sep)
99 # Absolute: UNC, device, and paths with a drive and root.
100 # LEGACY BUG: isabs("/x") should be false since the path has no drive.
101 if s.startswith(sep) or s.startswith(colon_sep, 1):
102 return True
103 return False
104
105
106# Join two (or more) paths.

Callers 3

_abspath_fallbackFunction · 0.70
_readlink_deepFunction · 0.70
realpathFunction · 0.70

Calls 2

startswithMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected