(path, start)
return '/'.join(['..'] * (len(start_list) - common_prefix_count) +
                  path_list[common_prefix_count:])
Return a relative path to |path| from |start|.
Return a relative path to |path| from |start|.
Return a relative path to |path| from |start| .
def GetRelpath(path, start):
  """Return a relative path to |path| from |start|."""
  # NOTE: Python 2.6 provides os.path.relpath, which has almost the same
  # functionality as this function. Since we want to support 2.4, we have
  # to implement it manually. :(
  path_list = os.path.abspath(os.path.normpath(path)).split(os.sep)
  start_list = os.path.abspath(
      os.path.normpath(os.path.dirname(start))).split(os.sep)

  common_prefix_count = 0
  for i in range(0, min(len(path_list), len(start_list))):
    if path_list[i] != start_list[i]:
      break
    common_prefix_count += 1

  # Always use forward slashes, because this will get expanded to a url,
  # not a file path.
  return '/'.join(['..'] * (len(start_list) - common_prefix_count) +
                  path_list[common_prefix_count:])
def GetRelpath ( path , start ) : # NOTE: Python 2.6 provides os.path.relpath, which has almost the same # functionality as this function. Since we want to support 2.4, we have # to implement it manually. :( path_list = os . path . abspath ( os . path . normpath ( path ) ) . split ( os . sep ) start_list = os . path . abspath ( os . path . normpath ( os . path . dirname ( start ) ) ) . split ( os . sep ) common_prefix_count = 0 for i in range ( 0 , min ( len ( path_list ) , len ( start_list ) ) ) : if path_list [ i ] != start_list [ i ] : break common_prefix_count += 1 # Always use forward slashes, because this will get expanded to a url, # not a file path. return '/' . join ( [ '..' ] * ( len ( start_list ) - common_prefix_count ) + path_list [ common_prefix_count : ] )