Given a path return only the parent name and file name as a string.

def ParentAndBaseName(path):
  """Given a path return only the parent name and file name as a string."""
  dirname, basename = os.path.split(path)
  dirname = dirname.rstrip(os.path.sep)
  if os.path.altsep:
    dirname = dirname.rstrip(os.path.altsep)
  _, parentname = os.path.split(dirname)
  return os.path.join(parentname, basename)