Skip to content
Snippets Groups Projects
Select Git revision
  • 481256e8ea1ee6762b0ea6aaa2356c8d12e9c919
  • master default protected
  • developement_1 protected
  • Version_1.2.4
  • Version_1.2.3
  • Version_1.2.2
  • Version_1.2.1
  • Version_1.2.0
  • Version_1.0.1
  • Version_1.0.0
  • Version_0.1.0
  • Version_0.0.6
  • Version_0.0.5
  • Version_0.0.4
  • Version_0.0.3
  • Version_0.0.2
  • Version_0.0.1
17 results

FileInterface.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    myrelpath.py 747 B
    """relpath is not present in python 2.5 and below, so hold an implementation of it.
    """
    try:
        from os.path import relpath
    except ImportError:
        from posixpath import curdir, sep, pardir, join, abspath, commonprefix
    
        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)
            # Work out how much of the filepath is shared by start and path.
            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)