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)
| 176 | |
| 177 | @memoize |
| 178 | def 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 | |
| 191 | def FixIfRelativePath(path, relative_to): |
nothing calls this directly
no test coverage detected