nodes: 0, module; 1, function_definition; 2, function_name:ToHtml; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, if_statement; 16, expression_statement; 17, expression_statement; 18, for_statement; 19, expression_statement; 20, expression_statement; 21, comment:# We now go over the data and add each row; 22, for_statement; 23, expression_statement; 24, return_statement; 25, identifier:columns_order; 26, None; 27, identifier:order_by; 28, tuple; 29, comment:"""Writes the data table as an HTML table code string.
  
      Args:
        columns_order: Optional. Specifies the order of columns in the
                       output table. Specify a list of all column IDs in the order
                       in which you want the table created.
                       Note that you must list all column IDs in this parameter,
                       if you use it.
        order_by: Optional. Specifies the name of the column(s) to sort by.
                  Passed as is to _PreparedData.
  
      Returns:
        An HTML table code string.
        Example result (the result is without the newlines):
         <html><body><table border="1">
          <thead><tr><th>a</th><th>b</th><th>c</th></tr></thead>
          <tbody>
           <tr><td>1</td><td>"z"</td><td>2</td></tr>
           <tr><td>"3$"</td><td>"w"</td><td></td></tr>
          </tbody>
         </table></body></html>
  
      Raises:
        DataTableException: The data does not match the type.
      """; 30, assignment; 31, assignment; 32, assignment; 33, assignment; 34, assignment; 35, assignment; 36, comparison_operator:columns_order is None; 37, block; 38, assignment; 39, assignment; 40, identifier:col; 41, identifier:columns_order; 42, block; 43, assignment; 44, assignment; 45, pattern_list; 46, call; 47, block; 48, assignment; 49, binary_operator:table_template % (columns_html + rows_html); 50, identifier:table_template; 51, string:"<html><body><table border=\"1\">%s</table></body></html>"; 52, identifier:columns_template; 53, string:"<thead><tr>%s</tr></thead>"; 54, identifier:rows_template; 55, string:"<tbody>%s</tbody>"; 56, identifier:row_template; 57, string:"<tr>%s</tr>"; 58, identifier:header_cell_template; 59, string:"<th>%s</th>"; 60, identifier:cell_template; 61, string:"<td>%s</td>"; 62, identifier:columns_order; 63, None; 64, expression_statement; 65, identifier:col_dict; 66, call; 67, identifier:columns_list; 68, list; 69, expression_statement; 70, identifier:columns_html; 71, binary_operator:columns_template % "".join(columns_list); 72, identifier:rows_list; 73, list; 74, identifier:row; 75, identifier:unused_cp; 76, attribute; 77, argument_list; 78, expression_statement; 79, comment:# We add all the elements of this row by their order; 80, for_statement; 81, expression_statement; 82, identifier:rows_html; 83, binary_operator:rows_template % "".join(rows_list); 84, identifier:table_template; 85, parenthesized_expression; 86, assignment; 87, identifier:dict; 88, argument_list; 89, call; 90, identifier:columns_template; 91, call; 92, identifier:self; 93, identifier:_PreparedData; 94, identifier:order_by; 95, assignment; 96, identifier:col; 97, identifier:columns_order; 98, comment:# For empty string we want empty quotes ("").; 99, block; 100, call; 101, identifier:rows_template; 102, call; 103, binary_operator:columns_html + rows_html; 104, identifier:columns_order; 105, list_comprehension; 106, list_comprehension; 107, attribute; 108, argument_list; 109, attribute; 110, argument_list; 111, identifier:cells_list; 112, list; 113, expression_statement; 114, if_statement; 115, if_statement; 116, attribute; 117, argument_list; 118, attribute; 119, argument_list; 120, identifier:columns_html; 121, identifier:rows_html; 122, subscript; 123, for_in_clause; 124, tuple; 125, for_in_clause; 126, identifier:columns_list; 127, identifier:append; 128, binary_operator:header_cell_template %
                            html.escape(col_dict[col]["label"]); 129, string:""; 130, identifier:join; 131, identifier:columns_list; 132, assignment; 133, boolean_operator; 134, block; 135, call; 136, comment:# We have a formatted value and we're going to use it; 137, block; 138, else_clause; 139, identifier:rows_list; 140, identifier:append; 141, binary_operator:row_template % "".join(cells_list); 142, string:""; 143, identifier:join; 144, identifier:rows_list; 145, identifier:col; 146, string:"id"; 147, identifier:col; 148, attribute; 149, subscript; 150, identifier:col; 151, identifier:col; 152, attribute; 153, identifier:header_cell_template; 154, call; 155, identifier:value; 156, string:""; 157, comparison_operator:col in row; 158, comparison_operator:row[col] is not None; 159, expression_statement; 160, identifier:isinstance; 161, argument_list; 162, expression_statement; 163, block; 164, identifier:row_template; 165, call; 166, identifier:self; 167, identifier:__columns; 168, identifier:col; 169, string:"id"; 170, identifier:self; 171, identifier:__columns; 172, attribute; 173, argument_list; 174, identifier:col; 175, identifier:row; 176, subscript; 177, None; 178, assignment; 179, identifier:value; 180, identifier:tuple; 181, call; 182, expression_statement; 183, attribute; 184, argument_list; 185, identifier:html; 186, identifier:escape; 187, subscript; 188, identifier:row; 189, identifier:col; 190, identifier:value; 191, call; 192, attribute; 193, argument_list; 194, call; 195, string:""; 196, identifier:join; 197, identifier:cells_list; 198, subscript; 199, string:"label"; 200, attribute; 201, argument_list; 202, identifier:cells_list; 203, identifier:append; 204, binary_operator:cell_template % html.escape(self.ToString(value[1])); 205, attribute; 206, argument_list; 207, identifier:col_dict; 208, identifier:col; 209, identifier:self; 210, identifier:CoerceValue; 211, subscript; 212, subscript; 213, identifier:cell_template; 214, call; 215, identifier:cells_list; 216, identifier:append; 217, binary_operator:cell_template % html.escape(self.ToString(value)); 218, identifier:row; 219, identifier:col; 220, subscript; 221, string:"type"; 222, attribute; 223, argument_list; 224, identifier:cell_template; 225, call; 226, identifier:col_dict; 227, identifier:col; 228, identifier:html; 229, identifier:escape; 230, call; 231, attribute; 232, argument_list; 233, attribute; 234, argument_list; 235, identifier:html; 236, identifier:escape; 237, call; 238, identifier:self; 239, identifier:ToString; 240, subscript; 241, attribute; 242, argument_list; 243, identifier:value; 244, integer:1; 245, identifier:self; 246, identifier:ToString; 247, identifier:value
code: def ToHtml(self, columns_order=None, order_by=()):
      """Writes the data table as an HTML table code string.
  
      Args:
        columns_order: Optional. Specifies the order of columns in the
                       output table. Specify a list of all column IDs in the order
                       in which you want the table created.
                       Note that you must list all column IDs in this parameter,
                       if you use it.
        order_by: Optional. Specifies the name of the column(s) to sort by.
                  Passed as is to _PreparedData.
  
      Returns:
        An HTML table code string.
        Example result (the result is without the newlines):
         <html><body><table border="1">
          <thead><tr><th>a</th><th>b</th><th>c</th></tr></thead>
          <tbody>
           <tr><td>1</td><td>"z"</td><td>2</td></tr>
           <tr><td>"3$"</td><td>"w"</td><td></td></tr>
          </tbody>
         </table></body></html>
  
      Raises:
        DataTableException: The data does not match the type.
      """
      table_template = "<html><body><table border=\"1\">%s</table></body></html>"
      columns_template = "<thead><tr>%s</tr></thead>"
      rows_template = "<tbody>%s</tbody>"
      row_template = "<tr>%s</tr>"
      header_cell_template = "<th>%s</th>"
      cell_template = "<td>%s</td>"
  
      if columns_order is None:
        columns_order = [col["id"] for col in self.__columns]
      col_dict = dict([(col["id"], col) for col in self.__columns])
  
      columns_list = []
      for col in columns_order:
        columns_list.append(header_cell_template %
                            html.escape(col_dict[col]["label"]))
      columns_html = columns_template % "".join(columns_list)
  
      rows_list = []
      # We now go over the data and add each row
      for row, unused_cp in self._PreparedData(order_by):
        cells_list = []
        # We add all the elements of this row by their order
        for col in columns_order:
          # For empty string we want empty quotes ("").
          value = ""
          if col in row and row[col] is not None:
            value = self.CoerceValue(row[col], col_dict[col]["type"])
          if isinstance(value, tuple):
            # We have a formatted value and we're going to use it
            cells_list.append(cell_template % html.escape(self.ToString(value[1])))
          else:
            cells_list.append(cell_template % html.escape(self.ToString(value)))
        rows_list.append(row_template % "".join(cells_list))
      rows_html = rows_template % "".join(rows_list)
  
      return table_template % (columns_html + rows_html)