From acd5592a4551ee9dedd34423e20c3c79ed9115d6 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 25 Jun 2020 09:37:43 -0300 Subject: [PATCH] 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). --- docs/samples/example_1.kiplot.yaml | 6 ++--- docs/samples/generic_plot.kiplot.yaml | 6 ++--- kiplot/out_any_drill.py | 12 ++++++--- tests/test_plot/test_drill.py | 12 +++++++-- tests/yaml_samples/drill.kiplot.yaml | 6 ++--- tests/yaml_samples/drill_legacy.kiplot.yaml | 28 +++++++++++++++++++++ 6 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 tests/yaml_samples/drill_legacy.kiplot.yaml diff --git a/docs/samples/example_1.kiplot.yaml b/docs/samples/example_1.kiplot.yaml index 831df405..2d86b514 100644 --- a/docs/samples/example_1.kiplot.yaml +++ b/docs/samples/example_1.kiplot.yaml @@ -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" diff --git a/docs/samples/generic_plot.kiplot.yaml b/docs/samples/generic_plot.kiplot.yaml index 44fc3f24..6b1d0000 100644 --- a/docs/samples/generic_plot.kiplot.yaml +++ b/docs/samples/generic_plot.kiplot.yaml @@ -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" diff --git a/kiplot/out_any_drill.py b/kiplot/out_any_drill.py index 494a55ec..84f7a37d 100644 --- a/kiplot/out_any_drill.py +++ b/kiplot/out_any_drill.py @@ -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: diff --git a/tests/test_plot/test_drill.py b/tests/test_plot/test_drill.py index a621c443..b18e4a7c 100644 --- a/tests/test_plot/test_drill.py +++ b/tests/test_plot/test_drill.py @@ -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') diff --git a/tests/yaml_samples/drill.kiplot.yaml b/tests/yaml_samples/drill.kiplot.yaml index 82c808a1..eb1268b9 100644 --- a/tests/yaml_samples/drill.kiplot.yaml +++ b/tests/yaml_samples/drill.kiplot.yaml @@ -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" diff --git a/tests/yaml_samples/drill_legacy.kiplot.yaml b/tests/yaml_samples/drill_legacy.kiplot.yaml new file mode 100644 index 00000000..82c808a1 --- /dev/null +++ b/tests/yaml_samples/drill_legacy.kiplot.yaml @@ -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 +