Test whether a path is absolute
(s, /)
| 78 | |
| 79 | |
| 80 | def isabs(s, /): |
| 81 | """Test whether a path is absolute""" |
| 82 | s = os.fspath(s) |
| 83 | if isinstance(s, bytes): |
| 84 | sep = b'\\' |
| 85 | altsep = b'/' |
| 86 | colon_sep = b':\\' |
| 87 | double_sep = b'\\\\' |
| 88 | else: |
| 89 | sep = '\\' |
| 90 | altsep = '/' |
| 91 | colon_sep = ':\\' |
| 92 | double_sep = '\\\\' |
| 93 | s = s[:3].replace(altsep, sep) |
| 94 | # Absolute: UNC, device, and paths with a drive and root. |
| 95 | return s.startswith(colon_sep, 1) or s.startswith(double_sep) |
| 96 | |
| 97 | |
| 98 | # Join two (or more) paths. |
no test coverage detected
searching dependent graphs…