MCPcopy Create free account
hub / github.com/PyTables/PyTables / split_path

Function split_path

tables/path.py:187–206  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

185
186
187def 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
209def isvisiblename(name: str) -> bool:

Callers 8

_g_getparentMethod · 0.85
_g_set_locationMethod · 0.85
_index_pathname_ofFunction · 0.85
_index_pathname_of_Function · 0.85
move_from_shadowFunction · 0.85
undo_moveFunction · 0.85
redo_moveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected