Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Prado Gesto <d.pradogesto@ultimaker.com>2018-03-23 19:14:53 +0300
committerDiego Prado Gesto <d.pradogesto@ultimaker.com>2018-03-23 19:14:53 +0300
commitdd0d0d20e9d692b87ade5293ad32c7e2177d6a70 (patch)
treef5e725d94b36a39c1bc776d17824b96f66936a0d /plugins/GCodeGzReader
parentc2888529cbd1036ca28b0c6fc22b42d3892702ab (diff)
CURA-5128 Modify the GCode parser to use a stream instead of a file so
we can reuse methods for the GCodeGZReader.
Diffstat (limited to 'plugins/GCodeGzReader')
-rw-r--r--plugins/GCodeGzReader/GCodeGzReader.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/plugins/GCodeGzReader/GCodeGzReader.py b/plugins/GCodeGzReader/GCodeGzReader.py
index 52df7f074f..5736fd2fec 100644
--- a/plugins/GCodeGzReader/GCodeGzReader.py
+++ b/plugins/GCodeGzReader/GCodeGzReader.py
@@ -2,15 +2,11 @@
# Cura is released under the terms of the LGPLv3 or higher.
import gzip
-import tempfile
-from io import StringIO, BufferedIOBase #To write the g-code to a temporary buffer, and for typing.
-from typing import List
+from io import TextIOWrapper
-from UM.Logger import Logger
from UM.Mesh.MeshReader import MeshReader #The class we're extending/implementing.
from UM.PluginRegistry import PluginRegistry
-from UM.Scene.SceneNode import SceneNode #For typing.
## A file writer that writes gzipped g-code.
#
@@ -24,10 +20,8 @@ class GCodeGzReader(MeshReader):
def read(self, file_name):
with open(file_name, "rb") as file:
file_data = file.read()
- uncompressed_gcode = gzip.decompress(file_data)
- with tempfile.NamedTemporaryFile() as temp_file:
- temp_file.write(uncompressed_gcode)
- PluginRegistry.getInstance().getPluginObject("GCodeReader").preRead(temp_file.name)
- result = PluginRegistry.getInstance().getPluginObject("GCodeReader").read(temp_file.name)
+ uncompressed_gcode = gzip.decompress(file_data).decode("utf-8")
+ PluginRegistry.getInstance().getPluginObject("GCodeReader").preReadFromStream(uncompressed_gcode)
+ result = PluginRegistry.getInstance().getPluginObject("GCodeReader").readFromStream(uncompressed_gcode)
return result