From: Eric S. Raymond Date: Tue, 16 Sep 2003 20:45:51 +0000 (+0000) Subject: We now have a statistics object. X-Git-Tag: 2.0~34 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=e9c986cceaf2ebea99720bc17420a7a5c5ff5889;p=comparator.git We now have a statistics object. --- diff --git a/comparator.py b/comparator.py index 5cf3dd1..1a6e15d 100644 --- a/comparator.py +++ b/comparator.py @@ -209,3 +209,17 @@ class CommonReport: raise ComparatorException("couldn't extracrt file text") self.cliques = filtered +class CommonStatistics: + "Statistical information from a report." + def __init__(self, report): + self.chunks = report.segment_count() + self.trees = [] + for (tree, totallines) in report.trees.items(): + lines = report.line_count(tree) + self.trees.append((tree, lines, totallines)) + + def __str__(self): + rep = "%d overlaps\n" % self.chunks + for (tree, lines, total) in self.trees: + rep += "%s:%d:%d\n" % (tree, lines, total) + return rep diff --git a/filterator b/filterator index 635ef9f..608b413 100755 --- a/filterator +++ b/filterator @@ -64,10 +64,7 @@ if __name__ == '__main__': state.filter_by_significance() if stats: - print "%d overlaps" % state.segment_count() - for (tree, totallines) in state.trees.items(): - lines = state.line_count(tree) - print "%s:%d:%d" % (tree, lines, state.trees[tree]) + sys.stdout.write(str(comparator.CommonStatistics(state))) else: report_common(state) except comparator.ComparatorException, e: