Browse Source

CURA-5053 Changed printer type checking

"Still hard coded but at least doesn't use `elif` because `elif`/`else if` should not exist in any programming language." - Grumpy Pedants & Ian >:[
Ian Paschal 7 years ago
parent
commit
4a16d04dd7
1 changed files with 9 additions and 6 deletions
  1. 9 6
      cura/PrinterOutput/NetworkedPrinterOutputDevice.py

+ 9 - 6
cura/PrinterOutput/NetworkedPrinterOutputDevice.py

@@ -56,12 +56,15 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
         self._connection_state_before_timeout = None    # type: Optional[ConnectionState]
 
         printer_type = self._properties.get(b"machine", b"").decode("utf-8")
-        if printer_type.startswith("9511"):
-            self._printer_type = "ultimaker3_extended"
-        elif printer_type.startswith("9066"):
-            self._printer_type = "ultimaker3"
-        else:
-            self._printer_type = "unknown"
+        printer_type_identifiers = {
+            "9066": "ultimaker3",
+            "9511": "ultimaker3_extended"
+        }
+        self._printer_type = "Unknown"
+        for key, value in printer_type_identifiers.items():
+            if printer_type.startswith(key):
+                self._printer_type = value
+                break
 
     def requestWrite(self, nodes, file_name=None, filter_by_machine=False, file_handler=None, **kwargs) -> None:
         raise NotImplementedError("requestWrite needs to be implemented")