def generate_index_page(index_links, index_fp, order=[_index_headers['run_summary']]):
 top_level_dir = split(split(index_fp)[0])[1]
 index_page_header = get_index_page_header()
 index_lines = [index_page_header]
 d = {}
 for e in index_links:
  try:
   d[e[2]].append((e[0], e[1]))
  except KeyError:
   d[e[2]] = [(e[0], e[1])]
 index_lines.append('<table border=1>\n')
 ordered_table_entries = (order + [k for k in d if (k not in order)])
 for k in ordered_table_entries:
  v = d[k]
  index_lines.append(('<tr colspan=2 align=center bgcolor=#e8e8e8><td colspan=2 align=center>%s</td></tr>\n' % k))
  for (description, path) in v:
   path = re.sub(('^.*%s\\/' % top_level_dir), './', path)
   index_lines.append(('<tr>%s</tr>\n' % format_index_link(description, path)))
 index_lines.append('</table>\n')
 index_page_footer = get_index_page_footer()
 index_lines.append(index_page_footer)
 open(index_fp, 'w').write(''.join(index_lines))

def generate_index_page ( index_links , index_fp , order = [ _index_headers [ 'run_summary' ] ] ) : top_level_dir = split ( split ( index_fp ) [ 0 ] ) [ 1 ] index_page_header = get_index_page_header ( ) index_lines = [ index_page_header ] d = { } for e in index_links : try : d [ e [ 2 ] ] . append ( ( e [ 0 ] , e [ 1 ] ) ) except KeyError : d [ e [ 2 ] ] = [ ( e [ 0 ] , e [ 1 ] ) ] index_lines . append ( '<table border=1>\n' ) ordered_table_entries = ( order + [ k for k in d if ( k not in order ) ] ) for k in ordered_table_entries : v = d [ k ] index_lines . append ( ( '<tr colspan=2 align=center bgcolor=#e8e8e8><td colspan=2 align=center>%s</td></tr>\n' % k ) ) for ( description , path ) in v : path = re . sub ( ( '^.*%s\\/' % top_level_dir ) , './' , path ) index_lines . append ( ( '<tr>%s</tr>\n' % format_index_link ( description , path ) ) ) index_lines . append ( '</table>\n' ) index_page_footer = get_index_page_footer ( ) index_lines . append ( index_page_footer ) open ( index_fp , 'w' ) . write ( '' . join ( index_lines ) )
generate the top-level index page .