mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Codestyle & readability cleanup for g-codeprofile reader
This commit is contained in:
parent
1f7c2be1bc
commit
60a50ee393
1 changed files with 11 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import re # Regular expressions for parsing escape characters in the settings.
|
import re # Regular expressions for parsing escape characters in the settings.
|
||||||
|
@ -9,9 +9,10 @@ from UM.Settings.ContainerFormatError import ContainerFormatError
|
||||||
from UM.Settings.InstanceContainer import InstanceContainer
|
from UM.Settings.InstanceContainer import InstanceContainer
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
from cura.ReaderWriters.ProfileReader import ProfileReader, NoProfileException
|
||||||
|
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
from cura.ReaderWriters.ProfileReader import ProfileReader, NoProfileException
|
|
||||||
|
|
||||||
class GCodeProfileReader(ProfileReader):
|
class GCodeProfileReader(ProfileReader):
|
||||||
"""A class that reads profile data from g-code files.
|
"""A class that reads profile data from g-code files.
|
||||||
|
@ -41,11 +42,6 @@ class GCodeProfileReader(ProfileReader):
|
||||||
not.
|
not.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
"""Initialises the g-code reader as a profile reader."""
|
|
||||||
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def read(self, file_name):
|
def read(self, file_name):
|
||||||
"""Reads a g-code file, loading the profile from it.
|
"""Reads a g-code file, loading the profile from it.
|
||||||
|
|
||||||
|
@ -54,6 +50,7 @@ class GCodeProfileReader(ProfileReader):
|
||||||
specified file was no g-code or contained no parsable profile,
|
specified file was no g-code or contained no parsable profile,
|
||||||
None is returned.
|
None is returned.
|
||||||
"""
|
"""
|
||||||
|
Logger.log("i", "Attempting to read a profile from the g-code")
|
||||||
|
|
||||||
if file_name.split(".")[-1] != "gcode":
|
if file_name.split(".")[-1] != "gcode":
|
||||||
return None
|
return None
|
||||||
|
@ -79,10 +76,10 @@ class GCodeProfileReader(ProfileReader):
|
||||||
serialized = serialized.strip()
|
serialized = serialized.strip()
|
||||||
|
|
||||||
if not serialized:
|
if not serialized:
|
||||||
Logger.log("i", "No custom profile to import from this g-code: %s", file_name)
|
Logger.log("w", "No custom profile to import from this g-code: %s", file_name)
|
||||||
raise NoProfileException()
|
raise NoProfileException()
|
||||||
|
|
||||||
# serialized data can be invalid JSON
|
# Serialized data can be invalid JSON
|
||||||
try:
|
try:
|
||||||
json_data = json.loads(serialized)
|
json_data = json.loads(serialized)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue