From 4ca247cf3753cedd77919778187bc0e4e43c88e9 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 17 Jun 2016 12:41:24 +0200 Subject: Changing the profile name to something unique. Imported profiles will be now called "Custom profile ()" --- plugins/GCodeProfileReader/GCodeProfileReader.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'plugins/GCodeProfileReader') diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 3cff7167b5..8b8809df57 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -7,6 +7,8 @@ import re #Regular expressions for parsing escape characters in the settings. from UM.Application import Application #To get the machine manager to create the new profile in. from UM.Settings.InstanceContainer import InstanceContainer from UM.Logger import Logger +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") from cura.ProfileReader import ProfileReader @@ -71,7 +73,7 @@ class GCodeProfileReader(ProfileReader): 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))) - # Create an empty profile with the name of the G-code file + # Create an empty profile - the id will be changed later profile = InstanceContainer("G-code-imported-profile") profile.addMetaDataEntry("type", "quality") try: @@ -80,4 +82,9 @@ class GCodeProfileReader(ProfileReader): Logger.log("e", "Unable to serialise the profile: %s", str(e)) return None + #Creating a unique name using the filename of the GCode + new_name = catalog.i18nc("@label", "Custom profile (%s)") %(os.path.splitext(os.path.basename(file_name))[0]) + profile.setName(new_name) + profile._id = new_name + return profile \ No newline at end of file -- cgit v1.2.3