Returns a StringIO containing the formatted statistics from _statsfile_.

    _sort_ is a list of fields to sort by.
    _format_ is the name of the method that pstats uses to format the data.
965326
def render_stats(stats, sort, format):
    
    output = StdoutWrapper()
    if hasattr(stats, "stream"):
        stats.stream = output.stream
    stats.sort_stats(*sort)
    getattr(stats, format)()
    return output.stream
1218083
def sort_headers(context, cl):
    
    headers = list(result_headers(context, cl))
    sorted_fields = False
    for h in headers:
        if h['sortable'] and h['sorted']:
            sorted_fields = True
    return {'cl': cl,
            'result_headers': headers,
            'sorted_fields': sorted_fields}
1294692
def _format_strings(self):
        

        values = self.values

        if not isinstance(values, DatetimeIndex):
            values = DatetimeIndex(values)

        if self.formatter is not None and callable(self.formatter):
            return [self.formatter(x) for x in values]

        fmt_values = format_array_from_datetime(
            values.asi8.ravel(),
            format=_get_format_datetime64_from_values(values,
                                                      self.date_format),
            na_rep=self.nat_rep).reshape(values.shape)
        return fmt_values.tolist()
1097290
public final String report() {
        StringBuilder sb = new StringBuilder();
        
        sb.append(String.format("%s stats: %s\n", name, this));

        if (pubs.hasSamples()) {
            String indent = " ";
            if (subs.hasSamples()) {
                sb.append(String.format("%sPub stats: %s\n", indent, pubs));
                indent = "  ";
            }
            if (pubs.getSamples().size() > 1) {
                for (Sample stat : pubs.getSamples()) {
                    sb.append(String.format("%s[%2d] %s (%d msgs)\n", indent,
                            pubs.getSamples().indexOf(stat) + 1, stat, stat.jobMsgCnt));
                }
                sb.append(String.format("%s %s\n", indent, pubs.statistics()));
            }
        }
        if (subs.hasSamples()) {
            String indent = " ";
            sb.append(String.format("%sSub stats: %s\n", indent, subs));
            indent = "  ";
            if (subs.getSamples().size() > 1) {
                for (Sample stat : subs.getSamples()) {
                    sb.append(String.format("%s[%2d] %s (%d msgs)\n", indent,
                            subs.getSamples().indexOf(stat) + 1, stat, stat.jobMsgCnt));
                }
                sb.append(String.format("%s %s\n", indent, subs.statistics()));
            }
        }
        return sb.toString();
    }
385028
def GetFormatterObject(cls, data_type):
    
    data_type = data_type.lower()
    if data_type not in cls._formatter_objects:
      formatter_object = None

      if data_type in cls._formatter_classes:
        formatter_class = cls._formatter_classes[data_type]
        # TODO: remove the need to instantiate the Formatter classes
        # and use class methods only.
        formatter_object = formatter_class()

      if not formatter_object:
        logger.warning(
            'Using default formatter for data type: {0:s}'.format(data_type))
        formatter_object = default.DefaultFormatter()

      cls._formatter_objects[data_type] = formatter_object

    return cls._formatter_objects[data_type]
1122855
def sort(self):
        
        self._matches.sort_values(
            by=[constants.SIZE_FIELDNAME, constants.NGRAM_FIELDNAME,
                constants.COUNT_FIELDNAME, constants.LABEL_FIELDNAME,
                constants.WORK_FIELDNAME, constants.SIGLUM_FIELDNAME],
            ascending=[False, True, False, True, True, True], inplace=True)
573142
def pformat(self):
        '''
        
        '''
        result = "{\n"
        indent1 = " " * 4
        indent2 = " " * 8
        for line_no, code_objects in sorted(self.items()):
            result += '%s%i: [\n' % (indent1, line_no)
            for code_object in code_objects:
                result += '%s"""<%s:%s>""",\n' % (
                    indent2, code_object.PART_TYPE, code_object.content
                )
            result += '%s],\n' % indent1
        result += "}"

        return result
