# Template for parsing the output from comparator.
shredline = re.compile("(.*):([0-9]+):([0-9]+):([0-9]+)")
- def __init__(self, fp):
+ def __init__(self, fp, dir):
# Read the SCF header
+ self.dir = dir
self.hash_method = "RXOR"
self.merge_program = None
id = fp.readline()
def extract_text(self, clique):
"Return text corresponding to the given clique."
+ if self.dir:
+ olddir = os.getcwd()
+ os.chdir(dir)
for (file, start, end) in clique:
try:
# Try to deduce the text_type
except IOError:
sys.stderr.write("filterator: can't open %s\n" % file)
sys.exit(0)
+ if self.dir:
+ os.chdir(olddir)
return (text_type, text)
def filter_by_size(self, minsize):
stats = debug = 0
dofilter = 1
minsize = 5
+ dir = None
linecounts = {}
for (opt, val) in optlist:
if opt == '-d':
- os.chdir(val)
+ dir = val
elif opt == '-m':
minsize = int(val)
elif opt == '-n':
elif opt == '-x':
debug = 1
- state = CommonReport(sys.stdin)
+ state = CommonReport(sys.stdin, dir)
if minsize:
state.filter_by_size(minsize)
if dofilter: