diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2019-04-02 10:43:41 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2019-04-03 11:25:17 +0300 |
commit | dd19d7d1a9067f39989ab7fbb0d1efed9bed8504 (patch) | |
tree | 8d4516b0cc21e8d33cb528b1b3bc131a70a97c12 /plugins/GCodeReader | |
parent | 31e20e78b6a3f94db08cc1f1b0115ef80eccaa08 (diff) |
Fix typing
Diffstat (limited to 'plugins/GCodeReader')
-rw-r--r-- | plugins/GCodeReader/FlavorParser.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/plugins/GCodeReader/FlavorParser.py b/plugins/GCodeReader/FlavorParser.py index f8618712a1..4c88e5c953 100644 --- a/plugins/GCodeReader/FlavorParser.py +++ b/plugins/GCodeReader/FlavorParser.py @@ -1,31 +1,33 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +import math +import re +from typing import Dict, List, NamedTuple, Optional, Union + +import numpy + from UM.Backend import Backend from UM.Job import Job from UM.Logger import Logger from UM.Math.Vector import Vector from UM.Message import Message -from cura.Scene.CuraSceneNode import CuraSceneNode from UM.i18n import i18nCatalog -catalog = i18nCatalog("cura") - from cura.CuraApplication import CuraApplication from cura.LayerDataBuilder import LayerDataBuilder from cura.LayerDataDecorator import LayerDataDecorator from cura.LayerPolygon import LayerPolygon +from cura.Scene.CuraSceneNode import CuraSceneNode from cura.Scene.GCodeListDecorator import GCodeListDecorator from cura.Settings.ExtruderManager import ExtruderManager -import numpy -import math -import re -from typing import Dict, List, NamedTuple, Optional, Union +catalog = i18nCatalog("cura") PositionOptional = NamedTuple("Position", [("x", Optional[float]), ("y", Optional[float]), ("z", Optional[float]), ("f", Optional[float]), ("e", Optional[float])]) Position = NamedTuple("Position", [("x", float), ("y", float), ("z", float), ("f", float), ("e", List[float])]) + ## This parser is intended to interpret the common firmware codes among all the # different flavors class FlavorParser: @@ -33,7 +35,7 @@ class FlavorParser: def __init__(self) -> None: CuraApplication.getInstance().hideMessageSignal.connect(self._onHideMessage) self._cancelled = False - self._message = None + self._message = None # type: Optional[Message] self._layer_number = 0 self._extruder_number = 0 self._clearValues() @@ -425,7 +427,8 @@ class FlavorParser: if line.startswith("M"): M = self._getInt(line, "M") - self.processMCode(M, line, current_position, current_path) + if M is not None: + self.processMCode(M, line, current_position, current_path) # "Flush" leftovers. Last layer paths are still stored if len(current_path) > 1: @@ -463,7 +466,7 @@ class FlavorParser: Logger.log("w", "File doesn't contain any valid layers") settings = CuraApplication.getInstance().getGlobalContainerStack() - if not settings.getProperty("machine_center_is_zero", "value"): + if settings is not None and not settings.getProperty("machine_center_is_zero", "value"): machine_width = settings.getProperty("machine_width", "value") machine_depth = settings.getProperty("machine_depth", "value") scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2)) |