Cache preferred format

I think that makes the code a bit easier to read. This is not really done to make it faster, just more semantic.

Contributes to issue CURA-5097.
This commit is contained in:
Ghostkeeper 2018-03-16 14:05:40 +01:00
parent ee4a6dc704
commit e74191f2db
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -62,14 +62,15 @@ class RemovableDriveOutputDevice(OutputDevice):
if len(file_formats) == 0: if len(file_formats) == 0:
Logger.log("e", "There are no file formats available to write with!") Logger.log("e", "There are no file formats available to write with!")
raise OutputDeviceError.WriteRequestFailedError(catalog.i18nc("@info:status", "There are no file formats available to write with!")) raise OutputDeviceError.WriteRequestFailedError(catalog.i18nc("@info:status", "There are no file formats available to write with!"))
preferred_format = file_formats[0]
# Just take the first file format available. # Just take the first file format available.
if file_handler is not None: if file_handler is not None:
writer = file_handler.getWriterByMimeType(file_formats[0]["mime_type"]) writer = file_handler.getWriterByMimeType(preferred_format["mime_type"])
else: else:
writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(file_formats[0]["mime_type"]) writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(preferred_format["mime_type"])
extension = file_formats[0]["extension"] extension = preferred_format["extension"]
if file_name is None: if file_name is None:
file_name = self._automaticFileName(nodes) file_name = self._automaticFileName(nodes)