</varlistentry>
</variablelist>
-<para>The data section consists of a sequence of range sets. Each range set
-consists of two or more ranges followed by a line containing a %%\n
-section marker. A range is represented as three tab-separated fields:
-filename, start line, and end line. Line numbers are 1-origin.</para>
+<para>The data section consists of a statistics block followed by a
+sequence of range sets. The statistics block consists of ant number
+of count lines followed by a %%\n section marker. Each linecount line
+consists of two colon-separated fields, a tree name and a line count.</para>
+
+<para>Each range set consists of two or more ranges followed by a line
+containing a %%\n section marker. A range is represented as three
+tab-separated fields: filename, start line, and end line. Line
+numbers are 1-origin.</para>
<para>The natural sort order for range sets is by filename, then by
start line, then by end line. Ranges within range sets should be
def __init__(self, name):
self.name = name
self.fp = open(name)
+ shif.totallines = 0
self.comments = []
self.hashcount = 0
id = self.fp.readline()
shif.hashcount += 1
if hashcount % 10000 == 0:
sys.stderr.write("\b\b\b%02.0f%%" % (shif.fp.tell() / (total * 0.01)))
+ (shif.totallines,) = struct.unpack("!i", shif.fp.read(4))
return True
def item_factory(db):
print "After sorting:", matches
report_time("Reduction done")
# OK, dump all matches.
- print "#SCF-B 1.0"
+ print "#SCF-B 1.1"
print "Hash-Method: MD5"
print "Normalization:", ",".join(shiflist[0].normalization)
- print "Merge-Program: shredcompare.py 1.0"
+ print "Merge-Program: shredcompare.py 1.1"
print "Shred-Size: %d" % shiflist[0].shredsize
print "%%"
+ for shif in shiflist:
+ print "%s:%d" % (shif.name,shif.totallines)
+ print "%%"
# FIXME: do something appropriate with comments
for match in matches:
for range in match:
elif opt == '-x':
debug = True
if args:
- print "#SCF-A 1.0"
+ print "#SCF-A 1.1"
print "Generator-Program: shredtree.py 1.0"
print "Hash-Method: MD5"
print "Normalization: %s" % ",".join(normalization);
if ws: normalization.append("remove_whitespace")
if not normalization:
normalization.append("none")
- print "%%"
+ print "%%"
+ totalbytes = 0
filenames = []
for root, dirs, files in os.walk(args[0]):
for file in files:
filenames.sort()
sys.stdout.write(struct.pack("!i", len(filenames)))
for path in filenames:
- shredfile(path)
+ totalbytes = totalbytes + shredfile(path)
+ sys.stdout.write(struct.pack("!i", totalbytes))
# End