Now the map.type and report.filename are deprecated in favor of map and report.

The old mechanism is supported, but removed from examples.
Added a test case for the new mechanism.
Documented the reason for the complex properties.
Added docstrings to these particular cases (with None as default).
This commit is contained in:
Salvador E. Tropea 2020-06-25 09:37:43 -03:00
parent fa1ea5bdc9
commit acd5592a45
6 changed files with 53 additions and 17 deletions

View File

@ -144,10 +144,8 @@ outputs:
use_aux_axis_as_origin: false
minimal_header: false
mirror_y_axis: false
report:
filename: 'Conjunto-drl.rpt'
map:
type: 'pdf'
report: 'Conjunto-drl.rpt'
map: 'pdf'
- name: gerber_drills
comment: "Gerber drill files"

View File

@ -60,10 +60,8 @@ outputs:
use_aux_axis_as_origin: false
minimal_header: false
mirror_y_axis: false
report:
filename: 'drill_report.rpt'
map:
type: 'pdf'
report: 'drill_report.rpt'
map: 'pdf'
- name: gerber drills
comment: "Gerber drill files"

View File

@ -17,10 +17,10 @@ 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 """
""" [string=None] format for a graphical drill map. The valid formats are hpgl, ps, gerber, dxf, svg and pdf.
Not generated unless a format is specified """
self._report = None
""" this is an optional subsection to indicate the name of the drill report """
""" [string=None] name of the drill report. Not generated unless a name is specified """
# Mappings to KiCad values
self._map_map = {
'hpgl': PLOT_FORMAT_HPGL,
@ -37,6 +37,8 @@ class AnyDrill(BaseOutput):
@map.setter
def map(self, val):
# In the original "version 1" of the format this is a dict with one key named `type`.
# Currently we spect a string, but we support the old mechanism.
if val is None:
raise KiPlotConfigurationError("Empty drill `map` section")
# Setting from a dict
@ -57,6 +59,10 @@ class AnyDrill(BaseOutput):
@report.setter
def report(self, val):
# In the original "version 1" of the format this is a dict with one key named `filename`.
# Currently we spect a string, but we support the old mechanism.
if val is None:
raise KiPlotConfigurationError("Empty drill `report` section")
# Setting from a dict
if isinstance(val, dict):
if 'filename' not in val:

View File

@ -23,8 +23,8 @@ DRILL_DIR = 'Drill'
positions = {'R1': (105, 35, 'top'), 'R2': (110, 35, 'bottom'), 'R3': (110, 45, 'top')}
def test_3Rs_drill():
ctx = context.TestContext('3Rs_drill', '3Rs', 'drill', DRILL_DIR)
def do_3Rs(conf, dir):
ctx = context.TestContext(dir, '3Rs', conf, DRILL_DIR)
ctx.run()
# Check all outputs are there
ctx.expect_out_file(os.path.join(DRILL_DIR, 'report.rpt'))
@ -49,3 +49,11 @@ def test_3Rs_drill():
ctx.expect_gerber_flash_at(npth_gbr_drl, 6, (120, -29))
ctx.expect_gerber_has_apertures(npth_gbr_drl, ['C,2.100000'])
ctx.clean_up()
def test_drill_3Rs():
do_3Rs('drill', 'Drill_3Rs')
def test_drill_legacy_3Rs():
do_3Rs('drill_legacy', 'DrillLegacy_3Rs')

View File

@ -14,10 +14,8 @@ outputs:
use_aux_axis_as_origin: false
minimal_header: false
mirror_y_axis: false
report:
filename: 'report.rpt'
map:
type: 'pdf'
report: 'report.rpt'
map: 'pdf'
- name: gerber_drills
comment: "Gerber drill files"

View File

@ -0,0 +1,28 @@
# Drills and Gerber drills
kiplot:
version: 1
outputs:
- name: excellon_drill
comment: "Excellon drill files"
type: excellon
dir: Drill
options:
metric_units: true
pth_and_npth_single_file: false
use_aux_axis_as_origin: false
minimal_header: false
mirror_y_axis: false
report:
filename: 'report.rpt'
map:
type: 'pdf'
- name: gerber_drills
comment: "Gerber drill files"
type: gerb_drill
dir: Drill
options:
use_aux_axis_as_origin: false