Core function of the make_table suite, which generates the table
439040
def __make_table(yfmtfunc, fmtfunc, endline, data, fxyz, sortx=None, sorty=None, seplinefunc=None):  # noqa: E501
    """"""
    vx = {}
    vy = {}
    vz = {}
    vxf = {}

    # Python 2 backward compatibility
    fxyz = lambda_tuple_converter(fxyz)

    tmp_len = 0
    for e in data:
        xx, yy, zz = [str(s) for s in fxyz(*e)]
        tmp_len = max(len(yy), tmp_len)
        vx[xx] = max(vx.get(xx, 0), len(xx), len(zz))
        vy[yy] = None
        vz[(xx, yy)] = zz

    vxk = list(vx)
    vyk = list(vy)
    if sortx:
        vxk.sort(key=sortx)
    else:
        try:
            vxk.sort(key=int)
        except Exception:
            try:
                vxk.sort(key=atol)
            except Exception:
                vxk.sort()
    if sorty:
        vyk.sort(key=sorty)
    else:
        try:
            vyk.sort(key=int)
        except Exception:
            try:
                vyk.sort(key=atol)
            except Exception:
                vyk.sort()

    if seplinefunc:
        sepline = seplinefunc(tmp_len, [vx[x] for x in vxk])
        print(sepline)

    fmt = yfmtfunc(tmp_len)
    print(fmt % "", end=' ')
    for x in vxk:
        vxf[x] = fmtfunc(vx[x])
        print(vxf[x] % x, end=' ')
    print(endline)
    if seplinefunc:
        print(sepline)
    for y in vyk:
        print(fmt % y, end=' ')
        for x in vxk:
            print(vxf[x] % vz.get((x, y), "-"), end=' ')
        print(endline)
    if seplinefunc:
        print(sepline)
471801
def rst_table(data, schema=None):
  
  # Process multi-rows (replaced by rows with empty columns when needed)
  pdata = []
  for row in data:
    prow = [el if isinstance(el, list) else [el] for el in row]
    pdata.extend(pr for pr in xzip_longest(*prow, fillvalue=""))

  # Find the columns sizes
  sizes = [max(len("{0}".format(el)) for el in column)
           for column in xzip(*pdata)]
  sizes = [max(size, len(sch)) for size, sch in xzip(sizes, schema)]

  # Creates the title and border rows
  if schema is None:
    schema = pdata[0]
    pdata = pdata[1:]
  border = " ".join("=" * size for size in sizes)
  titles = " ".join("{1:^{0}}".format(*pair)
                    for pair in xzip(sizes, schema))

  # Creates the full table and returns
  rows = [border, titles, border]
  rows.extend(" ".join("{1:<{0}}".format(*pair)
                       for pair in xzip(sizes, row))
              for row in pdata)
  rows.append(border)
  return rows
826181
def make_csv_tables(self):
        
        logger.info('Generate csv report tables')
        report_parts = []
        for sr in self.subreports:
            for data_item in sr.report_data:
                report_parts.append(TextPart(fmt='csv', text=data_item.csv, ext='csv'))
        return report_parts
647587
def convert_table(app, docname, source):
    """"""
    num_tables = 0
    for i,j in enumerate(source):
        table = []
        output = ''
        in_table = False
        for l in j.split('\n'):
            r = l.strip()
            if r.startswith('|'):
                table.append(r)
                in_table = True
            else:
                if in_table is True:
                    converted = _convert_md_table_to_rst(table)
                    if converted is '':
                        print("Failed to convert the markdown table")
                        print(table)
                    else:
                        num_tables += 1
                    output += converted
                    in_table = False
                    table = []
                output += l + '\n'
        source[i] = output
    if num_tables > 0:
        print('Converted %d tables in %s' % (num_tables, docname))
1217031
def create_table(table_name, options = {})
      table_definition = TableDefinition.new
      table_definition.define_primary_keys(options[:primary_keys]) if options[:primary_keys]
      table_definition.define_partition_keys(options[:partition_keys]) if options[:partition_keys]
      table_definition.define_options(options[:options]) if options[:options]

      yield table_definition if block_given?

      announce_operation "create_table(#{table_name})"

      create_cql =  "CREATE TABLE #{table_name} ("
      create_cql << table_definition.to_create_cql
      create_cql << ")"
      create_cql << table_definition.options

      announce_suboperation create_cql

      execute create_cql
    end
42226
def table(*columns, &_block)
      rows = []
      yield(rows)

      @io << tag(:table, class: 'rla-report-table', cellspacing: 0) do |content|
        if table_has_header?(columns)
          content << tag(:tr) do
            columns.map { |col| tag(:th, col[:title]) }.join("\n")
          end
        end

        odd = false
        rows.each do |row|
          odd = !odd
          content << tag(:tr) do
            if odd
              row.map { |cell| tag(:td, cell, class: 'alt') }.join("\n")
            else
              row.map { |cell| tag(:td, cell) }.join("\n")
            end
          end
        end
      end
    end
