diff --git a/kibot/out_base.py b/kibot/out_base.py index a0158911..88ab059b 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -52,6 +52,9 @@ class BaseOutput(RegOutput): Use the boolean true value to disable the output you are extending """ self.output_id = '' """ Text to use for the %I expansion content. To differentiate variations of this output """ + self.category = Optionable + """ [string|list(string)=''] The category for this output. If not specified an internally defined category is used. + Categories looks like file system paths, i.e. PCB/fabrication/gerber """ if GS.global_dir: self.dir = GS.global_dir self._sch_related = False @@ -122,6 +125,9 @@ class BaseOutput(RegOutput): self.options = self.options() # Configure them using an empty tree self.options.config(self) + self.category = self.force_list(self.category) + if not self.category: + self.category = self._category def expand_dirname(self, out_dir): return self.options.expand_filename_both(out_dir, is_sch=self._sch_related) diff --git a/kibot/out_navigate_results.py b/kibot/out_navigate_results.py index bd06e965..d9fefa43 100644 --- a/kibot/out_navigate_results.py +++ b/kibot/out_navigate_results.py @@ -201,7 +201,6 @@ class Navigate_ResultsOptions(BaseOptions): for o in RegOutput.get_outputs(): # Is this one that can be used to represent it? if o.type in outs_rep: - config_output(o) out_dir = get_output_dir(o.dir, o, dry=True) targets = o.get_targets(out_dir) # Look the output targets @@ -330,6 +329,8 @@ class Navigate_ResultsOptions(BaseOptions): acc = 0 f.write('\n\n') for cat, content in node.items(): + if not isinstance(content, dict): + continue if acc >= by_row: # Flush the table and create another acc = 0 @@ -339,59 +340,64 @@ class Navigate_ResultsOptions(BaseOptions): f.write(' \n'.format(pname, self.get_image_for_cat(cat))) acc += 1 f.write('\n
{}
\n') + self.generate_outputs(f, node) self.add_back_home(f, prev) f.write('\n\n') + def generate_outputs(self, f, node): + for oname, out in node.items(): + if isinstance(out, dict): + continue + f.write('\n') + out_name = oname.replace(' ', '_') + oname = oname.replace('_', ' ') + oname = oname[0].upper()+oname[1:] + if out.comment: + oname += ': '+out.comment + f.write('\n'.format(OUT_COLS, oname)) + out_dir = get_output_dir(out.dir, out, dry=True) + f.write('\n') + targets = out.get_targets(out_dir) + if len(targets) == 1: + tg_rel = os.path.relpath(os.path.abspath(targets[0]), start=self.out_dir) + img, _ = self.get_image_for_file(targets[0], out_name) + f.write('\n'. + format(OUT_COLS, tg_rel, img)) + else: + c = 0 + for tg in targets: + if c == OUT_COLS: + f.write('\n\n') + c = 0 + tg_rel = os.path.relpath(os.path.abspath(tg), start=self.out_dir) + img, wide = self.get_image_for_file(tg, out_name) + # Check if we need to break this row + span = 1 + if wide: + span = BIG_2_MID_REL + remain = OUT_COLS-c + if span > remain: + f.write('\n\n'.format(remain)) + # Add a new cell + f.write('\n'.format(span, tg_rel, img)) + c = c+span + if c < OUT_COLS: + f.write('\n'.format(OUT_COLS-c)) + f.write('\n') + # This row is just to ensure we have at least 1 cell in each column + f.write('\n') + for _ in range(OUT_COLS): + f.write('\n') + f.write('\n') + f.write('\n') + f.write('
{}
{}
{}
\n') + def generate_end_page_for(self, name, node, prev, category): logger.debug('- Outputs: '+str(node.keys())) with open(os.path.join(self.out_dir, name), 'wt') as f: self.write_head(f, category) name, ext = os.path.splitext(name) - for oname, out in node.items(): - f.write('\n') - out_name = oname.replace(' ', '_') - oname = oname.replace('_', ' ') - oname = oname[0].upper()+oname[1:] - if out.comment: - oname += ': '+out.comment - f.write('\n'.format(OUT_COLS, oname)) - config_output(out) - out_dir = get_output_dir(out.dir, out, dry=True) - f.write('\n') - targets = out.get_targets(out_dir) - if len(targets) == 1: - tg_rel = os.path.relpath(os.path.abspath(targets[0]), start=self.out_dir) - img, _ = self.get_image_for_file(targets[0], out_name) - f.write('\n'. - format(OUT_COLS, tg_rel, img)) - else: - c = 0 - for tg in targets: - if c == OUT_COLS: - f.write('\n\n') - c = 0 - tg_rel = os.path.relpath(os.path.abspath(tg), start=self.out_dir) - img, wide = self.get_image_for_file(tg, out_name) - # Check if we need to break this row - span = 1 - if wide: - span = BIG_2_MID_REL - remain = OUT_COLS-c - if span > remain: - f.write('\n\n'.format(remain)) - # Add a new cell - f.write('\n'.format(span, tg_rel, img)) - c = c+span - if c < OUT_COLS: - f.write('\n'.format(OUT_COLS-c)) - f.write('\n') - # This row is just to ensure we have at least 1 cell in each column - f.write('\n') - for _ in range(OUT_COLS): - f.write('\n') - f.write('\n') - f.write('\n') - f.write('
{}
{}
{}
\n') + self.generate_outputs(f, node) self.add_back_home(f, prev) f.write('\n\n') @@ -412,7 +418,8 @@ class Navigate_ResultsOptions(BaseOptions): # Create a tree with all the outputs o_tree = {} for o in RegOutput.get_outputs(): - cat = o._category + config_output(o) + cat = o.category if cat is None: continue if isinstance(cat, str):