diff --git a/kiplot/optionable.py b/kiplot/optionable.py index 5483e646..fa0667ac 100644 --- a/kiplot/optionable.py +++ b/kiplot/optionable.py @@ -149,7 +149,7 @@ class Optionable(object): attrs = self.get_attrs_for() return ((k, v) for k, v in attrs.items() if k[0] != '_') - def expand_filename(self, name, id='', ext=''): + def expand_filename(self, out_dir, name, id='', ext=''): """ Expands %x values in filenames """ if GS.board: # This is based on InterativeHtmlBom expansion @@ -180,7 +180,7 @@ class Optionable(object): # sanitize the name to avoid characters illegal in file systems name = name.replace('\\', '/') name = re.sub(r'[?%*:|"<>]', '_', name) - return name + return os.path.abspath(os.path.join(out_dir, name)) class BaseOptions(Optionable): diff --git a/kiplot/out_any_drill.py b/kiplot/out_any_drill.py index a6c9cf2e..c7671ead 100644 --- a/kiplot/out_any_drill.py +++ b/kiplot/out_any_drill.py @@ -22,7 +22,7 @@ class DrillReport(Optionable): super().__init__() with document: self.filename = '' - """ name of the drill report. Not generated unless a name is specified """ # pragma: no cover + """ name of the drill report. Not generated unless a name is specified. (%i='drill' %x='txt') """ # pragma: no cover self._unkown_is_error = True @@ -80,6 +80,6 @@ class AnyDrill(BaseOptions): drill_writer.CreateDrillandMapFilesSet(output_dir, True, gen_map) if self.report: - drill_report_file = os.path.join(output_dir, self.report) + drill_report_file = self.expand_filename(output_dir, self.report, 'drill', 'txt') logger.debug("Generating drill report: "+drill_report_file) drill_writer.GenDrillReportFile(drill_report_file) diff --git a/kiplot/out_any_layer.py b/kiplot/out_any_layer.py index 129a4218..6d0d1765 100644 --- a/kiplot/out_any_layer.py +++ b/kiplot/out_any_layer.py @@ -83,8 +83,7 @@ class AnyLayerOptions(BaseOptions): k_filename = plot_ctrl.GetPlotFileName() if self.output: - filename = self.expand_filename(self.output, suffix, os.path.splitext(k_filename)[1][1:]) - filename = os.path.abspath(os.path.join(output_dir, filename)) + filename = self.expand_filename(output_dir, self.output, suffix, os.path.splitext(k_filename)[1][1:]) else: filename = k_filename logger.debug("Plotting layer `{}` to `{}`".format(l, filename)) @@ -96,8 +95,7 @@ class AnyLayerOptions(BaseOptions): jobfile_writer.AddGbrFile(id, os.path.basename(filename)) if create_job: - job_fn = self.expand_filename(po.gerber_job_file, 'job', 'gbrjob') - jobfile_writer.CreateJobFile(os.path.abspath(os.path.join(output_dir, job_fn))) + jobfile_writer.CreateJobFile(self.expand_filename(output_dir, po.gerber_job_file, 'job', 'gbrjob')) def read_vals_from_po(self, po): # excludeedgelayer diff --git a/kiplot/out_pcbdraw.py b/kiplot/out_pcbdraw.py index 0a344f04..b43f0c34 100644 --- a/kiplot/out_pcbdraw.py +++ b/kiplot/out_pcbdraw.py @@ -173,8 +173,7 @@ class PcbDrawOptions(BaseOptions): def run(self, output_dir, board): # Output file name - output = self.expand_filename(self.output, 'bottom' if self.bottom else 'top', self.format) - output = os.path.abspath(os.path.join(output_dir, output)) + output = self.expand_filename(output_dir, self.output, 'bottom' if self.bottom else 'top', self.format) # Base command with overwrite cmd = [PCBDRAW] # Add user options