| From c96b6d39563e24c98721a9fcd41d43a0cdad9315 Mon Sep 17 00:00:00 2001 |
| From: Daniel Schmitz <40656107+dschmitz89@users.noreply.github.com> |
| Date: Thu, 17 Aug 2023 20:52:15 +0200 |
| Subject: [PATCH 1/2] MAINT: replace `optparse` by `argparse` |
| |
| --- |
| ninjatracing | 34 +++++++++++++++++----------------- |
| 1 file changed, 17 insertions(+), 17 deletions(-) |
| |
| diff --git a/ninjatracing b/ninjatracing |
| index 60e6016..d220d96 100755 |
| --- a/ninjatracing |
| +++ b/ninjatracing |
| @@ -25,7 +25,7 @@ Usage: |
| |
| import json |
| import os |
| -import optparse |
| +import argparse |
| import re |
| import sys |
| |
| @@ -158,22 +158,22 @@ def log_to_dicts(log, pid, options): |
| |
| def main(argv): |
| usage = __doc__ |
| - parser = optparse.OptionParser(usage) |
| - parser.add_option('-a', '--showall', action='store_true', dest='showall', |
| - default=False, |
| - help='report on last build step for all outputs. Default ' |
| - 'is to report just on the last (possibly incremental) ' |
| - 'build') |
| - parser.add_option('-g', '--granularity', type='int', default=50000, |
| - dest='granularity', |
| - help='minimum length time-trace event to embed in ' |
| - 'microseconds. Default: %default') |
| - parser.add_option('-e', '--embed-time-trace', action='store_true', |
| - default=False, dest='embed_time_trace', |
| - help='embed clang -ftime-trace json file found adjacent ' |
| - 'to a target file') |
| - (options, args) = parser.parse_args() |
| - |
| + parser = argparse.ArgumentParser(usage) |
| + parser.add_argument("logfiles", nargs="*", help=argparse.SUPPRESS) |
| + parser.add_argument('-a', '--showall', action='store_true', |
| + dest='showall', default=False, |
| + help='report on last build step for all outputs. ' |
| + 'Default is to report just on the last ' |
| + '(possibly incremental) build') |
| + parser.add_argument('-g', '--granularity', type=int, default=50000, |
| + dest='granularity', |
| + help='minimum length time-trace event to embed in ' |
| + 'microseconds. Default: 50000') |
| + parser.add_argument('-e', '--embed-time-trace', action='store_true', |
| + default=False, dest='embed_time_trace', |
| + help='embed clang -ftime-trace json file found ' |
| + 'adjacent to a target file') |
| + options = parser.parse_args() |
| if len(args) == 0: |
| print('Must specify at least one .ninja_log file') |
| parser.print_help() |
| |
| From 46fa3fa42e7df59f2d3ae01197afce1e97da8818 Mon Sep 17 00:00:00 2001 |
| From: Daniel Schmitz <40656107+dschmitz89@users.noreply.github.com> |
| Date: Thu, 17 Aug 2023 20:53:37 +0200 |
| Subject: [PATCH 2/2] Fix incomplete update |
| |
| --- |
| ninjatracing | 6 +----- |
| 1 file changed, 1 insertion(+), 5 deletions(-) |
| |
| diff --git a/ninjatracing b/ninjatracing |
| index d220d96..458b050 100755 |
| --- a/ninjatracing |
| +++ b/ninjatracing |
| @@ -174,13 +174,9 @@ def main(argv): |
| help='embed clang -ftime-trace json file found ' |
| 'adjacent to a target file') |
| options = parser.parse_args() |
| - if len(args) == 0: |
| - print('Must specify at least one .ninja_log file') |
| - parser.print_help() |
| - return 1 |
| |
| entries = [] |
| - for pid, log_file in enumerate(args): |
| + for pid, log_file in enumerate(options.logfiles): |
| with open(log_file, 'r') as log: |
| entries += list(log_to_dicts(log, pid, vars(options))) |
| json.dump(entries, sys.stdout) |