MCPcopy Index your code
hub / github.com/PyTables/PyTables / join_path

Function join_path

tables/path.py:158–184  ·  view source on GitHub ↗

Join a *canonical* `parentpath` with a *non-empty* `name`. .. versionchanged:: 3.0 The *parentPath* parameter has been renamed into *parentpath*. >>> join_path('/', 'foo') '/foo' >>> join_path('/foo', 'bar') '/foo/bar' >>> join_path('/foo', '/foo2/bar') '/foo/foo

(parentpath: str, name: str)

Source from the content-addressed store, hash-verified

156
157
158def join_path(parentpath: str, name: str) -> str:
159 """Join a *canonical* `parentpath` with a *non-empty* `name`.
160
161 .. versionchanged:: 3.0
162 The *parentPath* parameter has been renamed into *parentpath*.
163
164 >>> join_path('/', 'foo')
165 '/foo'
166 >>> join_path('/foo', 'bar')
167 '/foo/bar'
168 >>> join_path('/foo', '/foo2/bar')
169 '/foo/foo2/bar'
170 >>> join_path('/foo', '/')
171 '/foo'
172
173 """
174 if name.startswith("./"): # Support relative paths (mainly for links)
175 name = name[2:]
176 if parentpath == "/" and name.startswith("/"):
177 pstr = "%s" % name
178 elif parentpath == "/" or name.startswith("/"):
179 pstr = f"{parentpath}{name}"
180 else:
181 pstr = f"{parentpath}/{name}"
182 if pstr.endswith("/"):
183 pstr = pstr[:-1]
184 return pstr
185
186
187def split_path(path: str) -> (str, str):

Callers 13

_g_set_locationMethod · 0.85
_g_update_locationMethod · 0.85
_index_pathname_ofFunction · 0.85
_index_pathname_of_Function · 0.85
_g_joinMethod · 0.85
_f_get_childMethod · 0.85
_g_load_childMethod · 0.85
tableMethod · 0.85
file.pyFile · 0.85
get_nodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected