Outputs help and options review

- Included properties
- The final dot is placed by the printing code (removed from messages)
- docstrings line lengths limited
- Better HPGL help
- Fixed ibom default output (.html.html)
- pdf_pcb_print to use PCB name when not output name
- Default PS scaling factor to 1 (not 2)
This commit is contained in:
Salvador E. Tropea 2020-06-25 09:05:46 -03:00
parent fb5c32f0ad
commit fa1ea5bdc9
13 changed files with 44 additions and 27 deletions

View File

@ -301,11 +301,12 @@ def print_output_options(name, cl):
obj = cl('', name, '') obj = cl('', name, '')
print(' * Options:') print(' * Options:')
num_opts = 0 num_opts = 0
for k, v in obj.__dict__.items(): attrs = BaseOutput.get_attrs_for(obj)
for k, v in attrs.items():
if k[0] != '_': if k[0] != '_':
help_attr = '_help_'+k help_attr = '_help_'+k
help = obj.__dict__.get(help_attr) help = attrs.get(help_attr)
print(' - {}: {}'.format(k, help if help else 'Undocumented')) print(' - {}: {}.'.format(k, help.rstrip() if help else 'Undocumented'))
num_opts = num_opts+1 num_opts = num_opts+1
if num_opts == 0: if num_opts == 0:
print(' - No available options') print(' - No available options')

View File

@ -17,7 +17,8 @@ class AnyDrill(BaseOutput):
self.use_aux_axis_as_origin = False self.use_aux_axis_as_origin = False
""" use the auxiliar axis as origin for coordinates """ """ use the auxiliar axis as origin for coordinates """
self._map = None self._map = None
""" this is an optional subsection to indicate the format for a graphical drill map. The valid formats are hpgl, ps, gerber, dxf, svg and pdf. """ """ this is an optional subsection to indicate the format for a graphical drill map.
The valid formats are hpgl, ps, gerber, dxf, svg and pdf """
self._report = None self._report = None
""" this is an optional subsection to indicate the name of the drill report """ """ this is an optional subsection to indicate the name of the drill report """
# Mappings to KiCad values # Mappings to KiCad values

View File

@ -20,7 +20,7 @@ class BaseOutput(object):
def _perform_config_mapping(self): def _perform_config_mapping(self):
""" Map the options to class attributes """ """ Map the options to class attributes """
attrs = dict(inspect.getmembers(self, filter)) attrs = BaseOutput.get_attrs_for(self)
for k, v in self._options.items(): for k, v in self._options.items():
# Map known attributes and avoid mapping private ones # Map known attributes and avoid mapping private ones
if (k[0] == '_') or (k not in attrs): if (k[0] == '_') or (k not in attrs):
@ -47,6 +47,10 @@ class BaseOutput(object):
if options: if options:
self._perform_config_mapping() self._perform_config_mapping()
@staticmethod
def get_attrs_for(obj):
return dict(inspect.getmembers(obj, filter))
@staticmethod @staticmethod
def register(name, aclass): def register(name, aclass):
BaseOutput._registered[name] = aclass BaseOutput._registered[name] = aclass

View File

@ -13,9 +13,9 @@ class Excellon(AnyDrill):
super(Excellon, self).__init__(name, type, description) super(Excellon, self).__init__(name, type, description)
with document: with document:
self.metric_units = True self.metric_units = True
""" use metric units instead of inches. """ """ use metric units instead of inches """
self.pth_and_npth_single_file = True self.pth_and_npth_single_file = True
""" generate one file for both, plated holes and non-plated holes, instead of two separated files. """ """ generate one file for both, plated holes and non-plated holes, instead of two separated files """
self.minimal_header = False self.minimal_header = False
""" use a minimal header in the file """ """ use a minimal header in the file """
self.mirror_y_axis = False self.mirror_y_axis = False

View File

