def parse_path(root_dir):
    """Split path into head and last component for the completer.
    Also return position where last component starts.
    :param root_dir: str path
    :return: tuple of (string, string, int)
    """
    base_dir, last_dir, position = '', '', 0
    if root_dir:
        base_dir, last_dir = os.path.split(root_dir)
        position = -len(last_dir) if last_dir else 0
    return base_dir, last_dir, position
Split path into head and last component for the completer.
    Also return position where last component starts.
    :param root_dir: str path
    :return: tuple of (string, string, int)