diff --git a/CHANGELOG.md b/CHANGELOG.md index b635458f..5cd44af1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/kiplot/out_position.py b/kiplot/out_position.py index 5b4e95c9..d14a4fee 100644 --- a/kiplot/out_position.py +++ b/kiplot/out_position.py @@ -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] diff --git a/tests/test_plot/test_position.py b/tests/test_plot/test_position.py index 505410e3..60f34882 100644 --- a/tests/test_plot/test_position.py +++ b/tests/test_plot/test_position.py @@ -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() diff --git a/tests/utils/context.py b/tests/utils/context.py index 7682ac60..2f0c282a 100644 --- a/tests/utils/context.py +++ b/tests/utils/context.py @@ -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') diff --git a/tests/yaml_samples/simple_position_unified_th.kiplot.yaml b/tests/yaml_samples/simple_position_unified_th.kiplot.yaml index fb5d12e8..42b36a4d 100644 --- a/tests/yaml_samples/simple_position_unified_th.kiplot.yaml +++ b/tests/yaml_samples/simple_position_unified_th.kiplot.yaml @@ -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