Format lister row.
199803
public function formatRow()
    {
        parent::formatRow();

        if (is_array($this->current_row) || $this->current_row instanceof ArrayAccess) {
            $this->odd_even =
                $this->odd_even == $this->odd_css_class
                    ? $this->even_css_class
                    : $this->odd_css_class;
            $this->current_row['odd_even'] = $this->odd_even;
        }
    }
422352
def <<(row)
      if row == Border::SEPARATOR
        separators << columns_size - (header ? 0 : 2)
      else
        rows_copy = rows.dup
        assert_row_sizes rows_copy << row
        rows << to_row(row)
      end
      self
    end
1238577
def simple_separated_format(separator):
    
    return TableFormat(None, None, None, None,
                       headerrow=DataRow('', separator, ''),
                       datarow=DataRow('', separator, ''),
                       padding=0, with_header_hide=None)
196298
def format_items(self, data, many):
        
        if many:
            return [self.format_item(item) for item in data]
        else:
            return self.format_item(data)
227858
def prettytable(self):
        """"""
        table = prettytable.PrettyTable(self.columns)

        if self.sortby:
            if self.sortby in self.columns:
                table.sortby = self.sortby
            else:
                msg = "Column (%s) doesn't exist to sort by" % self.sortby
                raise exceptions.CLIAbort(msg)
        for a_col, alignment in self.align.items():
            table.align[a_col] = alignment

        if self.title:
            table.title = self.title
        # Adding rows
        for row in self.rows:
            table.add_row(row)
        return table
1369182
def format_rst(self):
        
        res = ''
        num_cols = len(self.header)
        col_width = 25
        for _ in range(num_cols):
            res += ''.join(['=' for _ in range(col_width - 1)]) + ' ' 
        res += '\n'
        for c in self.header:
            res += c.ljust(col_width) 
        res += '\n'
        for _ in range(num_cols):
            res += ''.join(['=' for _ in range(col_width - 1)]) + ' ' 
        res += '\n'
        for row in self.arr:
            for c in row:
                res += self.force_to_string(c).ljust(col_width)
            res += '\n' 
        for _ in range(num_cols):
            res += ''.join(['=' for _ in range(col_width - 1)]) + ' ' 
        res += '\n'
        return res
762710
def iter_top_row_tcs(self):
        """"""
        tr = self._tbl.tr_lst[self._top]
        for tc in tr.tc_lst[self._left:self._right]:
            yield tc
507378
def FormatContext(self):
    """"""
    text = ''
    if hasattr(self, 'feed_name'):
      text += "In feed '%s': " % self.feed_name
    if hasattr(self, 'file_name'):
      text += self.file_name
    if hasattr(self, 'row_num'):
      text += ":%i" % self.row_num
    if hasattr(self, 'column_name'):
      text += " column %s" % self.column_name
    return text
655456
def format_row(self, row):
        
        assert all(isinstance(x, VTMLBuffer) for x in row)
        raw = (fn(x) for x, fn in zip(row, self.formatters))
        for line in itertools.zip_longest(*raw):
            line = list(line)
            for i, col in enumerate(line):
                if col is None:
                    line[i] = self._get_blank_cell(i)
            yield line
60726
def separator(self):
        
        cells = dict([(column, "-" * self.column_widths[column]) for column in self.columns])
        return ColorRow(self, **cells)
50851
def rows(self, cell_mode=CellMode.cooked):
    
    for row_index in range(self.nrows):
      yield self.parse_row(self.get_row(row_index), row_index, cell_mode)
