From 5504ee228ddb238d0ab90d04d3a9363b2609ad05 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 29 Apr 2022 09:02:52 -0300 Subject: [PATCH] Added --type option to --quick-start to select outputs - Useful to debug a particular output --- kibot/__main__.py | 8 +++++--- kibot/kiplot.py | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/kibot/__main__.py b/kibot/__main__.py index 05044e7e..1e18c6b4 100644 --- a/kibot/__main__.py +++ b/kibot/__main__.py @@ -12,7 +12,8 @@ Usage: [-q | -v...] [-i] [-C] [-m MKFILE] [-g DEF]... [TARGET...] kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] --list kibot [-v...] [-b BOARD] [-d OUT_DIR] [-p | -P] --example - kibot [-v...] [--start PATH] [-d OUT_DIR] [--dry] --quick-start + kibot [-v...] [--start PATH] [-d OUT_DIR] [--dry] [-t, --type TYPE]... + --quick-start kibot [-v...] --help-filters kibot [-v...] --help-global-options kibot [-v...] --help-list-outputs @@ -45,8 +46,9 @@ Options: Quick start options: --quick-start Generates demo config files and their outputs - --start PATH Starting point for the search [default: .] --dry Just generate the config files + --start PATH Starting point for the search [default: .] + --type TYPE Generate examples only for the indicated type/s Help options: -h, --help Show this help message and exit @@ -281,7 +283,7 @@ def main(): sys.exit(0) if args.quick_start: # Some kind of wizard to get usable examples - generate_examples(args.start, args.dry) + generate_examples(args.start, args.dry, args.type) sys.exit(0) # Determine the YAML file diff --git a/kibot/kiplot.py b/kibot/kiplot.py index 7663ed3f..8b05b8c5 100644 --- a/kibot/kiplot.py +++ b/kibot/kiplot.py @@ -758,7 +758,7 @@ def discover_files(dest_dir): return fname -def generate_one_example(dest_dir): +def generate_one_example(dest_dir, types): """ Generate a example config for dest_dir """ fname = discover_files(dest_dir) # Abort if none @@ -808,6 +808,9 @@ def generate_one_example(dest_dir): outputs = [] for n, cls in OrderedDict(sorted(outs.items())).items(): o = cls() + if types and n not in types: + logger.debug('- {}, not selected (PCB: {} SCH: {})'.format(n, o.is_pcb(), o.is_sch())) + continue if ((not(o.is_pcb() and GS.pcb_file) and not(o.is_sch() and GS.sch_file)) or ((o.is_pcb() and o.is_sch()) and (not GS.pcb_file or not GS.sch_file))): logger.debug('- {}, skipped (PCB: {} SCH: {})'.format(n, o.is_pcb(), o.is_sch())) @@ -826,7 +829,10 @@ def generate_one_example(dest_dir): outputs.extend(tree) else: logger.debug('- {}, nothing to do'.format(n)) - f.write(yaml.dump({'outputs': outputs}, sort_keys=False)) + if outputs: + f.write(yaml.dump({'outputs': outputs}, sort_keys=False)) + else: + return None return fname @@ -855,7 +861,7 @@ def _walk(path, depth): yield from _walk(entry.path, depth) -def generate_examples(start_dir, dry): +def generate_examples(start_dir, dry, types): if not start_dir: start_dir = '.' else: @@ -876,7 +882,7 @@ def generate_examples(start_dir, dry): confs = [] for c in sorted(candidates): logger.info('Analyzing `{}` dir'.format(c)) - res = generate_one_example(c) + res = generate_one_example(c, types) if res: confs.append(res) logger.info('')