547658
def make_table(self,
                   tablename: str,
                   fieldspeclist: FIELDSPECLIST_TYPE,
                   dynamic: bool = False,
                   compressed: bool = False) -> Optional[int]:
        """"""
        if self.table_exists(tablename):
            log.info("Skipping creation of table " + tablename +
                     " (already exists)")
            return None
        if not self.is_mysql():
            dynamic = False
            compressed = False
        # http://dev.mysql.com/doc/refman/5.5/en/innodb-compression-usage.html
        sql = """
            CREATE TABLE IF NOT EXISTS {tablename}
            ({fieldspecs})
            {dynamic}
            {compressed}
        """.format(
            tablename=tablename,
            fieldspecs=self.fielddefsql_from_fieldspeclist(fieldspeclist),
            dynamic="ROW_FORMAT=DYNAMIC" if dynamic else "",
            compressed="ROW_FORMAT=COMPRESSED" if compressed else "",
        )
        log.info("Creating table " + tablename)
        return self.db_exec_literal(sql)
388676
def gen_xlsx_table():
    '''
    
    '''


    XLSX_FILE = './database/esheet/20180811.xlsx'
    if os.path.exists(XLSX_FILE):
        pass
    else:
        return

    fields = []
    for sheet_ranges in load_workbook(filename=XLSX_FILE):

        for xr in FILTER_COLUMNS:
            row1_val = sheet_ranges[xr + "1"].value
            row2_val = sheet_ranges[xr + "2"].value
            row3_val = sheet_ranges[xr + "3"].value
            row4_val = sheet_ranges[xr + "4"].value
            if row1_val and row1_val.strip() != '':
                desc = {
                    'slug': row1_val,
                    'name': row2_val,
                    'type': row3_val,
                    'display_mode': row4_val
                }

                fields.append(desc)

    create_tab(fields)
972156
def generate_table(self, rows):
        
        table = PrettyTable(**self.kwargs)
        for row in self.rows:
            if len(row[0]) < self.max_row_width:
                appends = self.max_row_width - len(row[0])
                for i in range(1, appends):
                    row[0].append("-")

            if row[1] is True:
                self.make_fields_unique(row[0])
                table.field_names = row[0]
            else:
                table.add_row(row[0])
        return table
947718
def generate_list_table_result(lexicon_logger, output=None, without_header=None):
    """"""
    if not isinstance(output, list):
        lexicon_logger.debug('Command output is not a list, and then cannot '
                             'be printed with --quiet parameter not enabled.')
        return None

    array = [[
        row.get('id', ''),
        row.get('type', ''),
        row.get('name', ''),
        row.get('content', ''),
        row.get('ttl', '')] for row in output]

    # Insert header (insert before calculating the max width of each column
    # to take headers size into account)
    if not without_header:
        headers = ['ID', 'TYPE', 'NAME', 'CONTENT', 'TTL']
        array.insert(0, headers)

    column_widths = [0, 0, 0, 0, 0]
    # Find max width for each column
    for row in array:
        for idx, col in enumerate(row):
            width = len(str(col))
            if width > column_widths[idx]:
                column_widths[idx] = width

    # Add a 'nice' separator
    if not without_header:
        array.insert(1, ['-' * column_widths[idx]
                         for idx in range(len(column_widths))])

    # Construct table to be printed
    table = []
    for row in array:
        row_list = []
        for idx, col in enumerate(row):
            row_list.append(str(col).ljust(column_widths[idx]))
        table.append(' '.join(row_list))

    # Return table
    return os.linesep.join(table)
479817
private NiceTable generateHeader(final NiceTable table) {
        table.addHeader("Benchmark");
        table.addRow(new String[]{"-", "unit", "sum", "min", "max", "avg", "stddev", "conf95", "runs"});
        return table;
    }
847411
def _build_table(self, info, order, max_col_len=40, only_changed=False):
        

        info_dict, bounds_dict = {}, {}
        (params, val_dict, changed) = info
        col_widths = dict((k,0) for k in order)

        for name, p in params.items():
            if only_changed and not (name in changed):
                continue

            constant = 'C' if p.constant else 'V'
            readonly = 'RO' if p.readonly else 'RW'
            allow_None = ' AN' if hasattr(p, 'allow_None') and p.allow_None else ''

            mode = '%s %s%s' % (constant, readonly, allow_None)
            info_dict[name] = {'name': name, 'type':p.__class__.__name__,
                               'mode':mode}

            if hasattr(p, 'bounds'):
                lbound, ubound = (None,None) if p.bounds is None else p.bounds

                mark_lbound, mark_ubound = False, False
                # Use soft_bounds when bounds not defined.
                if hasattr(p, 'get_soft_bounds'):
                    soft_lbound, soft_ubound = p.get_soft_bounds()
                    if lbound is None and soft_lbound is not None:
                        lbound = soft_lbound
                        mark_lbound = True
                    if ubound is None and soft_ubound is not None:
                        ubound = soft_ubound
                        mark_ubound = True

                if (lbound, ubound) != (None,None):
                    bounds_dict[name] = (mark_lbound, mark_ubound)
                    info_dict[name]['bounds'] = '(%s, %s)' % (lbound, ubound)

            value = repr(val_dict[name])
            if len(value) > (max_col_len - 3):
                value = value[:max_col_len-3] + '...'
            info_dict[name]['value'] = value

            for col in info_dict[name]:
                max_width = max([col_widths[col], len(info_dict[name][col])])
                col_widths[col] = max_width

        return self._tabulate(info_dict, col_widths, changed, order, bounds_dict)
