From e9c986cceaf2ebea99720bc17420a7a5c5ff5889 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 16 Sep 2003 20:45:51 +0000 Subject: [PATCH] We now have a statistics object. --- comparator.py | 14 ++++++++++++++ filterator | 5 +---- 2 files changed, 15 insertions(+), 4 deletions(-) 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: -- 2.43.0