def html_tableify(item_matrix, select=None, header=None , footer=None) :
    """ returnr a string for an html table"""
    if not item_matrix :
        return ''
    html_cols = []
    tds = lambda text : '<td>'+text+'  </td>'
    trs = lambda text : '<tr>'+text+'</tr>'
    tds_items = [list(map(tds, row)) for row in item_matrix]
    if select :
        row, col = select
        tds_items[row][col] = '<td class="inverted">'\
                +item_matrix[row][col]\
                +'  </td>'
    #select the right item
    html_cols = map(trs, (''.join(row) for row in tds_items))
    head = ''
    foot = ''
    if header :
        head = ('<tr>'\
            +''.join(('<td>'+header+'</td>')*len(item_matrix[0]))\
            +'</tr>')

    if footer :
        foot = ('<tr>'\
            +''.join(('<td>'+footer+'</td>')*len(item_matrix[0]))\
            +'</tr>')
    html = ('<table class="completion" style="white-space:pre"'
            'cellspacing=0>' +
            head + (''.join(html_cols)) + foot + '</table>')
    return html
 returnr a string for an html table
angrmanagement/vendor/qtconsole/completion_html.py