Added --type option to --quick-start to select outputs

- Useful to debug a particular output
This commit is contained in:
Salvador E. Tropea 2022-04-29 09:02:52 -03:00
parent 74d77f037c
commit 5504ee228d
2 changed files with 15 additions and 7 deletions

View File

@ -12,7 +12,8 @@ Usage:
[-q | -v...] [-i] [-C] [-m MKFILE] [-g DEF]... [TARGET...] [-q | -v...] [-i] [-C] [-m MKFILE] [-g DEF]... [TARGET...]
kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] --list kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] --list
kibot [-v...] [-b BOARD] [-d OUT_DIR] [-p | -P] --example 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-filters
kibot [-v...] --help-global-options kibot [-v...] --help-global-options
kibot [-v...] --help-list-outputs kibot [-v...] --help-list-outputs
@ -45,8 +46,9 @@ Options:
Quick start options: Quick start options:
--quick-start Generates demo config files and their outputs --quick-start Generates demo config files and their outputs
--start PATH Starting point for the search [default: .]
--dry Just generate the config files --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: Help options:
-h, --help Show this help message and exit -h, --help Show this help message and exit
@ -281,7 +283,7 @@ def main():
sys.exit(0) sys.exit(0)
if args.quick_start: if args.quick_start:
# Some kind of wizard to get usable examples # 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) sys.exit(0)
# Determine the YAML file # Determine the YAML file

View File

@ -758,7 +758,7 @@ def discover_files(dest_dir):
return fname return fname
def generate_one_example(dest_dir): def generate_one_example(dest_dir, types):
""" Generate a example config for dest_dir """ """ Generate a example config for dest_dir """
fname = discover_files(dest_dir) fname = discover_files(dest_dir)
# Abort if none # Abort if none
@ -808,6 +808,9 @@ def generate_one_example(dest_dir):
outputs = [] outputs = []
for n, cls in OrderedDict(sorted(outs.items())).items(): for n, cls in OrderedDict(sorted(outs.items())).items():
o = cls() 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 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))): ((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())) 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) outputs.extend(tree)
else: else:
logger.debug('- {}, nothing to do'.format(n)) 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 return fname
@ -855,7 +861,7 @@ def _walk(path, depth):
yield from _walk(entry.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: if not start_dir:
start_dir = '.' start_dir = '.'
else: else:
@ -876,7 +882,7 @@ def generate_examples(start_dir, dry):
confs = [] confs = []
for c in sorted(candidates): for c in sorted(candidates):
logger.info('Analyzing `{}` dir'.format(c)) logger.info('Analyzing `{}` dir'.format(c))
res = generate_one_example(c) res = generate_one_example(c, types)
if res: if res:
confs.append(res) confs.append(res)
logger.info('') logger.info('')