|
4 | 4 | The tool used to analyze file created by "ya make ... --build-results-report <file>" |
5 | 5 | """ |
6 | 6 |
|
| 7 | +import argparse |
7 | 8 | import sys |
8 | 9 | import json |
9 | 10 |
|
10 | 11 | if __name__ == "__main__": |
11 | | - report_path = sys.argv[1] |
12 | | - summary_path = sys.argv[2] |
| 12 | + parser = argparse.ArgumentParser() |
| 13 | + parser.add_argument( |
| 14 | + "--report_file", |
| 15 | + help="path to file received via 'ya make ... --build-results-report <file>'", |
| 16 | + type=argparse.FileType("r"), |
| 17 | + required=True |
| 18 | + ) |
| 19 | + parser.add_argument( |
| 20 | + "--summary_file", |
| 21 | + help="output file for summary", |
| 22 | + type=argparse.FileType("w"), |
| 23 | + default="-" |
| 24 | + ) |
| 25 | + args = parser.parse_args() |
13 | 26 |
|
14 | | - with open(report_path) as f: |
15 | | - obj = json.loads(f.read()) |
| 27 | + report_file = args.report_file |
| 28 | + summary_file = args.summary_file |
| 29 | + |
| 30 | + obj = json.load(report_file) |
16 | 31 |
|
17 | 32 | all = [] |
18 | 33 |
|
|
24 | 39 | all.append((rss_consumtion, path)) |
25 | 40 |
|
26 | 41 | all.sort() |
27 | | - with open (summary_path, "w") as f: |
28 | | - f.write("RSS usage by tests, sorted\n\n") |
29 | | - for rss, path in all: |
30 | | - f.write("{} {:.2f} GiB \n".format(path, rss)) |
31 | | - f.write("\n") |
| 42 | + summary_file.write("RSS usage by tests, sorted\n\n") |
| 43 | + for rss, path in all: |
| 44 | + summary_file.write("{} {:.2f} GiB\n".format(path, rss)) |
| 45 | + summary_file.write("\n") |
0 commit comments