@ -25,7 +25,8 @@ class Gerber(AnyLayer):
self._gerber_precision = 4.6 self._gerber_precision = 4.6
""" this the gerber coordinate format, can be 4.5 or 4.6 """ """ this the gerber coordinate format, can be 4.5 or 4.6 """
self.create_gerber_job_file = True self.create_gerber_job_file = True
""" creates a file with information about all the generated gerbers. You can use it in gerbview to load all gerbers at once. """ """ creates a file with information about all the generated gerbers.
You can use it in gerbview to load all gerbers at once """
self.use_gerber_x2_attributes = True self.use_gerber_x2_attributes = True
""" use the extended X2 format """ """ use the extended X2 format """
self.use_gerber_net_attributes = True self.use_gerber_net_attributes = True

View File

@ -19,11 +19,11 @@ class HPGL(AnyLayer):
self.sketch_plot = False self.sketch_plot = False
""" don't fill objects, just draw the outline """ """ don't fill objects, just draw the outline """
self.scaling = 0 self.scaling = 0
""" scale factor """ """ scale factor (0 means autoscaling) """
self._drill_marks = 'full' self._drill_marks = 'full'
""" what to use to indicate the drill places, can be none, small or full (for real scale) """ """ what to use to indicate the drill places, can be none, small or full (for real scale) """
self.pen_width = 0.5 self.pen_width = 0.5
""" default trace width """ """ pen diameter in MILS, useful to fill areas. However, it is in mm in HPGL files """
@property @property
def drill_marks(self): def drill_marks(self):
return self._drill_marks return self._drill_marks

View File

@ -21,8 +21,8 @@ class IBoM(BaseOutput):
with document: with document:
self.blacklist = '' self.blacklist = ''
""" regular expression for the components to exclude (using the Config field) """ """ regular expression for the components to exclude (using the Config field) """
self.name_format = 'ibom.html' self.name_format = 'ibom'
""" format of the output name, example: %f_%r_iBoM will generate a file with revision and _iBoM. """ """ format of the output name, example: %f_%r_iBoM will generate a file with revision and _iBoM """
def run(self, output_dir, board): def run(self, output_dir, board):
check_script(CMD_IBOM, URL_IBOM) check_script(CMD_IBOM, URL_IBOM)

View File

@ -22,7 +22,7 @@ class KiBoM(BaseOutput):
# Options # Options
with document: with document:
self._format = 'HTML' self._format = 'HTML'
""" can be HTML or CSV. """ """ can be `HTML` or `CSV` """
@property @property
def format(self): def format(self):

View File

@ -1,3 +1,4 @@
import os
from subprocess import (call) from subprocess import (call)
from .out_base import BaseOutput from .out_base import BaseOutput
from .pre_base import BasePreFlight from .pre_base import BasePreFlight
@ -19,8 +20,8 @@ class PDFPcbPrint(BaseOutput):
super(PDFPcbPrint, self).__init__(name, type, description) super(PDFPcbPrint, self).__init__(name, type, description)
# Options # Options
with document: with document:
self.output_name = 'pdf_pcb_print.pdf' self.output_name = ''
""" filename for the output PDF """ """ filename for the output PDF (the name of the PCB if empty) """
def config(self, outdir, options, layers): def config(self, outdir, options, layers):
super().config(outdir, options, layers) super().config(outdir, options, layers)
@ -37,7 +38,12 @@ class PDFPcbPrint(BaseOutput):
if l.is_inner: if l.is_inner:
if l.id < 1 or l.id >= layer_cnt - 1: if l.id < 1 or l.id >= layer_cnt - 1:
raise PlotError("Inner layer `{}` is not valid for this board".format(l)) raise PlotError("Inner layer `{}` is not valid for this board".format(l))
cmd = [CMD_PCBNEW_PRINT_LAYERS, 'export', '--output_name', self.output_name] # Output file name
output = self.output_name
if not output:
output = os.path.splitext(os.path.basename(GS.pcb_file))[0]+'.pdf'
output = os.path.abspath(os.path.join(output_dir, output))
cmd = [CMD_PCBNEW_PRINT_LAYERS, 'export', '--output_name', output]
if BasePreFlight.get_option('check_zone_fills'): if BasePreFlight.get_option('check_zone_fills'):
cmd.append('-f') cmd.append('-f')
cmd.extend([GS.pcb_file, output_dir]) cmd.extend([GS.pcb_file, output_dir])

