MCPcopy Index your code
hub / github.com/nodejs/node / InvertRelativePath

Function InvertRelativePath

tools/gyp/pylib/gyp/common.py:178–188  ·  view source on GitHub ↗

Given a path like foo/bar that is relative to toplevel_dir, return the inverse relative path back to the toplevel_dir. E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path))) should always produce the empty string, unless the path contains symlinks.

(path, toplevel_dir=None)

Source from the content-addressed store, hash-verified

176
177@memoize
178def InvertRelativePath(path, toplevel_dir=None):
179 """Given a path like foo/bar that is relative to toplevel_dir, return
180 the inverse relative path back to the toplevel_dir.
181
182 E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path)))
183 should always produce the empty string, unless the path contains symlinks.
184 """
185 if not path:
186 return path
187 toplevel_dir = "." if toplevel_dir is None else toplevel_dir
188 return RelativePath(toplevel_dir, os.path.join(toplevel_dir, path))
189
190
191def FixIfRelativePath(path, relative_to):

Callers

nothing calls this directly

Calls 2

RelativePathFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected