Package biana :: Package BianaObjects :: Module output_utilities
[hide private]
[frames] | no frames]

Source Code for Module biana.BianaObjects.output_utilities

 1   
2 -def get_html_table_header(columns, attributes):
3 4 attributes_str = " ".join([ "%s=\"%s\"" %(x[0],x[1]) for x in attributes ]) 5 th_str = "<tr>%s</tr>" %"".join([ "<th>%s</th>" %x for x in columns ]) 6 return "<table %s>%s" %(attributes_str,th_str)
7 #return "<table id=\"biana\" %s>%s" %(attributes_str,th_str) 8
9 -def get_html_table_foot():
10 return "</table>\n"
11
12 -def append_html_table_values(values,rowIDs=None):
13 14 if rowIDs is None: 15 rowIDs = [ x for x in xrange(len(values)) ] 16 17 data_str = "".join([ "<tr rowID=\"%s\">%s</tr>" %(rowIDs[current_row_index],"".join([ "<td>%s</td>" %str(current_column).replace("&","").replace("<","").replace(">","") for current_column in values[current_row_index] ])) for current_row_index in xrange(len(values)) ]) 18 return data_str
19
20 -def get_html_table(columns,values,rowIDs=None,attributes=[],title=""):
21 """ 22 "columns" must be a list with column headers 23 """ 24 25 if rowIDs is None: 26 rowIDs = [ x for x in xrange(len(values)) ] 27 28 attributes_str = " ".join([ "%s=\"%s\"" %(x[0],x[1]) for x in attributes ]) 29 30 th_str = "<tr>%s</tr>" %"".join([ "<th>%s</th>" %x for x in columns ]) 31 data_str = "".join([ "<tr rowID=\"%s\">%s</tr>" %(rowIDs[current_row_index],"".join([ "<td>%s</td>" %str(current_column).replace("&","").replace("<","").replace(">","") for current_column in values[current_row_index] ])) for current_row_index in xrange(len(values)) ]) 32 return "<table %s>%s%s</table>\n" %(attributes_str,th_str,data_str)
33 34
35 -def get_tabulated_table(values,columns=None):
36 """ 37 """ 38 if columns is not None: 39 to_print = ["\t".join(columns)] 40 else: 41 to_print = [] 42 43 to_print.extend(values) 44 45 return "%s\n" %"\n".join( [ "\t".join(map(str,x)) for x in values ] )
46