docs: def format_table(table, column_names=None, column_specs=None, max_col_width=32,
                   report_dimensions=False):
      ''' Table pretty printer.
      Expects tables to be given as arrays of arrays.
  
      Example:
  
          print format_table([[1, "2"], [3, "456"]], column_names=['A', 'B'])
  
      '''
      if len(table) > 0:
          col_widths = [0] * len(list(table)[0])
      elif column_specs is not None:
          col_widths = [0] * (len(column_specs) + 1)
      elif column_names is not None:
          col_widths = [0] * len(column_names)
      my_column_names = []
      if column_specs is not None:
          column_names = ['Row']
          column_names.extend([col['name'] for col in column_specs])
          column_specs = [{'name': 'Row', 'type': 'float'}] + column_specs
      if column_names is not None:
          for i in range(len(column_names)):
              my_col = str(column_names[i])
              if len(my_col) > max_col_width:
                  my_col = my_col[:max_col_width-1] + '…'
              my_column_names.append(my_col)
              col_widths[i] = max(col_widths[i], len(my_col))
      my_table = []
      for row in table:
          my_row = []
          for i in range(len(row)):
              my_item = escape_unicode_string(str(row[i]))
              if len(my_item) > max_col_width:
                  my_item = my_item[:max_col_width-1] + '…'
              my_row.append(my_item)
              col_widths[i] = max(col_widths[i], len(my_item))
          my_table.append(my_row)
  
      def border(i):
          return WHITE() + i + ENDC()
  
      type_colormap = {'boolean': BLUE(),
                       'integer': YELLOW(),
                       'float': WHITE(),
                       'string': GREEN()}
      for i in 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64':
          type_colormap[i] = type_colormap['integer']
      type_colormap['double'] = type_colormap['float']
  
      def col_head(i):
          if column_specs is not None:
              return BOLD() + type_colormap[column_specs[i]['type']] + column_names[i] + ENDC()
          else:
              return BOLD() + WHITE() + column_names[i] + ENDC()
  
      formatted_table = [border('┌') + border('┬').join(border('─')*i for i in col_widths) + border('┐')]
      if len(my_column_names) > 0:
          padded_column_names = [col_head(i) + ' '*(col_widths[i]-len(my_column_names[i])) for i in range(len(my_column_names))]
          formatted_table.append(border('│') + border('│').join(padded_column_names) + border('│'))
          formatted_table.append(border('├') + border('┼').join(border('─')*i for i in col_widths) + border('┤'))
  
      for row in my_table:
          padded_row = [row[i] + ' '*(col_widths[i]-len(row[i])) for i in range(len(row))]
          formatted_table.append(border('│') + border('│').join(padded_row) + border('│'))
      formatted_table.append(border('└') + border('┴').join(border('─')*i for i in col_widths) + border('┘'))
  
      if report_dimensions:
          return '\n'.join(formatted_table), len(formatted_table), sum(col_widths) + len(col_widths) + 1
      else:
          return '\n'.join(formatted_table)