Skip to content

Commit c554497

Browse files
authored
Merge pull request #523 from vpodzime/master-filter_only_exotics
Add an option to get ONLY exotic labels with get_labels_expr.py
2 parents 5de0016 + 31e8417 commit c554497

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

build-scripts/get_labels_expr.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def get_args():
1818
ap.add_argument("-e", "--run-on-exotics", nargs="?", default=False, const=True,
1919
help="Run on exotic labels if RUN_ON_EXOTICS is not specified " +
2020
"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")
2123
ap.add_argument("labels_file")
2224
ap.add_argument("exotics_file")
2325

@@ -31,14 +33,21 @@ def non_empty_lines(file_obj):
3133
if content:
3234
yield content
3335

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:
3738
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):
3848
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):
4251
labels_to_run.discard(label.strip())
4352

4453
print("(", end="")
@@ -50,5 +59,6 @@ def main(labels_f_path, exotics_f_path, run_on_exotics):
5059
if __name__ == "__main__":
5160
args = get_args()
5261
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"))
5464
sys.exit(ret)

0 commit comments

Comments
 (0)