From 3839a78e264b92f4dac3a891df9dc920860e8dc7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 16 Sep 2003 19:50:22 +0000 Subject: [PATCH] We handle names as well as file objects now. --- comparator.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/comparator.py b/comparator.py index 00ba548..5cf3dd1 100644 --- a/comparator.py +++ b/comparator.py @@ -77,6 +77,12 @@ class CommonReport: shredline = re.compile("(.*):([0-9]+):([0-9]+):([0-9]+)") def __init__(self, fp, dir): + "Read and parse an SCF-B report." + # Handle either file objects or strings + self.name = None + if type(fp) == type(""): + self.name = fp + self.fp = file(self.name) # Read the SCF header self.dir = dir self.hash_method = "RXOR" @@ -124,6 +130,9 @@ class CommonReport: if line == '%%\n': self.cliques.append(locations) locations = [] + # We're done, clean up + if self.name: + self.fp.close() def segment_count(self): "Number of common chunks in the report." -- 2.43.0