]> thyrsus.com Git - comparator.git/commitdiff
We handle names as well as file objects now.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 16 Sep 2003 19:50:22 +0000 (19:50 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 16 Sep 2003 19:50:22 +0000 (19:50 +0000)
comparator.py

index 00ba548b78de84b41719c71b1f513b6d28c75474..5cf3dd11756639855c0c155d7dec97ec257680bf 100644 (file)
@@ -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."