View File

@ -20,7 +20,7 @@ class PDFSchPrint(BaseOutput):
# Options # Options
with document: with document:
self.output = '' self.output = ''
""" filename for the output PDF """ """ filename for the output PDF (the name of the schematic if empty) """
def run(self, output_dir, board): def run(self, output_dir, board):
check_eeschema_do() check_eeschema_do()

View File

@ -16,13 +16,13 @@ class Position(BaseOutput):
# Options # Options
with document: with document:
self._format = 'ASCII' self._format = 'ASCII'
""" can be ASCII or CSV. """ """ can be ASCII or CSV """
self.separate_files_for_front_and_back = True self.separate_files_for_front_and_back = True
""" generate two separated files, one for the top and another for the bottom. """ """ generate two separated files, one for the top and another for the bottom """
self.only_smd = True self.only_smd = True
""" only include the surface mount components. """ """ only include the surface mount components """
self._units = 'millimeters' self._units = 'millimeters'
""" can be millimeters or inches. """ """ can be millimeters or inches """
@property @property
def format(self): def format(self):

View File

@ -22,8 +22,8 @@ class PS(AnyLayer):
""" invert black and white """ """ invert black and white """
self.sketch_plot = False self.sketch_plot = False
""" don't fill objects, just draw the outline """ """ don't fill objects, just draw the outline """
self.scaling = 2 self.scaling = 1
""" scale factor """ """ scale factor (0 means autoscaling)"""
self._drill_marks = 'full' self._drill_marks = 'full'
""" what to use to indicate the drill places, can be none, small or full (for real scale) """ """ what to use to indicate the drill places, can be none, small or full (for real scale) """
self.scale_adjust_x = 1.0 self.scale_adjust_x = 1.0
@ -31,6 +31,8 @@ class PS(AnyLayer):
self.scale_adjust_y = 1.0 self.scale_adjust_y = 1.0
""" fine grain adjust for the Y scale (floating point multiplier) """ """ fine grain adjust for the Y scale (floating point multiplier) """
self.width_adjust = 0 self.width_adjust = 0
""" this width factor is intended to compensate PS printers/plotters that do not strictly obey line width settings.
Only used to plot pads and tracks """
self.a4_output = True self.a4_output = True
""" force A4 paper size """ """ force A4 paper size """

View File

@ -23,13 +23,15 @@ class STEP(BaseOutput):
self.metric_units = True self.metric_units = True
""" use metric units instead of inches. """ """ use metric units instead of inches. """
self._origin = 'grid' self._origin = 'grid'
""" determines the coordinates origin. Using grid the coordinates are the same as you have in the design sheet. The drill option uses the auxiliar reference defined by the user. You can define any other origin using the format 'X,Y', i.e. '3.2,-10'. """ """ determines the coordinates origin. Using grid the coordinates are the same as you have in the design sheet.
The drill option uses the auxiliar reference defined by the user.
You can define any other origin using the format 'X,Y', i.e. '3.2,-10' """
self.no_virtual = False self.no_virtual = False
""" used to exclude 3D models for components with 'virtual' attribute. """ """ used to exclude 3D models for components with 'virtual' attribute """
self.min_distance = -1 self.min_distance = -1
""" the minimum distance between points to treat them as separate ones. (-1 id KiCad default: 0.01 mm) """ """ the minimum distance between points to treat them as separate ones (-1 is KiCad default: 0.01 mm) """
self.output = '' self.output = ''
""" name for the generated STEP file. """ """ name for the generated STEP file (the name of the PCB if empty) """
@property @property
def origin(self): def origin(self):