573456
def pformat(self, prefix=()):
        '''
        
        '''
        nan = float("nan")

        def sformat(segment, stat):
            FMT = "n={0}, mean={1}, p50/95={2}/{3}, max={4}"
            line_segs = [segment]
            for s in [stat]:
                p = s.get_percentiles()
                p50, p95 = p.get(0.50, nan), p.get(0.95, nan)
                line_segs.append(FMT.format(s.n, s.mean, p50, p95, s.max))
            return '{0}: {1}'.format(*line_segs)

        lines = []
        for path in sorted(self.path_stats.keys()):
            lines.append('=====================')
            for seg, stat in zip(path, self.path_stats[path]):
                lines.append(sformat(seg, stat))
        return lines
494168
def to_string(self, format_, fps=None, **kwargs):
        
        fp = io.StringIO()
        self.to_file(fp, format_, fps=fps, **kwargs)
        return fp.getvalue()
202658
def pformat(self):
        
        lines = []
        lines.append(("%s (%s)" % (self.name, self.status)).center(50, "-"))
        lines.append("items: {0:,} ({1:,} bytes)".format(self.item_count, self.size))
        cap = self.consumed_capacity.get("__table__", {})
        read = "Read: " + format_throughput(self.read_throughput, cap.get("read"))
        write = "Write: " + format_throughput(self.write_throughput, cap.get("write"))
        lines.append(read + "  " + write)
        if self.decreases_today > 0:
            lines.append("decreases today: %d" % self.decreases_today)

        if self.range_key is None:
            lines.append(str(self.hash_key))
        else:
            lines.append("%s, %s" % (self.hash_key, self.range_key))

        for field in itervalues(self.attrs):
            if field.key_type == "INDEX":
                lines.append(str(field))

        for index_name, gindex in iteritems(self.global_indexes):
            cap = self.consumed_capacity.get(index_name)
            lines.append(gindex.pformat(cap))

        return "\n".join(lines)
95123
def _get_str_range(self, vals_stats):
        """"""
        minmax = vals_stats[1] # stats minmax
        minval = self.fmtstr.format(minmax[0])
        maxval = self.fmtstr.format(minmax[1])
        return '{A} to {B:6>}'.format(A=minval, B=maxval)
632916
def sort_by(self, sf):
    
    params = join_params(self.parameters, {"sf": sf})

    return self.__class__(**params)
916591
def stat(path, format):
    
    cmd = "hadoop fs -stat %s %s" % (format, path)
    rcode, stdout, stderr = _checked_hadoop_fs_command(cmd)
    return stdout.rstrip()
305514
def format_response(self, data):
        
        self.count = self.max_count

        return OrderedDict([
            ('highest_count', self.max_count),
            ('overall_total', self.total),
            ('next', self.get_next_link()),
            ('previous', self.get_previous_link()),
            ('results', data)
        ])
1036938
def GetStructFormatString(self):
    
    if self._format_string is None and self._data_type_maps:
      format_strings = []
      for member_data_type_map in self._data_type_maps:
        if member_data_type_map is None:
          return None

        member_format_string = member_data_type_map.GetStructFormatString()
        if member_format_string is None:
          return None

        format_strings.append(member_format_string)

      self._format_string = ''.join(format_strings)

    return self._format_string
331023
def format(self, formatter, *args, **kwargs):
        
        # TODO: data export?
        return self.get_formatter(formatter)(*args, **kwargs)
395503
def _format_count_file(count_file, data):
    
    COUNT_COLUMN = 5
    out_file = os.path.splitext(count_file)[0] + ".fixed.counts"
    if file_exists(out_file):
        return out_file

    df = pd.io.parsers.read_table(count_file, sep="\t", index_col=0, header=1)
    df_sub = df.ix[:, COUNT_COLUMN]
    with file_transaction(data, out_file) as tx_out_file:
        df_sub.to_csv(tx_out_file, sep="\t", index_label="id", header=False)
    return out_file