1342490
def colformat(strings, num_sep_spaces=1, terminal_width=None):
    """"""
    if terminal_width is None:
        terminal_width = get_terminal_size().columns

    if not strings:
        return

    num_items = len(strings)
    max_len = max([len(strip_ansi_escapes(s)) for s in strings])

    num_columns = min(
        int((terminal_width + num_sep_spaces) / (max_len + num_sep_spaces)),
        num_items)
    num_columns = max(1, num_columns)

    num_lines = int(math.ceil(float(num_items) / num_columns))
    num_columns = int(math.ceil(float(num_items) / num_lines))

    num_elements_last_column = num_items % num_lines
    if num_elements_last_column == 0:
        num_elements_last_column = num_lines

    lines = []
    for i in range(num_lines):
        line_size = num_columns
        if i >= num_elements_last_column:
            line_size -= 1
        lines.append([None] * line_size)

    for i, line in enumerate(lines):
        line_size = len(line)
        for j in range(line_size):
            k = i + num_lines * j
            item = strings[k]
            if j % line_size != line_size - 1:
                item_len = len(strip_ansi_escapes(item))
                item = item + ' ' * (max_len - item_len)
            line[j] = item

    sep = ' ' * num_sep_spaces
    for line in lines:
        yield sep.join(line)
545078
def row2table(soup, table, row):
    """"""
    tr = Tag(soup, name="tr")
    table.append(tr)
    for attr in row:
        td = Tag(soup, name="td")
        tr.append(td)
        td.append(attr)
1285162
def columnise(rows, padding=2):
    """"""
    strs = []
    maxwidths = {}

    for row in rows:
        for i, e in enumerate(row):
            se = str(e)
            nse = len(se)
            w = maxwidths.get(i, -1)
            if nse > w:
                maxwidths[i] = nse

    for row in rows:
        s = ''
        for i, e in enumerate(row):
            se = str(e)
            if i < len(row) - 1:
                n = maxwidths[i] + padding - len(se)
                se += ' ' * n
            s += se
        strs.append(s)
    return strs
129912
def _build_simple_row(padded_cells, rowfmt):
    ""
    begin, sep, end = rowfmt
    return (begin + sep.join(padded_cells) + end).rstrip()
571531
def format_records(records):
    """"""
    formatted = list()
    for record_ in records:
        formatted.append(format_record(record_))
    return formatted
492976
def __format_row(self, row: AssetAllocationViewModel):
        
        output = ""
        index = 0

        # Name
        value = row.name
        # Indent according to depth.
        for _ in range(0, row.depth):
            value = f"   {value}"
        output += self.append_text_column(value, index)

        # Set Allocation
        value = ""
        index += 1
        if row.set_allocation > 0:
            value = f"{row.set_allocation:.2f}"
        output += self.append_num_column(value, index)

        # Current Allocation
        value = ""
        index += 1
        if row.curr_allocation > Decimal(0):
            value = f"{row.curr_allocation:.2f}"
        output += self.append_num_column(value, index)

        # Allocation difference, percentage
        value = ""
        index += 1
        if row.alloc_diff_perc.copy_abs() > Decimal(0):
            value = f"{row.alloc_diff_perc:.0f} %"
        output += self.append_num_column(value, index)

        # Allocated value
        index += 1
        value = ""
        if row.set_value:
            value = f"{row.set_value:,.0f}"
        output += self.append_num_column(value, index)

        # Current Value
        index += 1
        value = f"{row.curr_value:,.0f}"
        output += self.append_num_column(value, index)

        # Value in security's currency. Show only if displaying full model, with stocks.
        index += 1
        if self.full:
            value = ""
            if row.curr_value_own_currency:
                value = f"({row.curr_value_own_currency:,.0f}"
                value += f" {row.own_currency}"
                value += ")"
            output += self.append_num_column(value, index)

        # https://en.wikipedia.org/wiki/ANSI_escape_code
        # CSI="\x1B["
        # red = 31, green = 32
        # output += CSI+"31;40m" + "Colored Text" + CSI + "0m"

        # Value diff
        index += 1
        value = ""
        if row.diff_value:
            value = f"{row.diff_value:,.0f}"
            # Color the output
            # value = f"{CSI};40m{value}{CSI};40m"
        output += self.append_num_column(value, index)

        return output