def METHOD_NAME(self, stream):
    """Output profiler report.
    """
    log.debug('printing profiler report')
    self.prof.close()
    prof_stats = stats.load(self.pfile)
    prof_stats.sort_stats(self.sort)
    # 2.5 has completely different stream handling from 2.4 and earlier.
    # Before 2.5, stats objects have no stream attribute; in 2.5 and later
    # a reference sys.stdout is stored before we can tweak it.
    compat_25 = hasattr(prof_stats, 'stream')
    if compat_25:
        tmp = prof_stats.stream
        prof_stats.stream = stream
    else:
        tmp = sys.stdout
        sys.stdout = stream
    try:
        if self.restrict:
            log.debug('setting profiler restriction to %s', self.restrict)
            prof_stats.print_stats(*self.restrict)
        else:
            prof_stats.print_stats()
    finally:
        if compat_25:
            prof_stats.stream = tmp
        else:
            sys.stdout = tmp