Format a single row (if necessary)
426888
def get_row(self, row):
        ''''''

        if isinstance(self.fields, dict):
            return dict([
                (key, text_type(value).format(**row) if RE_FORMATTED.match(value) else row[value])
                for key, value in self.fields.items()
            ])
        else:
            return [text_type(field).format(**row) if RE_FORMATTED.match(field)
                    else row[field]
                    for field in self.fields]
246152
def summarize_attr(key, value, col_width=None):
    """"""
    # Indent key and add ':', then right-pad if col_width is not None
    k_str = '    {}:'.format(key)
    if col_width is not None:
        k_str = pretty_print(k_str, col_width)
    # Replace tabs and newlines, so we print on one line in known width
    v_str = str(value).replace('\t', '\\t').replace('\n', '\\n')
    # Finally, truncate to the desired display width
    return maybe_truncate('{} {}'.format(k_str, v_str),
                          OPTIONS['display_width'])
1044465
def _format_week(self, name, type, a_per):
        """"""
        return '{},{},{}/{},{}/{}'.format(name, type, a_per.st_month, a_per.st_day,
                                          a_per.end_month, a_per.end_day)
1326497
def create_md_row(self, row, header=False):
        """"""
        if not row:
            return
        cols = row.split('\t')
        if len(cols) == 1:
            self.out.append(cols[0])
        else:
            col_md = '|'
            underline_md = '|'

            if cols:
                for col in cols:
                    col_md += col + '|'
                    underline_md += '-|'

            if header:
                self.out.append(col_md + '\n' + underline_md)
            else:
                self.out.append(col_md)
94342
function doRow1Col(dataType, data, expand){
    return format(ROW1COL, doRowStyle(dataType, expand), data);
}
844111
def table_format(self, columns, content):
        
        result = []
        textw = TextWidget()
        for row in content:
            i = 0
            result_row = []
            for cell in row:
                result_row.append(textw.render(cell, **columns[i]))
                i += 1
            result.append(result_row)
        return (columns, result)
449097
def format_line(data, linestyle):
    """"""
    return linestyle.begin + linestyle.sep.join(data) + linestyle.end
464889
def _validate_row(row, sep=',', required_length=None):
    '''

    '''
    if not isinstance(row, list):
        row = _parse_row(row, sep)

    if required_length:
        length = len(row)
        if length != required_length:
            bot.warning('Row should have length %s (not %s)' %(required_length,
                                                               length))
            bot.warning(row) 
            row = None

    return row
1363281
def _format_table(fmt, headers, rows, colwidths, colaligns):
    """"""
    lines = []
    hidden = fmt.with_header_hide if (headers and fmt.with_header_hide) else []
    pad = fmt.padding
    headerrow = fmt.headerrow

    padded_widths = [(w + 2*pad) for w in colwidths]
    padded_headers = _pad_row(headers, pad)
    padded_rows = [_pad_row(row, pad) for row in rows]

    if fmt.lineabove and "lineabove" not in hidden:
        lines.append(_build_line(padded_widths, colaligns, fmt.lineabove))

    if padded_headers:
        lines.append(_build_row(padded_headers, padded_widths, colaligns, headerrow))
        if fmt.linebelowheader and "linebelowheader" not in hidden:
            lines.append(_build_line(padded_widths, colaligns, fmt.linebelowheader))

    if padded_rows and fmt.linebetweenrows and "linebetweenrows" not in hidden:
        # initial rows with a line below
        for row in padded_rows[:-1]:
            lines.append(_build_row(row, padded_widths, colaligns, fmt.datarow))
            lines.append(_build_line(padded_widths, colaligns, fmt.linebetweenrows))
        # the last row without a line below
        lines.append(_build_row(padded_rows[-1], padded_widths, colaligns, fmt.datarow))
    else:
        for row in padded_rows:
            lines.append(_build_row(row, padded_widths, colaligns, fmt.datarow))

    if fmt.linebelow and "linebelow" not in hidden:
        lines.append(_build_line(padded_widths, colaligns, fmt.linebelow))

    return "\n".join(lines)
1204648
def format_no_tty(table):
    """"""

    for i, row in enumerate(table.rows):
        for j, item in enumerate(row):
            table.rows[i][j] = format_output(item, fmt='raw')
    ptable = table.prettytable()

    for col in table.columns:
        ptable.align[col] = 'l'

    ptable.hrules = prettytable.NONE
    ptable.border = False
    ptable.header = False
    ptable.left_padding_width = 0
    ptable.right_padding_width = 2
    return ptable
97983
def format_data(data):
    
    if data is None:
        return None
    return u":".join([u"{:02x}".format(ord(c)) for c in data])
204837
function format(text) {
    const lintResult = linter.executeOnText(text)
    return lintResult.results[0].output || text
}
583716
def table_formatter(self, dataframe, inc_header=1, inc_index=1):
        """"""
        return TableFormatter(dataframe, inc_header=inc_header, inc_index=inc_index)
233996
def format_value(value):
    
    if isinstance(value, list):
        value = ", ".join([v.strip() for v in value])
    return value
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
1241062
def _parse_row(row, sep=','):
    '''

    '''
    parsed = row.split(sep)
    parsed = [x for x in parsed if x.strip()]
    return parsed
821932
def unindent(buffer, from_row, to_row, count=1):
    
    current_row = buffer.document.cursor_position_row
    line_range = range(from_row, to_row)

    def transform(text):
        remove = '    ' * count
        if text.startswith(remove):
            return text[len(remove):]
        else:
            return text.lstrip()

    # Apply transformation.
    new_text = buffer.transform_lines(line_range, transform)
    buffer.document = Document(
        new_text,
        Document(new_text).translate_row_col_to_index(current_row, 0))

    # Go to the start of the line.
    buffer.cursor_position += buffer.document.get_start_of_line_position(after_whitespace=True)