def MapFileExtension(file_name, extension_mapping):
  """Changes the file extension based on extension_mapping."""
  name_parts = file_name.rsplit('.', 1)
  if len(name_parts) == 1:
    return file_name

  name_parts[-1] = extension_mapping.get(name_parts[-1], name_parts[-1])
  return '.'.join(name_parts)