From fa1ea5bdc9dac7b18a16e36eec2935a3a5afff94 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 25 Jun 2020 09:05:46 -0300 Subject: [PATCH] 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) --- kiplot/config_reader.py | 7 ++++--- kiplot/out_any_drill.py | 3 ++- kiplot/out_base.py | 6 +++++- kiplot/out_excellon.py | 4 ++-- kiplot/out_gerber.py | 3 ++- kiplot/out_hpgl.py | 4 ++-- kiplot/out_ibom.py | 4 ++-- kiplot/out_kibom.py | 2 +- kiplot/out_pdf_pcb_print.py | 12 +++++++++--- kiplot/out_pdf_sch_print.py | 2 +- kiplot/out_position.py | 8 ++++---- kiplot/out_ps.py | 6 ++++-- kiplot/out_step.py | 10 ++++++---- 13 files changed, 44 insertions(+), 27 deletions(-) diff --git a/kiplot/config_reader.py b/kiplot/config_reader.py index 1581cde2..05d22bbb 100644 --- a/kiplot/config_reader.py +++ b/kiplot/config_reader.py @@ -301,11 +301,12 @@ def print_output_options(name, cl): obj = cl('', name, '') print(' * Options:') 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] != '_': help_attr = '_help_'+k - help = obj.__dict__.get(help_attr) - print(' - {}: {}'.format(k, help if help else 'Undocumented')) + help = attrs.get(help_attr) + print(' - {}: {}.'.format(k, help.rstrip() if help else 'Undocumented')) num_opts = num_opts+1 if num_opts == 0: print(' - No available options') diff --git a/kiplot/out_any_drill.py b/kiplot/out_any_drill.py index 5eae02dc..494a55ec 100644 --- a/kiplot/out_any_drill.py +++ b/kiplot/out_any_drill.py @@ -17,7 +17,8 @@ class AnyDrill(BaseOutput): self.use_aux_axis_as_origin = False """ use the auxiliar axis as origin for coordinates """ 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 """ this is an optional subsection to indicate the name of the drill report """ # Mappings to KiCad values diff --git a/kiplot/out_base.py b/kiplot/out_base.py index 57792aae..239f6543 100644 --- a/kiplot/out_base.py +++ b/kiplot/out_base.py @@ -20,7 +20,7 @@ class BaseOutput(object): def _perform_config_mapping(self): """ 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(): # Map known attributes and avoid mapping private ones if (k[0] == '_') or (k not in attrs): @@ -47,6 +47,10 @@ class BaseOutput(object): if options: self._perform_config_mapping() + @staticmethod + def get_attrs_for(obj): + return dict(inspect.getmembers(obj, filter)) + @staticmethod def register(name, aclass): BaseOutput._registered[name] = aclass diff --git a/kiplot/out_excellon.py b/kiplot/out_excellon.py index af86c7e5..d3af23a6 100644 --- a/kiplot/out_excellon.py +++ b/kiplot/out_excellon.py @@ -13,9 +13,9 @@ class Excellon(AnyDrill): super(Excellon, self).__init__(name, type, description) with document: self.metric_units = True - """ use metric units instead of inches. """ + """ use metric units instead of inches """ 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 """ use a minimal header in the file """ self.mirror_y_axis = False diff --git a/kiplot/out_gerber.py b/kiplot/out_gerber.py index 316fd2e9..667c00cd 100644 --- a/kiplot/out_gerber.py +++ b/kiplot/out_gerber.py @@ -25,7 +25,8 @@ class Gerber(AnyLayer): self._gerber_precision = 4.6 """ this the gerber coordinate format, can be 4.5 or 4.6 """ 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 """ use the extended X2 format """ self.use_gerber_net_attributes = True diff --git a/kiplot/out_hpgl.py b/kiplot/out_hpgl.py index f4a05fb2..79298080 100644 --- a/kiplot/out_hpgl.py +++ b/kiplot/out_hpgl.py @@ -19,11 +19,11 @@ class HPGL(AnyLayer): self.sketch_plot = False """ don't fill objects, just draw the outline """ self.scaling = 0 - """ scale factor """ + """ scale factor (0 means autoscaling) """ self._drill_marks = 'full' """ what to use to indicate the drill places, can be none, small or full (for real scale) """ 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 def drill_marks(self): return self._drill_marks diff --git a/kiplot/out_ibom.py b/kiplot/out_ibom.py index 3a422e04..4c857fd0 100644 --- a/kiplot/out_ibom.py +++ b/kiplot/out_ibom.py @@ -21,8 +21,8 @@ class IBoM(BaseOutput): with document: self.blacklist = '' """ regular expression for the components to exclude (using the Config field) """ - self.name_format = 'ibom.html' - """ format of the output name, example: %f_%r_iBoM will generate a file with revision and _iBoM. """ + self.name_format = 'ibom' + """ format of the output name, example: %f_%r_iBoM will generate a file with revision and _iBoM """ def run(self, output_dir, board): check_script(CMD_IBOM, URL_IBOM) diff --git a/kiplot/out_kibom.py b/kiplot/out_kibom.py index 3f40e77e..d9e055cc 100644 --- a/kiplot/out_kibom.py +++ b/kiplot/out_kibom.py @@ -22,7 +22,7 @@ class KiBoM(BaseOutput): # Options with document: self._format = 'HTML' - """ can be HTML or CSV. """ + """ can be `HTML` or `CSV` """ @property def format(self): diff --git a/kiplot/out_pdf_pcb_print.py b/kiplot/out_pdf_pcb_print.py index daf6e77f..239b85ab 100644 --- a/kiplot/out_pdf_pcb_print.py +++ b/kiplot/out_pdf_pcb_print.py @@ -1,3 +1,4 @@ +import os from subprocess import (call) from .out_base import BaseOutput from .pre_base import BasePreFlight @@ -19,8 +20,8 @@ class PDFPcbPrint(BaseOutput): super(PDFPcbPrint, self).__init__(name, type, description) # Options with document: - self.output_name = 'pdf_pcb_print.pdf' - """ filename for the output PDF """ + self.output_name = '' + """ filename for the output PDF (the name of the PCB if empty) """ def config(self, outdir, options, layers): super().config(outdir, options, layers) @@ -37,7 +38,12 @@ class PDFPcbPrint(BaseOutput): if l.is_inner: if l.id < 1 or l.id >= layer_cnt - 1: 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'): cmd.append('-f') cmd.extend([GS.pcb_file, output_dir]) diff --git a/kiplot/out_pdf_sch_print.py b/kiplot/out_pdf_sch_print.py index 1789eafb..64e4d82d 100644 --- a/kiplot/out_pdf_sch_print.py +++ b/kiplot/out_pdf_sch_print.py @@ -20,7 +20,7 @@ class PDFSchPrint(BaseOutput): # Options with document: 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): check_eeschema_do() diff --git a/kiplot/out_position.py b/kiplot/out_position.py index 1c107c2b..ef92de58 100644 --- a/kiplot/out_position.py +++ b/kiplot/out_position.py @@ -16,13 +16,13 @@ class Position(BaseOutput): # Options with document: self._format = 'ASCII' - """ can be ASCII or CSV. """ + """ can be ASCII or CSV """ 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 - """ only include the surface mount components. """ + """ only include the surface mount components """ self._units = 'millimeters' - """ can be millimeters or inches. """ + """ can be millimeters or inches """ @property def format(self): diff --git a/kiplot/out_ps.py b/kiplot/out_ps.py index da37b0de..ef96938f 100644 --- a/kiplot/out_ps.py +++ b/kiplot/out_ps.py @@ -22,8 +22,8 @@ class PS(AnyLayer): """ invert black and white """ self.sketch_plot = False """ don't fill objects, just draw the outline """ - self.scaling = 2 - """ scale factor """ + self.scaling = 1 + """ scale factor (0 means autoscaling)""" self._drill_marks = 'full' """ what to use to indicate the drill places, can be none, small or full (for real scale) """ self.scale_adjust_x = 1.0 @@ -31,6 +31,8 @@ class PS(AnyLayer): self.scale_adjust_y = 1.0 """ fine grain adjust for the Y scale (floating point multiplier) """ 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 """ force A4 paper size """ diff --git a/kiplot/out_step.py b/kiplot/out_step.py index 0719e97d..d422f9b1 100644 --- a/kiplot/out_step.py +++ b/kiplot/out_step.py @@ -23,13 +23,15 @@ class STEP(BaseOutput): self.metric_units = True """ use metric units instead of inches. """ 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 - """ used to exclude 3D models for components with 'virtual' attribute. """ + """ used to exclude 3D models for components with 'virtual' attribute """ 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 = '' - """ name for the generated STEP file. """ + """ name for the generated STEP file (the name of the PCB if empty) """ @property def origin(self):