Now you can ask to compress the targets of an output (by out put name)

This commit is contained in:
Salvador E. Tropea 2021-01-18 16:12:30 -03:00
parent b347a6ca30
commit 88cd5927dc
30 changed files with 298 additions and 83 deletions

View File

@ -661,6 +661,8 @@ Next time you need this list just use an alias, like this:
* Valid keys:
- `dest`: [string=''] Destination directory inside the archive, empty means the same of the file.
- `filter`: [string='.*'] A regular expression that source files must match.
- `from_output`: [string=''] Collect files from the selected output.
When used the `source` option is ignored.
- `source`: [string='*'] File names to add, wildcards allowed. Use ** for recursive match.
Note this pattern is applied to the output dir specified with -d comman line option.
- `format`: [string='ZIP'] [ZIP,TAR,RAR] Output file format.

View File

@ -53,5 +53,8 @@ outputs:
dir: Elecrow
options:
files:
- source: Elecrow/*
- from_output: gerbers
dest: /
- from_output: drill
dest: /

View File

@ -55,5 +55,8 @@ outputs:
dir: Elecrow
options:
files:
- source: Elecrow/*
- from_output: gerbers
dest: /
- from_output: drill
dest: /

View File

@ -53,5 +53,8 @@ outputs:
dir: FusionPCB
options:
files:
- source: FusionPCB/*
- from_output: gerbers
dest: /
- from_output: drill
dest: /

View File

@ -59,5 +59,8 @@ outputs:
dir: JLCPCB
options:
files:
- source: JLCPCB/*
- from_output: gerbers
dest: /
- from_output: drill
dest: /

View File

@ -52,5 +52,8 @@ outputs:
dir: JLCPCB
options:
files:
- source: JLCPCB/*
- from_output: gerbers
dest: /
- from_output: drill
dest: /

View File

@ -66,5 +66,8 @@ outputs:
dir: P-Ban
options:
files:
- source: P-Ban/*
- from_output: gerbers
dest: /
- from_output: drill
dest: /

View File

@ -59,5 +59,8 @@ outputs:
options:
format: ZIP
files:
- source: PCBWay/*
- from_output: gerbers
dest: /
- from_output: drill
dest: /

View File

@ -176,6 +176,9 @@ outputs:
- dest: ''
# [string='.*'] A regular expression that source files must match
filter: '.*'
# [string=''] Collect files from the selected output.
# When used the `source` option is ignored
from_output: ''
# [string='*'] File names to add, wildcards allowed. Use ** for recursive match.
# Note this pattern is applied to the output dir specified with -d comman line option
source: '*'

View File

@ -88,7 +88,7 @@ def list_pre_and_outs(logger, outputs):
if len(outputs):
logger.info('Outputs:')
for o in outputs:
config_output(o)
config_output(o, dry=True)
logger.info('- '+str(o))

View File

@ -57,6 +57,8 @@ class GS(object):
pcb_comp = None
# Current variant/s
variant = None
# All the outputs
outputs = None
# Name for the output we are generating
current_output = None
# Global defaults

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
"""
@ -1601,3 +1601,14 @@ class Schematic(object):
f.write(' (lib (name n)(type Legacy)(uri ${KIPRJMOD}/n.lib)(options "")(descr ""))\n')
f.write(')\n')
return fname
def file_names_variant(self, dest_dir):
""" Returns a list of file names created by save_variant() """
fnames = [os.path.join(dest_dir, 'y.lib'),
os.path.join(dest_dir, 'n.lib'),
os.path.join(dest_dir, os.path.basename(self.fname)),
os.path.join(dest_dir, 'sym-lib-table')]
# Sub-sheets
for sch in self.sheets:
fnames.append(os.path.join(dest_dir, sch.file.replace('/', '_')))
return fnames

View File

@ -241,15 +241,34 @@ def get_output_dir(o_dir):
return outdir
def config_output(out):
def config_output(out, dry=False):
# Should we load the PCB?
if not dry:
if out.is_pcb():
load_board()
if out.is_sch():
load_sch()
try:
out.config()
except KiPlotConfigurationError as e:
config_error("In section '"+out.name+"' ("+out.type+"): "+str(e))
def run_output(out):
GS.current_output = out.name
try:
out.run(get_output_dir(out.dir))
out._done = True
except PlotError as e:
logger.error("In output `"+str(out)+"`: "+str(e))
exit(PLOT_ERROR)
except KiPlotConfigurationError as e:
config_error("In section '"+out.name+"' ("+out.type+"): "+str(e))
def generate_outputs(outputs, target, invert, skip_pre):
logger.debug("Starting outputs for board {}".format(GS.pcb_file))
GS.outputs = outputs
preflight_checks(skip_pre)
# Check if all must be skipped
n = len(target)
@ -260,20 +279,8 @@ def generate_outputs(outputs, target, invert, skip_pre):
# Generate outputs
for out in outputs:
if (n == 0) or ((out.name in target) ^ invert):
# Should we load the PCB?
if out.is_pcb():
load_board()
if out.is_sch():
load_sch()
config_output(out)
logger.info('- '+str(out))
GS.current_output = out.name
try:
out.run(get_output_dir(out.dir))
except PlotError as e:
logger.error("In output `"+str(out)+"`: "+str(e))
exit(PLOT_ERROR)
except KiPlotConfigurationError as e:
config_error("In section '"+out.name+"' ("+out.type+"): "+str(e))
run_output(out)
else:
logger.debug('Skipping `%s` output', str(out))

View File

@ -30,6 +30,7 @@ class Optionable(object):
self._unkown_is_error = False
self._error_context = ''
self._tree = {}
self._configured = False
super().__init__()
if GS.global_output is not None and getattr(self, 'output', None):
setattr(self, 'output', GS.global_output)
@ -165,8 +166,9 @@ class Optionable(object):
self._tree = tree
def config(self):
if self._tree:
if self._tree and not self._configured:
self._perform_config_mapping()
self._configured = True
def get_attrs_for(self):
""" Returns all attributes """

View File

@ -102,13 +102,37 @@ class AnyDrill(BaseOptions):
# PTH
return self.pth_id if self.pth_id is not None else d+'_drill'
def get_file_names(self, output_dir):
""" Returns a dict containing KiCad names and its replacement.
If no replacement is needed the replacement is empty """
filenames = {}
files = [''] if self._unified_output else ['PTH', 'NPTH']
for d in files:
kicad_id = '-'+d if d else d
kibot_id = self.solve_id(d)
if self._ext == 'drl':
k_file = self.expand_filename(output_dir, '%f'+kicad_id+'.%x', '', self._ext)
else: # gbr
k_file = self.expand_filename(output_dir, '%f'+kicad_id+'-drl.%x', '', self._ext)
file = ''
if self.output:
file = self.expand_filename(output_dir, self.output, kibot_id, self._ext)
filenames[k_file] = file
if self.map is not None:
k_file = self.expand_filename(output_dir, '%f'+kicad_id+'-drl_map.%x', '', self.map_ext)
file = ''
if self.map_output:
file = self.expand_filename(output_dir, self.map_output, kibot_id+'_map', self.map_ext)
filenames[k_file] = file
return filenames
def run(self, output_dir):
# dialog_gendrill.cpp:357
if self.use_aux_axis_as_origin:
offset = get_aux_origin(GS.board)
else:
offset = wxPoint(0, 0)
drill_writer, ext = self._configure_writer(GS.board, offset)
drill_writer = self._configure_writer(GS.board, offset)
logger.debug("Generating drill files in "+output_dir)
gen_map = self.map is not None
@ -118,23 +142,21 @@ class AnyDrill(BaseOptions):
# We always generate the drill file
drill_writer.CreateDrillandMapFilesSet(output_dir, True, gen_map)
# Rename the files
files = [''] if self._unified_output else ['PTH', 'NPTH']
for d in files:
kicad_id = '-'+d if d else d
kibot_id = self.solve_id(d)
if self.output:
if ext == 'drl':
k_file = self.expand_filename(output_dir, '%f'+kicad_id+'.%x', '', ext)
else: # gbr
k_file = self.expand_filename(output_dir, '%f'+kicad_id+'-drl.%x', '', ext)
file = self.expand_filename(output_dir, self.output, kibot_id, ext)
os.rename(k_file, file)
if gen_map and self.map_output:
k_file = self.expand_filename(output_dir, '%f'+kicad_id+'-drl_map.%x', '', self.map_ext)
file = self.expand_filename(output_dir, self.map_output, kibot_id+'_map', self.map_ext)
os.rename(k_file, file)
files = self.get_file_names(output_dir)
for k_f, f in files.items():
if f:
os.rename(k_f, f)
# Generate the report
if self.report:
drill_report_file = self.expand_filename(output_dir, self.report, 'drill_report', 'txt')
logger.debug("Generating drill report: "+drill_report_file)
drill_writer.GenDrillReportFile(drill_report_file)
def get_targets(self, parent, out_dir):
targets = []
files = self.get_file_names(out_dir)
for k_f, f in files.items():
targets.append(f if f else k_f)
if self.report:
targets.append(self.expand_filename(out_dir, self.report, 'drill_report', 'txt'))
return targets

View File

@ -7,6 +7,8 @@
# Adapted from: https://github.com/johnbeard/kiplot
import os
import re
from shutil import rmtree
from tempfile import mkdtemp
from pcbnew import GERBER_JOBFILE_WRITER, PLOT_CONTROLLER, IsCopperLayer, F_Cu, B_Cu, Edge_Cuts
from .optionable import Optionable
from .out_base import BaseOutput, VariantOptions
@ -96,6 +98,22 @@ class AnyLayerOptions(VariantOptions):
self.uncross_modules(board, self.comps_hash)
self.restore_paste_and_glue(board, self.comps_hash)
def compute_name(self, k_filename, output_dir, output, id, suffix):
if output:
filename = self.expand_filename(output_dir, output, suffix, os.path.splitext(k_filename)[1][1:])
else:
filename = k_filename
if id > F_Cu and id < B_Cu and self.inner_extension_pattern:
ext = self.inner_extension_pattern
ext = ext.replace('%n', str(id))
ext = ext.replace('%N', str(id+1))
filename = os.path.splitext(filename)[0]+ext
if id == Edge_Cuts and self.edge_cut_extension:
filename = os.path.splitext(filename)[0]+self.edge_cut_extension
if self.uppercase_extensions:
filename = os.path.splitext(filename)[0]+os.path.splitext(filename)[1].upper()
return filename
def run(self, output_dir, layers):
super().run(output_dir)
# fresh plot controller
@ -134,19 +152,7 @@ class AnyLayerOptions(VariantOptions):
raise PlotError("OpenPlotfile failed!") # pragma: no cover
# Compute the current file name and the one we want
k_filename = plot_ctrl.GetPlotFileName()
if self.output:
filename = self.expand_filename(output_dir, self.output, suffix, os.path.splitext(k_filename)[1][1:])
else:
filename = k_filename
if id > F_Cu and id < B_Cu and self.inner_extension_pattern:
ext = self.inner_extension_pattern
ext = ext.replace('%n', str(id))
ext = ext.replace('%N', str(id+1))
filename = os.path.splitext(filename)[0]+ext
if id == Edge_Cuts and self.edge_cut_extension:
filename = os.path.splitext(filename)[0]+self.edge_cut_extension
if self.uppercase_extensions:
filename = os.path.splitext(filename)[0]+os.path.splitext(filename)[1].upper()
filename = self.compute_name(k_filename, output_dir, self.output, id, suffix)
logger.debug("Plotting layer `{}` to `{}`".format(la, filename))
plot_ctrl.PlotLayer()
plot_ctrl.ClosePlot()
@ -181,6 +187,38 @@ class AnyLayerOptions(VariantOptions):
if exclude:
self.unfilter_components(GS.board)
def get_targets(self, output_dir, layers):
# This is tricky because we can use names generated by KiCad
targets = []
# Configure KiCad's plotter
plot_ctrl = PLOT_CONTROLLER(GS.board)
po = plot_ctrl.GetPlotOptions()
self._configure_plot_ctrl(po, output_dir)
# KiCad doesn't assign an extension until we actually call OpenPlotFile
# So we create temporal files just to get their name :-(
tmp_dir = mkdtemp()
po.SetOutputDirectory(tmp_dir)
layers = Layer.solve(layers)
for la in layers:
id = la.id
if not GS.board.IsLayerEnabled(id):
continue
plot_ctrl.SetLayer(id)
plot_ctrl.OpenPlotfile(la.suffix, self._plot_format, '')
# Here we convert the temporal name to the actual name using replace
k_filename = plot_ctrl.GetPlotFileName().replace(tmp_dir, output_dir)
filename = self.compute_name(k_filename, output_dir, self.output, id, la.suffix)
plot_ctrl.ClosePlot()
if GS.debug_level > 2:
logger.debug('Layer id {} file name {} ({})'.format(id, filename, k_filename))
targets.append(filename)
rmtree(tmp_dir)
if po.GetCreateGerberJobFile():
targets.append(self.expand_filename(output_dir, po.gerber_job_file, 'job', 'gbrjob'))
for report in self.custom_reports:
targets.append(os.path.join(output_dir, report.output))
return targets
def read_vals_from_po(self, po):
# excludeedgelayer
self.exclude_edge_layer = po.GetExcludeEdgeLayer()
@ -213,5 +251,8 @@ class AnyLayer(BaseOutput):
if isinstance(self.layers, type):
raise KiPlotConfigurationError("Missing `layers` list")
def get_targets(self, out_dir):
return self.options.get_targets(out_dir, self.layers)
def run(self, output_dir):
self.options.run(output_dir, self.layers)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
from .gs import GS
@ -34,6 +34,7 @@ class BaseOutput(RegOutput):
""" A comment for documentation purposes """ # pragma: no cover
self._sch_related = False
self._unkown_is_error = True
self._done = False
@staticmethod
def attr2longopt(attr):
@ -47,6 +48,13 @@ class BaseOutput(RegOutput):
""" True for outputs that works on the PCB """
return not self._sch_related
def get_targets(self, out_dir):
""" Returns a list of targets generated by this output """
if not (hasattr(self, "options") and hasattr(self.options, "get_targets")):
logger.error("Output {} doesn't implement get_targets(), plese report it".format(self))
return []
return self.options.get_targets(self, out_dir)
def config(self):
super().config()
if getattr(self, 'options', None) and isinstance(self.options, type):

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: MIT
# Project: KiBot (formerly KiPlot)
"""
@ -409,6 +409,9 @@ class BoMOptions(BaseOptions):
except BoMError as e:
raise KiPlotConfigurationError(str(e))
def get_targets(self, parent, out_dir):
return [self.expand_filename_sch(out_dir, self.output, 'bom', self.format.lower())]
@output_class
class BoM(BaseOutput): # noqa: F821

View File

@ -12,7 +12,8 @@ from zipfile import ZipFile, ZIP_STORED, ZIP_DEFLATED, ZIP_BZIP2, ZIP_LZMA
from tarfile import open as tar_open
from collections import OrderedDict
from .gs import GS
from .misc import MISSING_TOOL, WRONG_INSTALL, W_EMPTYZIP
from .kiplot import config_output, get_output_dir, run_output
from .misc import MISSING_TOOL, WRONG_INSTALL, W_EMPTYZIP, WRONG_ARGUMENTS, INTERNAL_ERROR
from .optionable import Optionable, BaseOptions
from .macros import macros, document, output_class # noqa: F401
from . import log
@ -27,6 +28,9 @@ class FilesList(Optionable):
self.source = '*'
""" File names to add, wildcards allowed. Use ** for recursive match.
Note this pattern is applied to the output dir specified with -d comman line option """
self.from_output = ''
""" Collect files from the selected output.
When used the `source` option is ignored """
self.filter = '.*'
""" A regular expression that source files must match """
self.dest = ''
@ -104,7 +108,10 @@ class CompressOptions(BaseOptions):
ext += '.'+sub_ext
return ext
def run(self, output_dir):
def get_targets(self, parent, out_dir):
return [self.expand_filename(out_dir, self.output, parent.name, self.solve_extension())]
def run(self, output_dir, parent):
# Output file name
output = self.expand_filename(output_dir, self.output, GS.current_output, self.solve_extension())
logger.debug('Collecting files')
@ -112,7 +119,31 @@ class CompressOptions(BaseOptions):
# Collect the files
files = OrderedDict()
for f in self.files:
for fname in filter(re.compile(f.filter).match, glob.iglob(os.path.join(GS.out_dir, f.source), recursive=True)):
# Get the list of candidates
files_list = None
if f.from_output:
for out in GS.outputs:
if out.name == f.from_output:
config_output(out)
files_list = out.get_targets(get_output_dir(out.dir))
break
if files_list is None:
logger.error('Unknown output `{}` selected in {}'.format(f.from_output, parent))
exit(WRONG_ARGUMENTS)
for file in files_list:
if not os.path.isfile(file):
# The target doesn't exist
if not out._done:
# The output wasn't created in this run, try running it
run_output(out)
if not os.path.isfile(file):
# Still missing, something is wrong
logger.error('Unable to generate `{}` from {}'.format(file, out))
exit(INTERNAL_ERROR)
else:
files_list = glob.iglob(os.path.join(GS.out_dir, f.source), recursive=True)
# Filter and adapt them
for fname in filter(re.compile(f.filter).match, files_list):
fname_real = os.path.realpath(fname)
# Avoid including the output
if fname_real == output_real:
@ -143,3 +174,6 @@ class Compress(BaseOutput): # noqa: F821
with document:
self.options = CompressOptions
""" [dict] Options for the `compress` output """
def run(self, output_dir):
self.options.run(output_dir, self)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
from pcbnew import EXCELLON_WRITER
@ -31,13 +31,14 @@ class ExcellonOptions(AnyDrill):
""" number of digits for integer part of coordinates (0 is auto) """
self.right_digits = 0
""" number of digits for mantissa part of coordinates (0 is auto) """
self._ext = 'drl'
def _configure_writer(self, board, offset):
drill_writer = EXCELLON_WRITER(board)
drill_writer.SetOptions(self.mirror_y_axis, self.minimal_header, offset, self.pth_and_npth_single_file)
drill_writer.SetFormat(self.metric_units, ZF[self.zeros_format], self.left_digits, self.right_digits)
self._unified_output = self.pth_and_npth_single_file
return drill_writer, 'drl'
return drill_writer
@output_class

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
from pcbnew import GERBER_WRITER
@ -11,13 +11,14 @@ from .macros import macros, document, output_class # noqa: F401
class Gerb_DrillOptions(AnyDrill):
def __init__(self):
super().__init__()
self._ext = 'gbr'
def _configure_writer(self, board, offset):
drill_writer = GERBER_WRITER(board)
# hard coded in UI?
drill_writer.SetFormat(5)
drill_writer.SetOptions(offset)
return drill_writer, 'gbr'
return drill_writer
@output_class

View File

@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
import os
from subprocess import (check_output, STDOUT, CalledProcessError)
from .misc import (CMD_IBOM, URL_IBOM, BOM_ERROR)
@ -89,6 +94,13 @@ class IBoMOptions(VariantOptions):
super().config()
self.netlist_file = self.expand_filename('', self.netlist_file, 'ibom', 'xml')
def get_targets(self, parent, out_dir):
if self.output:
return [self.expand_filename(out_dir, self.output, 'ibom', 'html')]
logger.error('{} uses a name generated by the external tool.'.format(parent))
logger.error('Please use a name generated by KiBot or specify the name explicitly.')
return []
def run(self, output_dir):
super().run(output_dir)
check_script(CMD_IBOM, URL_IBOM)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
import os
@ -355,6 +355,13 @@ class KiBoMOptions(BaseOptions):
self.conf.save(conf)
self.conf = conf
def get_targets(self, parent, out_dir):
if self.output:
return [self.expand_filename_sch(out_dir, self.output, 'bom', self.format.lower())]
logger.error('{} uses a name generated by the external tool.'.format(parent))
logger.error('Please use a name generated by KiBot or specify the name explicitly.')
return []
def run(self, output_dir):
check_script(CMD_KIBOM, URL_KIBOM, '1.8.0')
format = self.format.lower()

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
import os
@ -227,6 +227,9 @@ class PcbDrawOptions(VariantOptions):
cmd.append(svg)
return svg
def get_targets(self, parent, out_dir):
return [self.expand_filename(out_dir, self.output, 'bottom' if self.bottom else 'top', self.format)]
def run(self, output_dir):
super().run(output_dir)
check_script(PCBDRAW, URL_PCBDRAW, '0.6.0')

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
import os
@ -85,6 +85,11 @@ class PDF_Pcb_PrintOptions(VariantOptions):
self.restore_paste_and_glue(board, comps_hash)
return fname, fproj
def get_targets(self, out_dir, layers):
layers = Layer.solve(layers)
id = '+'.join([la.suffix for la in layers])
return [self.expand_filename(out_dir, self.output, id, 'pdf')]
def run(self, output_dir, layers):
super().run(layers)
check_script(CMD_PCBNEW_PRINT_LAYERS, URL_PCBNEW_PRINT_LAYERS, '1.5.2')
@ -146,5 +151,8 @@ class PDF_Pcb_Print(BaseOutput): # noqa: F821
if isinstance(self.layers, type):
raise KiPlotConfigurationError("Missing `layers` list")
def get_targets(self, out_dir):
return self.options.get_targets(out_dir, self.layers)
def run(self, output_dir):
self.options.run(output_dir, self.layers)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
import os
@ -24,6 +24,13 @@ class PDF_Sch_PrintOptions(VariantOptions):
super().__init__()
self.add_to_doc('variant', "Not fitted components are crossed")
def get_targets(self, parent, out_dir):
id = 'schematic'
ext = 'pdf'
if self.output:
return [self.expand_filename_sch(out_dir, self.output, id, ext)]
return [self.expand_filename_sch(out_dir, '%f.%x', id, ext)]
def run(self, output_dir):
super().run(output_dir)
check_eeschema_do()

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2019 Romain Deterre (@rdeterre)
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
@ -200,6 +200,13 @@ class PositionOptions(VariantOptions):
return PositionOptions.is_pure_smd_5, PositionOptions.is_not_virtual_5
return PositionOptions.is_pure_smd_6, PositionOptions.is_not_virtual_6
def get_targets(self, parent, out_dir):
ext = 'pos' if self.format == 'ASCII' else 'csv'
if self.separate_files_for_front_and_back:
return [self.expand_filename(out_dir, self.output, 'top_pos', ext),
self.expand_filename(out_dir, self.output, 'bottom_pos', ext)]
return [self.expand_filename(out_dir, self.output, 'both_pos', ext)]
def run(self, output_dir):
super().run(output_dir)
columns = self.columns.values()

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
from .gs import GS
@ -12,6 +12,9 @@ class Sch_Variant_Options(VariantOptions):
def __init__(self):
super().__init__()
def get_targets(self, parent, out_dir):
return GS.sch.file_names_variant(out_dir)
def run(self, output_dir):
super().run(output_dir)
# Create the schematic

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
import re
@ -185,6 +185,9 @@ class STEPOptions(VariantOptions):
models.push_front(model)
return fname
def get_targets(self, parent, out_dir):
return [self.expand_filename_sch(out_dir, self.output, '3D', 'step')]
def run(self, output_dir):
super().run(output_dir)
# Output file name

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020 @nerdyscout
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
@ -25,6 +25,13 @@ class SVG_Sch_PrintOptions(VariantOptions):
super().__init__()
self.add_to_doc('variant', "Not fitted components are crossed")
def get_targets(self, parent, out_dir):
id = 'schematic'
ext = 'svg'
if self.output:
return [self.expand_filename_sch(out_dir, self.output, id, ext)]
return [self.expand_filename_sch(out_dir, '%f.%x', id, ext)]
def run(self, output_dir):
super().run(output_dir)
check_eeschema_do()