|
@@ -1,19 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import os
|
|
|
|
+import re
|
|
|
|
+
|
|
from UM.Application import Application
|
|
from UM.Application import Application
|
|
-from UM.Settings.Profile import Profile
|
|
+from UM.Settings.InstanceContainer import InstanceContainer
|
|
-from UM.Settings.ProfileReader import ProfileReader
|
|
|
|
from UM.Logger import Logger
|
|
from UM.Logger import Logger
|
|
-import re
|
|
|
|
|
|
|
|
|
|
+from cura.ProfileReader import ProfileReader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GCodeProfileReader(ProfileReader):
|
|
class GCodeProfileReader(ProfileReader):
|
|
-
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -51,31 +53,32 @@ class GCodeProfileReader(ProfileReader):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- serialised = ""
|
|
+ serialized = ""
|
|
try:
|
|
try:
|
|
with open(file_name) as f:
|
|
with open(file_name) as f:
|
|
for line in f:
|
|
for line in f:
|
|
if line.startswith(prefix):
|
|
if line.startswith(prefix):
|
|
|
|
|
|
- serialised += line[prefix_length : -1]
|
|
+ serialized += line[prefix_length : -1]
|
|
except IOError as e:
|
|
except IOError as e:
|
|
Logger.log("e", "Unable to open file %s for reading: %s", file_name, str(e))
|
|
Logger.log("e", "Unable to open file %s for reading: %s", file_name, str(e))
|
|
return None
|
|
return None
|
|
-
|
|
+
|
|
-
|
|
+
|
|
pattern = re.compile("|".join(GCodeProfileReader.escape_characters.keys()))
|
|
pattern = re.compile("|".join(GCodeProfileReader.escape_characters.keys()))
|
|
|
|
|
|
|
|
|
|
- serialised = pattern.sub(lambda m: GCodeProfileReader.escape_characters[re.escape(m.group(0))], serialised)
|
|
+ serialized = pattern.sub(lambda m: GCodeProfileReader.escape_characters[re.escape(m.group(0))], serialized)
|
|
|
|
+ Logger.log("i", "Serialized the following from %s: %s" %(file_name, repr(serialized)))
|
|
|
|
|
|
-
|
|
+
|
|
- profile = Profile(machine_manager = Application.getInstance().getMachineManager(), read_only = False)
|
|
+ profile = InstanceContainer(os.path.basename(os.path.splitext(file_name)[0]))
|
|
|
|
+ profile.addMetaDataEntry("type", "quality")
|
|
try:
|
|
try:
|
|
- profile.unserialise(serialised)
|
|
+ profile.deserialize(serialized)
|
|
- profile.setType(None)
|
|
|
|
profile.setReadOnly(False)
|
|
profile.setReadOnly(False)
|
|
- profile.setDirty(True)
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
Logger.log("e", "Unable to serialise the profile: %s", str(e))
|
|
Logger.log("e", "Unable to serialise the profile: %s", str(e))
|
|
return None
|
|
return None
|
|
|
|
+
|
|
return profile
|
|
return profile
|