

def relpath(path, start=curdir):
    'Return a relative version of a path'
    if (not path):
        raise ValueError('no path specified')
    start_list = abspath(start).split(sep)
    path_list = abspath(path).split(sep)
    i = len(commonprefix([start_list, path_list]))
    rel_list = (([pardir] * (len(start_list) - i)) + path_list[i:])
    if (not rel_list):
        return curdir
    return join(*rel_list)

dataset/ETHPy150Open cournape/Bento/bento/compat/posix_path.py relpath/original