Niv Sardi commited on
Commit
dd9165a
1 Parent(s): da78e91

vendor: add arguments

Browse files
Files changed (1) hide show
  1. python/vendor.py +14 -3
python/vendor.py CHANGED
@@ -18,10 +18,10 @@ def query_vendor_site(e: Entity):
18
  sfn = screenshot.sc_entity(e)
19
  return (fn, lfn, sfn)
20
 
21
- def from_csv(fn: str):
22
  with open(fn, newline='') as csvfile:
23
  reader = csv.DictReader(csvfile)
24
- with concurrent.futures.ThreadPoolExecutor(max_workers = PARALLEL) as executor:
25
  futures = {executor.submit(query_vendor_site, e): e for e in [Entity.from_dict(d) for d in reader]}
26
  bar = ChargingBar('Processing', max=len(futures))
27
  for f in concurrent.futures.as_completed(futures):
@@ -40,4 +40,15 @@ def from_csv(fn: str):
40
  #exit()
41
 
42
  if __name__ == '__main__':
43
- from_csv(defaults.MAIN_CSV_PATH)
 
 
 
 
 
 
 
 
 
 
 
 
18
  sfn = screenshot.sc_entity(e)
19
  return (fn, lfn, sfn)
20
 
21
+ def from_csv(fn: str, n_workers = PARALLEL):
22
  with open(fn, newline='') as csvfile:
23
  reader = csv.DictReader(csvfile)
24
+ with concurrent.futures.ThreadPoolExecutor(max_workers = n_workers) as executor:
25
  futures = {executor.submit(query_vendor_site, e): e for e in [Entity.from_dict(d) for d in reader]}
26
  bar = ChargingBar('Processing', max=len(futures))
27
  for f in concurrent.futures.as_completed(futures):
 
40
  #exit()
41
 
42
  if __name__ == '__main__':
43
+ import argparse
44
+
45
+ parser = argparse.ArgumentParser(description='extract certificates and screenshots websites')
46
+ parser.add_argument('--csv', metavar='csv', type=str,
47
+ default=defaults.MAIN_CSV_PATH,
48
+ help='main database')
49
+ parser.add_argument('--parallel', metavar='parallel', type=int,
50
+ default=PARALLEL,
51
+ help='number of concurrent jobs')
52
+
53
+ args = parser.parse_args()
54
+ from_csv(args.csv)