Commit feac83ce authored by Petr Špaček's avatar Petr Špaček

msgdiff: create main function to make msgdiff importable

parent 30b9ec83
......@@ -277,30 +277,30 @@ def process_results(diff_generator):
uniq[field] = collections.OrderedDict(uniq[field].most_common(20))
pprint(uniq)
target = 'kresd'
ccriteria = ['opcode', 'rcode', 'flags', 'question', 'qname', 'qtype', 'answer'] #'authority', 'additional', 'edns']
def main():
target = 'kresd'
ccriteria = ['opcode', 'rcode', 'flags', 'question', 'qname', 'qtype', 'answer'] #'authority', 'additional', 'edns']
#ccriteria = ['opcode', 'rcode', 'flags', 'question', 'qname', 'qtype', 'answer', 'authority', 'additional', 'edns', 'nsid']
if False:
dir_names = itertools.tee(find_querydirs(sys.argv[1]), 2)
for d in dir_names:
print(d)
workdirs = itertools.islice(find_querydirs(sys.argv[1]), 100000)
print('diffs = {')
serial = False
if serial:
worker_init(ccriteria, target)
process_results(map(compare_wrapper, workdirs))
else:
with pool.Pool(
processes=4,
initializer=worker_init,
initargs=(ccriteria, target)
) as p:
process_results(p.imap_unordered(compare_wrapper, workdirs, chunksize=100))
if False:
dir_names = itertools.tee(find_querydirs(sys.argv[1]), 2)
for d in dir_names:
print(d)
workdirs = itertools.islice(find_querydirs(sys.argv[1]), 100000)
print('diffs = {')
serial = False
if serial:
worker_init(ccriteria, target)
process_results(map(compare_wrapper, workdirs))
else:
with pool.Pool(
processes=4,
initializer=worker_init,
initargs=(ccriteria, target)
) as p:
process_results(p.imap_unordered(compare_wrapper, workdirs, chunksize=100))
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment