New internal category "any related"

- Navigate results and KiCanvas needs a PCB and/or schematic
- Are related to both, but one is enough
This commit is contained in:
Salvador E. Tropea 2024-01-30 09:42:46 -03:00
parent abf07ac95d
commit a1c0dd6c2b
5 changed files with 25 additions and 19 deletions

View File

@ -990,7 +990,8 @@ def generate_one_example(dest_dir, types):
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) and
not (o.is_any() and (GS.pcb_file or 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()))
continue

View File

@ -91,9 +91,10 @@ class BaseOutput(RegOutput):
needed """
if GS.global_dir:
self.dir = GS.global_dir
self._sch_related = False
self._both_related = False
self._none_related = False
self._sch_related = False # True if we need an schematic
self._both_related = False # True if we need an schematic AND a PCB
self._none_related = False # True if not related to the schematic AND the PCB
self._any_related = False # True if we need an schematic OR a PCB
self._unknown_is_error = True
self._done = False
self._category = None
@ -103,12 +104,16 @@ class BaseOutput(RegOutput):
return '--'+attr.replace('_', '-')
def is_sch(self):
""" True for outputs that works on the schematic """
""" True for outputs that needs the schematic """
return self._sch_related or self._both_related
def is_pcb(self):
""" True for outputs that works on the PCB """
return (not self._sch_related and not self._none_related) or self._both_related
""" True for outputs that needs the PCB """
return (not self._sch_related and not self._none_related and not self._any_related) or self._both_related
def is_any(self):
""" True for outputs that needs the schematic and/or the PCB """
return self._any_related
def get_targets(self, out_dir):
""" Returns a list of targets generated by this output """

View File

@ -168,7 +168,7 @@ class KiCanvas(BaseOutput): # noqa: F821
def __init__(self):
super().__init__()
self._category = ['PCB/docs', 'Schematic/docs']
self._none_related = True
self._any_related = True
with document:
self.output = GS.def_global_output
""" *Filename for the output (%i=kicanvas, %x=html) """

View File

@ -529,7 +529,7 @@ class Navigate_Results(BaseOutput): # noqa: F821
""" *[dict] Options for the `navigate_results` output """
# The help is inherited and already mentions the default priority
self.fix_priority_help()
self._none_related = True
self._any_related = True
@staticmethod
def get_conf_examples(name, layers):

View File

@ -1380,25 +1380,25 @@ def test_quick_start_1(test_dir):
ctx.run_command(['git', 'commit', '-m', 'Reference'], chdir_out=dest_dir)
# Modify the PCB
shutil.copy2(ctx.board_file.replace(prj, prj+'_diff'), dest_file)
# Run the Quick Start
# 1) Run the Quick Start
ctx.run(extra=['--quick-start', '--dry', '--start', dest_dir], no_board_file=True, no_yaml_file=True)
dest_conf = os.path.join(dir_o, generated)
ctx.expect_out_file(dest_conf)
# 2) Generate one output that we can use as image for a category
logging.debug('Creating `basic_pcb_print_pdf`')
dest_conf_f = os.path.join(dest_dir, 'kibot_generated.kibot.yaml')
ctx.run(extra=['-c', dest_conf_f, '-b', dest_file, 'basic_pcb_print_pdf'], no_yaml_file=True, no_board_file=True)
ctx.expect_out_file(os.path.join('PCB', 'PDF', prj+'-assembly.pdf'))
# 3) List the generated outputs
logging.debug('Creating the web pages')
ctx.expect_out_file(dest_conf)
# 2) List the generated outputs
ctx.run(extra=['-c', dest_conf_f, '-b', dest_file, '-l'], no_out_dir=True, no_yaml_file=True, no_board_file=True)
OUTS = ('boardview', 'dxf', 'excellon', 'gencad', 'gerb_drill', 'gerber', 'compress', 'hpgl', 'ibom',
'navigate_results', 'netlist', 'pcb_print', 'pcbdraw', 'pdf', 'position', 'ps', 'render_3d',
'report', 'step', 'svg', 'kiri',
'report', 'step', 'svg', 'kiri', # 'kicanvas',
'bom', 'download_datasheets', 'pdf_sch_print', 'svg_sch_print')
for o in OUTS:
ctx.search_out(r'\['+o+r'\]')
# 3) Generate the navigate_results stuff
# 3) Generate one output that we can use as image for a category
logging.debug('Creating `basic_pcb_print_pdf`')
ctx.run(extra=['-c', dest_conf_f, '-b', dest_file, 'basic_pcb_print_pdf'], no_yaml_file=True, no_board_file=True)
ctx.expect_out_file(os.path.join('PCB', 'PDF', prj+'-assembly.pdf'))
# 4) Generate the navigate_results stuff
logging.debug('Creating the web pages')
ctx.run(extra=['-c', dest_conf_f, '-b', dest_file, 'basic_navigate_results'], no_yaml_file=True, no_board_file=True)
ctx.expect_out_file('index.html')
ctx.expect_out_file(os.path.join('Browse', 'light_control-navigate.html'))