Split a *canonical* `path` into a parent path and a node name. The result is returned as a tuple. The parent path does not include a trailing slash. >>> split_path('/') ('/', '') >>> split_path('/foo/bar') ('/foo', 'bar')
(path: str)
| 185 | |
| 186 | |
| 187 | def split_path(path: str) -> (str, str): |
| 188 | """Split a *canonical* `path` into a parent path and a node name. |
| 189 | |
| 190 | The result is returned as a tuple. The parent path does not |
| 191 | include a trailing slash. |
| 192 | |
| 193 | >>> split_path('/') |
| 194 | ('/', '') |
| 195 | >>> split_path('/foo/bar') |
| 196 | ('/foo', 'bar') |
| 197 | |
| 198 | """ |
| 199 | lastslash = path.rfind("/") |
| 200 | ppath = path[:lastslash] |
| 201 | name = path[lastslash + 1 :] |
| 202 | |
| 203 | if ppath == "": |
| 204 | ppath = "/" |
| 205 | |
| 206 | return (ppath, name) |
| 207 | |
| 208 | |
| 209 | def isvisiblename(name: str) -> bool: |
no outgoing calls
no test coverage detected