Codestyle & readability cleanup for g-codeprofile reader

This commit is contained in:
Jaime van Kessel 2020-07-29 10:47:49 +02:00
parent 1f7c2be1bc
commit 60a50ee393
No known key found for this signature in database
GPG key ID: 3710727397403C91

View file

@ -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.
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.Logger import Logger
from UM.i18n import i18nCatalog
from cura.ReaderWriters.ProfileReader import ProfileReader, NoProfileException
catalog = i18nCatalog("cura")
from cura.ReaderWriters.ProfileReader import ProfileReader, NoProfileException
class GCodeProfileReader(ProfileReader):
"""A class that reads profile data from g-code files.
@ -41,11 +42,6 @@ class GCodeProfileReader(ProfileReader):
not.
"""
def __init__(self):
"""Initialises the g-code reader as a profile reader."""
super().__init__()
def read(self, file_name):
"""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,
None is returned.
"""
Logger.log("i", "Attempting to read a profile from the g-code")
if file_name.split(".")[-1] != "gcode":
return None
@ -79,10 +76,10 @@ class GCodeProfileReader(ProfileReader):
serialized = serialized.strip()
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()
# serialized data can be invalid JSON
# Serialized data can be invalid JSON
try:
json_data = json.loads(serialized)
except Exception as e: