Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.
(p, /)
| 220 | # The resulting head won't end in '/' unless it is the root. |
| 221 | |
| 222 | def split(p, /): |
| 223 | """Split a pathname. |
| 224 | |
| 225 | Return tuple (head, tail) where tail is everything after the final slash. |
| 226 | Either part may be empty.""" |
| 227 | p = os.fspath(p) |
| 228 | seps = _get_bothseps(p) |
| 229 | d, r, p = splitroot(p) |
| 230 | # set i to index beyond p's last slash |
| 231 | i = len(p) |
| 232 | while i and p[i-1] not in seps: |
| 233 | i -= 1 |
| 234 | head, tail = p[:i], p[i:] # now tail has no slashes |
| 235 | return d + r + head.rstrip(seps), tail |
| 236 | |
| 237 | |
| 238 | # Split a path in root and extension. |
no test coverage detected
searching dependent graphs…