Return a relative version of a path
(path, start=curdir)
| 10 | except: |
| 11 | from posixpath import curdir, sep, pardir |
| 12 | def relpath(path, start=curdir): |
| 13 | """Return a relative version of a path""" |
| 14 | if not path: |
| 15 | raise ValueError("no path specified") |
| 16 | start_list = abspath(start).split(sep) |
| 17 | path_list = abspath(path).split(sep) |
| 18 | # Work out how much of the filepath is shared by start and path. |
| 19 | i = len(commonprefix([start_list, path_list])) |
| 20 | rel_list = [pardir] * (len(start_list)-i) + path_list[i:] |
| 21 | if not rel_list: |
| 22 | return curdir |
| 23 | return join(*rel_list) |
| 24 | |
| 25 | def quotepath(path): |
| 26 | try: |
no test coverage detected