forked from Klim314/Quetzalcoatl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patternScan.py
executable file
·32 lines (27 loc) · 1007 Bytes
/
patternScan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
"""
patternScan.py
application of pattern.py to a set of input files
"""
import pattern
import os
import multiprocessing
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("target", help= "Directory containing all files", default = "input/pattern/")
parser.add_argument("-o", "--output", help= "Directory to output data to", default = "")
parser.add_argument("-c", "--cores", help= "Number of cores to use (default 4)", type = int, default = 4)
args = parser.parse_args()
outDir = "output/pattern/" + args.output
if outDir[-1] != '/':
outDir += '/'
if not os.path.exists(outDir):
os.makedirs(outDir)
target = args.target
cores = args.cores
files = [target + i for i in os.listdir(target) ]
files = filter (os.path.isfile, files)
files = [(i, args.output) for i in files]
with multiprocessing.Pool(cores) as pool:
pool.starmap(pattern.execute, files)