Drill map file names can be configured.

This commit is contained in:
Salvador E. Tropea 2020-07-12 17:01:23 -03:00
parent b6347d8992
commit b8b1277f5f
4 changed files with 39 additions and 7 deletions

View File

@ -14,6 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `regexp` -> `regex`
- `gerber.gerber_job_file` option to control the gerber job file name.
- `output` option to control the file name to all plot output formats.
- `drill.map` file names can be configured.
### Changed
- Default file names for:
- pdf_pcb_print: includes the used layers
- drill maps: uses drill instead of drl
## [0.5.0] - 2020-07-11
### Changed

View File

@ -9,9 +9,13 @@ logger = log.get_logger(__name__)
class DrillMap(Optionable):
_out_def = '%f-%i.%x'
def __init__(self):
super().__init__()
with document:
self.output = self._out_def
""" name for the map file, KiCad defaults if empty (%i='PTH_drill_map') """
self.type = 'pdf'
""" [hpgl,ps,gerber,dxf,svg,pdf] format for a graphical drill map """ # pragma: no cover
self._unkown_is_error = True
@ -47,13 +51,18 @@ class AnyDrill(BaseOptions):
'svg': PLOT_FORMAT_SVG,
'pdf': PLOT_FORMAT_PDF
}
self._map_ext = { 'hpgl': 'plt', 'ps': 'ps', 'gerber': 'gbr', 'dxf': 'dxf', 'svg': 'svg', 'pdf': 'pdf' }
def config(self, tree):
super().config(tree)
# Solve the map for both cases
if isinstance(self.map, str):
self.map_ext = self._map_ext[self.map]
self.map_output = DrillMap._out_def
self.map = self._map_map[self.map]
elif isinstance(self.map, DrillMap):
self.map_ext = self._map_ext[self.map.type]
self.map_output = self.map.output
self.map = self._map_map[self.map.type]
else:
self.map = None
@ -78,6 +87,16 @@ class AnyDrill(BaseOptions):
logger.debug("Generating drill map type {} in {}".format(self.map, output_dir))
# We always generate the drill file
drill_writer.CreateDrillandMapFilesSet(output_dir, True, gen_map)
# Rename the files
if gen_map and self.map_output:
id = 'PTH_drill_map'
k_file = self.expand_filename(output_dir, '%f-PTH-drl_map.%x', '', self.map_ext)
file = self.expand_filename(output_dir, self.map_output, id, self.map_ext)
os.rename(k_file, file)
id = 'N'+id
k_file = self.expand_filename(output_dir, '%f-NPTH-drl_map.%x', '', self.map_ext)
file = self.expand_filename(output_dir, self.map_output, id, self.map_ext)
os.rename(k_file, file)
if self.report:
drill_report_file = self.expand_filename(output_dir, self.report, 'drill_report', 'txt')

View File

@ -36,10 +36,6 @@ def do_3Rs(conf, dir, report):
ctx.expect_out_file(pth_gbr_drl)
npth_gbr_drl = ctx.get_npth_gbr_drl_filename()
ctx.expect_out_file(npth_gbr_drl)
pth_pdf_drl = ctx.get_pth_pdf_drl_filename()
ctx.expect_out_file(pth_pdf_drl)
npth_pdf_drl = ctx.get_npth_pdf_drl_filename()
ctx.expect_out_file(npth_pdf_drl)
# We have R3 at (110, 45) length is 9 mm on X, drill 1 mm
ctx.search_in_file(pth_drl, ['X110.0Y-45.0', 'X119.0Y-45.0'])
ctx.expect_gerber_flash_at(pth_gbr_drl, 6, (110, -45))
@ -48,12 +44,22 @@ def do_3Rs(conf, dir, report):
ctx.search_in_file(npth_drl, ['X120.0Y-29.0', 'T1C2.100'])
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()
return ctx
def test_drill_3Rs():
do_3Rs('drill', 'Drill_3Rs', 'report.rpt')
ctx = do_3Rs('drill', 'Drill_3Rs', 'report.rpt')
pth_pdf_drl = ctx.get_pth_pdf_drl_filename()
ctx.expect_out_file(pth_pdf_drl.replace('-drl', '_drill'))
npth_pdf_drl = ctx.get_npth_pdf_drl_filename()
ctx.expect_out_file(npth_pdf_drl.replace('-drl', '_drill'))
ctx.clean_up()
def test_drill_legacy_3Rs():
do_3Rs('drill_legacy', 'DrillLegacy_3Rs', '3Rs-drill_report.txt')
ctx = do_3Rs('drill_legacy', 'DrillLegacy_3Rs', '3Rs-drill_report.txt')
pth_pdf_drl = ctx.get_pth_pdf_drl_filename()
ctx.expect_out_file(pth_pdf_drl)
npth_pdf_drl = ctx.get_npth_pdf_drl_filename()
ctx.expect_out_file(npth_pdf_drl)
ctx.clean_up()

View File

@ -17,6 +17,7 @@ outputs:
report:
filename: '%f-%i.%x'
map:
output: ''
type: 'pdf'
- name: gerber_drills