Skip to content

Commit

Permalink
Extract property for mapping src extensions to out extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 21, 2022
1 parent d14faf0 commit e982d51
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,16 +928,22 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
for src_name in source_filenames
)

@property
def out_extensions(self):
return dict.fromkeys(self.src_extensions, self.obj_extension)

def _make_out_path(self, output_dir, strip_dir, src_name):
base, ext = os.path.splitext(src_name)
base = self._make_relative(base)
if ext not in self.src_extensions:
try:
new_ext = self.out_extensions[ext]
except LookupError:
raise UnknownFileError(
"unknown file type '{}' (from '{}')".format(ext, src_name)
)
if strip_dir:
base = os.path.basename(base)
return os.path.join(output_dir, base + self.obj_extension)
return os.path.join(output_dir, base + new_ext)

@staticmethod
def _make_relative(base):
Expand Down

0 comments on commit e982d51

Please sign in to comment.