Added `position` output configuration.

This commit is contained in:
Salvador E. Tropea 2020-07-12 18:46:37 -03:00
parent 36eedc9fce
commit 031c69e27c
5 changed files with 15 additions and 13 deletions

View File

@ -14,13 +14,14 @@ 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` and `drill.map` file names can be configured.
- `drill`, `drill.map` and `position` file names can be configured.
### Changed
- Default file names for:
- pdf_pcb_print: includes the used layers
- drill maps: uses drill instead of drl
- dril: uses drill instead of drl, used in gbr and drl.
- position: no -pos in CSVs
## [0.5.0] - 2020-07-11
### Changed

View File

@ -16,19 +16,20 @@ class PositionOptions(BaseOptions):
""" generate two separated files, one for the top and another for the bottom """
self.only_smd = True
""" only include the surface mount components """
self.output = '%f-%i.%x'
""" output file name (%i='top'|'bottom'|'both', %x='pos'|'csv') """
self.units = 'millimeters'
""" [millimeters,inches] units used for the positions """ # pragma: no cover
def _do_position_plot_ascii(self, board, output_dir, columns, modulesStr, maxSizes):
name = os.path.splitext(os.path.basename(board.GetFileName()))[0]
topf = None
botf = None
bothf = None
if self.separate_files_for_front_and_back:
topf = open(os.path.join(output_dir, "{}-top.pos".format(name)), 'w')
botf = open(os.path.join(output_dir, "{}-bottom.pos".format(name)), 'w')
topf = open(self.expand_filename(output_dir, self.output, 'top', 'pos'), 'w')
botf = open(self.expand_filename(output_dir, self.output, 'bottom', 'pos'), 'w')
else:
bothf = open(os.path.join(output_dir, "{}-both.pos").format(name), 'w')
bothf = open(self.expand_filename(output_dir, self.output, 'both', 'pos'), 'w')
files = [f for f in [topf, botf, bothf] if f is not None]
for f in files:
@ -79,15 +80,14 @@ class PositionOptions(BaseOptions):
bothf.close()
def _do_position_plot_csv(self, board, output_dir, columns, modulesStr):
name = os.path.splitext(os.path.basename(board.GetFileName()))[0]
topf = None
botf = None
bothf = None
if self.separate_files_for_front_and_back:
topf = open(os.path.join(output_dir, "{}-top-pos.csv".format(name)), 'w')
botf = open(os.path.join(output_dir, "{}-bottom-pos.csv".format(name)), 'w')
topf = open(self.expand_filename(output_dir, self.output, 'top', 'csv'), 'w')
botf = open(self.expand_filename(output_dir, self.output, 'bottom', 'csv'), 'w')
else:
bothf = open(os.path.join(output_dir, "{}-both-pos.csv").format(name), 'w')
bothf = open(self.expand_filename(output_dir, self.output, 'both', 'csv'), 'w')
files = [f for f in [topf, botf, bothf] if f is not None]

View File

@ -88,7 +88,7 @@ def test_3Rs_position_unified():
def test_3Rs_position_unified_th():
ctx = context.TestContext('3Rs_position_unified_th', '3Rs', 'simple_position_unified_th', POS_DIR)
ctx.run()
expect_position(ctx, ctx.get_pos_both_filename(), ['R1', 'R2', 'R3'])
expect_position(ctx, os.path.join(POS_DIR, ctx.board_name+'-both-pos.pos'), ['R1', 'R2', 'R3'])
ctx.clean_up()

View File

@ -105,13 +105,13 @@ class TestContext(object):
return os.path.join(self.sub_dir, self.board_name+'-both.pos')
def get_pos_top_csv_filename(self):
return os.path.join(self.sub_dir, self.board_name+'-top-pos.csv')
return os.path.join(self.sub_dir, self.board_name+'-top.csv')
def get_pos_bot_csv_filename(self):
return os.path.join(self.sub_dir, self.board_name+'-bottom-pos.csv')
return os.path.join(self.sub_dir, self.board_name+'-bottom.csv')
def get_pos_both_csv_filename(self):
return os.path.join(self.sub_dir, self.board_name+'-both-pos.csv')
return os.path.join(self.sub_dir, self.board_name+'-both.csv')
def get_pth_drl_filename(self):
return os.path.join(self.sub_dir, self.board_name+'-PTH.drl')

View File

@ -12,4 +12,5 @@ outputs:
format: ASCII # CSV or ASCII format
units: millimeters # millimeters or inches
separate_files_for_front_and_back: false
output: '%f-%i-pos.%x'
only_smd: false