@@ -18,6 +18,8 @@ def get_args():
18
18
ap .add_argument ("-e" , "--run-on-exotics" , nargs = "?" , default = False , const = True ,
19
19
help = "Run on exotic labels if RUN_ON_EXOTICS is not specified " +
20
20
"or it is not one of '0', 'no'." )
21
+ ap .add_argument ("-E" , "--only-exotics" , nargs = "?" , default = False , const = True ,
22
+ help = "Run ONLY on the exotic labels" )
21
23
ap .add_argument ("labels_file" )
22
24
ap .add_argument ("exotics_file" )
23
25
@@ -31,14 +33,21 @@ def non_empty_lines(file_obj):
31
33
if content :
32
34
yield content
33
35
34
- def main (labels_f_path , exotics_f_path , run_on_exotics ):
35
- labels_to_run = set ()
36
- with open (labels_f_path , "r" ) as f :
36
+ def get_labels_from_file (f_path ):
37
+ with open (f_path , "r" ) as f :
37
38
for label in non_empty_lines (f ):
39
+ yield label
40
+
41
+ def main (labels_f_path , exotics_f_path , run_on_exotics , only_exotics ):
42
+ labels_to_run = set ()
43
+ if only_exotics :
44
+ for label in get_labels_from_file (exotics_f_path ):
45
+ labels_to_run .add (label .strip ())
46
+ else :
47
+ for label in get_labels_from_file (labels_f_path ):
38
48
labels_to_run .add (label .strip ())
39
- if not run_on_exotics :
40
- with open (exotics_f_path , "r" ) as f :
41
- for label in non_empty_lines (f ):
49
+ if not run_on_exotics :
50
+ for label in get_labels_from_file (exotics_f_path ):
42
51
labels_to_run .discard (label .strip ())
43
52
44
53
print ("(" , end = "" )
@@ -50,5 +59,6 @@ def main(labels_f_path, exotics_f_path, run_on_exotics):
50
59
if __name__ == "__main__" :
51
60
args = get_args ()
52
61
ret = main (args .labels_file , args .exotics_file ,
53
- args .run_on_exotics not in (False , '0' , 0 , "no" ))
62
+ args .run_on_exotics not in (False , '0' , 0 , "no" ),
63
+ args .only_exotics not in (False , '0' , 0 , "no" ))
54
64
sys .exit (ret )
0 commit comments