622282
def _gen_property_table(self):
        
        headers = ['Property Name', 'Type', 'Value', 'Default Value']

        table = []
        for propval in sorted(self._properties.itervalues(),
                              key=lambda pval: pval.name.upper()):
            table.append([propval.name,
                np.dtype(propval.dtype).name,
                getattr(self, propval.name),
                propval.default])

        return table, headers
264539
def table_output(data):
    ''''''
    if type(data) == DictType:
        data = data.items()
    headings = [ item[0] for item in data ]
    rows = [ item[1] for item in data ]
    columns = zip(*rows)
    if len(columns):
        widths = [ max([ len(str(y)) for y in row ]) for row in rows ]
    else:
        widths = [ 0 for c in headings ]
    for c, heading in enumerate(headings):
        widths[c] = max(widths[c], len(heading))
    column_count = range(len(rows))
    table = [ ' '.join([ headings[c].ljust(widths[c]) for c in column_count ]) ]
    table.append(' '.join([ '=' * widths[c] for c in column_count ]))
    for column in columns:
        table.append(' '.join([ str(column[c]).ljust(widths[c]) for c in column_count ]))
    return '\n'.join(table)
547141
def create_table_sql(cls, db):
        '''
        
        '''
        parts = ['CREATE TABLE IF NOT EXISTS `%s`.`%s` AS `%s`.`%s`' % (db.db_name, cls.table_name(), db.db_name,
                                                                        cls.engine.main_model.table_name())]
        engine_str = cls.engine.create_table_sql(db)
        parts.append(engine_str)
        return ' '.join(parts)
49872
def table(options)
      lpadding = options.keys.max_by(&:length).length + 2
      rpadding = options.values.max_by { |v| v.to_s.length }.to_s.length
      puts 'PROPERTY'.ljust(lpadding) + 'VALUE'
      puts '=' * (lpadding + rpadding)
      options.keys.sort.each do |key|
        puts key.to_s.ljust(lpadding) + options[key].to_s
      end
      puts
      options
    end
459708
def _generate_html_table(data, out, level=0, extra_style=''):
    '''
    
    '''
    print('<table style="{0}">'.format(
        _lookup_style('table', ['table' + six.text_type(level)])), file=out)

    firstone = True

    row_style = 'row' + six.text_type(level)
    cell_style = 'cell' + six.text_type(level)

    for subdata in data:
        first_style = 'first_first' if firstone else 'notfirst_first'
        second_style = 'first' if firstone else 'other'

        if isinstance(subdata, dict):
            if '__style__' in subdata:
                new_extra_style = subdata['__style__']
                del subdata['__style__']
            else:
                new_extra_style = extra_style
            if len(subdata) == 1:
                name, value = next(six.iteritems(subdata))
                print('<tr style="{0}">'.format(
                    _lookup_style('tr', [row_style])
                ), file=out)
                print('<td style="{0}">{1}</td>'.format(
                    _lookup_style(
                        'td',
                        [cell_style, first_style, 'name', new_extra_style]
                    ),
                    name
                ), file=out)
                if isinstance(value, list):
                    print('<td style="{0}">'.format(
                        _lookup_style(
                            'td',
                            [
                                cell_style,
                                second_style,
                                'container',
                                new_extra_style
                            ]
                        )
                    ), file=out)
                    _generate_html_table(
                        value,
                        out,
                        level + 1,
                        new_extra_style
                    )
                    print('</td>', file=out)
                else:
                    print('<td style="{0}">{1}</td>'.format(
                        _lookup_style(
                            'td',
                            [
                                cell_style,
                                second_style,
                                'value',
                                new_extra_style
                            ]
                        ),
                        cgi.escape(six.text_type(value))
                    ), file=out)
                print('</tr>', file=out)
        elif isinstance(subdata, list):
            print('<tr style="{0}">'.format(
                _lookup_style('tr', [row_style])
            ), file=out)
            print('<td style="{0}">'.format(
                _lookup_style(
                    'td',
                    [cell_style, first_style, 'container', extra_style]
                )
            ), file=out)
            _generate_html_table(subdata, out, level + 1, extra_style)
            print('</td>', file=out)
            print('</tr>', file=out)
        else:
            print('<tr style="{0}">'.format(
                _lookup_style('tr', [row_style])
            ), file=out)
            print('<td style="{0}">{1}</td>'.format(
                _lookup_style(
                    'td',
                    [cell_style, first_style, 'value', extra_style]
                ),
                cgi.escape(six.text_type(subdata))
            ), file=out)
            print('</tr>', file=out)
        firstone = False
    print('</table>', file=out)