From e74191f2dbb814eab228060c5e867a9634edceac Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 16 Mar 2018 14:05:40 +0100 Subject: [PATCH] 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. --- .../RemovableDriveOutputDevice.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py index e719ba3286..184b6b8a20 100644 --- a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py +++ b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py @@ -62,14 +62,15 @@ class RemovableDriveOutputDevice(OutputDevice): if len(file_formats) == 0: 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!")) + preferred_format = file_formats[0] # Just take the first file format available. if file_handler is not None: - writer = file_handler.getWriterByMimeType(file_formats[0]["mime_type"]) + writer = file_handler.getWriterByMimeType(preferred_format["mime_type"]) 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: file_name = self._automaticFileName(nodes)