Return path relative to parent_path.
(path, parent_path)
| 132 | return os.path.join(*split) |
| 133 | |
| 134 | def rel_path(path, parent_path): |
| 135 | """Return path relative to parent_path.""" |
| 136 | # Use realpath to avoid issues with symlinked dirs (see gh-7707) |
| 137 | pd = os.path.realpath(os.path.abspath(parent_path)) |
| 138 | apath = os.path.realpath(os.path.abspath(path)) |
| 139 | if len(apath) < len(pd): |
| 140 | return path |
| 141 | if apath == pd: |
| 142 | return '' |
| 143 | if pd == apath[:len(pd)]: |
| 144 | assert apath[len(pd)] in [os.sep], repr((path, apath[len(pd)])) |
| 145 | path = apath[len(pd)+1:] |
| 146 | return path |
| 147 | |
| 148 | def get_path_from_frame(frame, parent_path=None): |
| 149 | """Return path of the module given a frame object from the call stack. |
no test coverage detected