From: Eric S. Raymond Date: Wed, 17 Sep 2003 21:06:26 +0000 (+0000) Subject: Handle properties. X-Git-Tag: 2.0~20 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=f59f336121e5abfde57ccabd1fe4d25b42a54e88;p=comparator.git Handle properties. --- diff --git a/comparator.py b/comparator.py index 6d37d39..1b852aa 100644 --- a/comparator.py +++ b/comparator.py @@ -108,14 +108,17 @@ class CommonReport: self.merge_program = value elif tag == "Hash-Method": self.hash_method = value - # Read file statistics + # Read file properties self.trees = {} while 1: line = self.fp.readline() if not line or line == '%%\n': break - (tag, chunks, lines, totallines) = line.split(":") - self.trees[tag] = (int(value), int(chunks), int(lines)) + (tree, properties) = line.split(":") + self.trees[tree] = {} + for assignment in properties.split(", "): + (property, value) = assignment.split("=") + self.trees[tree][property] = int(value) # Now read the common-segment stuff self.cliques = [] self.files = {} @@ -230,6 +233,8 @@ class CommonStatistics: def __str__(self): rep = "Trees: " + " ".join(map(lambda x: x[0], self.trees)) rep = "%d overlaps with %s normalization\n" % (self.chunks, self.normalization) - for (tree, lines, total) in self.trees: + for tree in self.trees: + lines = tree['lines'] + total = tree['total'] rep += "%s:\t%d of %d (%02.2f%%)\n" % (tree, lines, total, (lines * 100.0)/total) return rep