scripts: Changed -o/-O to an exclusive operation

So:

  $ ./scripts/code.py lfs.o -o- -q

Becomes:

  $ ./scripts/code.py lfs.o -o-

The original intention of -o/-O _not_ being exclusive (aka table is
still rendered unless disabled with -q/--quiet), was to allow results to
be written to csv files and rendered to tables in a single pass.

But this was never useful. Heck, we're not even using this in our
Makefile right now because it would make the rule dependencies more
complicated than it's worth. Even for long-running result scripts
(perf.py, perfbd.py, etc), most of the work is building that csv file,
the cost of rendering a table in a second pass is negligible.

In every case I've used -o/-O, I've also wanted -q/--quiet, and almost
always forget this on the first run. So might as well make the expected
behavior the actual behavior.

---

As a plus, this let us simplify some of the scripts a bit, by replacing
visibility filters with -o/-O dependent by-fields.
This commit is contained in:
Christopher Haster
2025-03-01 03:21:06 -06:00
parent e71aca65d9
commit 299e2604c6
9 changed files with 202 additions and 232 deletions

View File

@@ -1027,18 +1027,6 @@ def main(obj_paths, *,
by=by,
defines=defines)
# write results to CSV/JSON
if args.get('output'):
write_csv(args['output'], CodeResult, results,
by=by,
fields=fields,
**args)
if args.get('output_json'):
write_csv(args['output_json'], CodeResult, results, json=True,
by=by,
fields=fields,
**args)
# find previous results?
diff_results = None
if args.get('diff') or args.get('percent'):
@@ -1055,8 +1043,20 @@ def main(obj_paths, *,
by=by,
defines=defines)
# write results to JSON
if args.get('output_json'):
write_csv(args['output_json'], CodeResult, results, json=True,
by=by,
fields=fields,
**args)
# write results to CSV
elif args.get('output'):
write_csv(args['output'], CodeResult, results,
by=by,
fields=fields,
**args)
# print table
if not args.get('quiet'):
else:
table(CodeResult, results, diff_results,
by=by,
fields=fields,
@@ -1078,10 +1078,6 @@ if __name__ == "__main__":
'-v', '--verbose',
action='store_true',
help="Output commands that run behind the scenes.")
parser.add_argument(
'-q', '--quiet',
action='store_true',
help="Don't show anything, useful with -o.")
parser.add_argument(
'-o', '--output',
help="Specify CSV file to store results.")