Simplified the Optionable.expand_filename() usage.
Now the dir concatenation and absolute expansion is done in the function avoiding repetition.
This commit is contained in:
parent
acf6bedda8
commit
f8c339aa3d
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue