diff --git a/cura/ProfileWriter.py b/cura/ProfileWriter.py new file mode 100644 index 0000000000..6c719205ec --- /dev/null +++ b/cura/ProfileWriter.py @@ -0,0 +1,25 @@ +# Copyright (c) 2015 Ultimaker B.V. +# Uranium is released under the terms of the AGPLv3 or higher. + +from UM.PluginObject import PluginObject + +## Base class for profile writer plugins. +# +# This class defines a write() function to write profiles to files with. +class ProfileWriter(PluginObject): + ## Initialises the profile writer. + # + # This currently doesn't do anything since the writer is basically static. + def __init__(self): + super().__init__() + + ## Writes a profile to the specified file path. + # + # The profile writer may write its own file format to the specified file. + # + # \param path \type{string} The file to output to. + # \param profile \type{Profile} The profile to write to the file. + # \return \code True \endcode if the writing was successful, or \code + # False \endcode if it wasn't. + def write(self, path, node): + raise NotImplementedError("Profile writer plugin was not correctly implemented. No write was specified.") diff --git a/plugins/CuraProfileReader/CuraProfileReader.py b/plugins/CuraProfileReader/CuraProfileReader.py index c9b4e60046..9ff2955b22 100644 --- a/plugins/CuraProfileReader/CuraProfileReader.py +++ b/plugins/CuraProfileReader/CuraProfileReader.py @@ -3,7 +3,7 @@ from UM.Application import Application #To get the machine manager to create the new profile in. from UM.Logger import Logger -from UM.Settings.ProfileReader import ProfileReader +from cura.ProfileReader import ProfileReader ## A plugin that reads profile data from Cura profile files. @@ -25,16 +25,15 @@ class CuraProfileReader(ProfileReader): def read(self, file_name): # Create an empty profile. profile = Profile(machine_manager = Application.getInstance().getMachineManager(), read_only = False) - serialised = "" try: with open(file_name) as f: # Open file for reading. - serialised = f.read() + serialized = f.read() except IOError as e: Logger.log("e", "Unable to open file %s for reading: %s", file_name, str(e)) return None try: - profile.unserialise(serialised) + profile.deserialize(serialized) except Exception as e: # Parsing error. This is not a (valid) Cura profile then. Logger.log("e", "Error while trying to parse profile: %s", str(e)) return None diff --git a/plugins/CuraProfileWriter/CuraProfileWriter.py b/plugins/CuraProfileWriter/CuraProfileWriter.py index c6c4244948..86b4f7dc89 100644 --- a/plugins/CuraProfileWriter/CuraProfileWriter.py +++ b/plugins/CuraProfileWriter/CuraProfileWriter.py @@ -4,7 +4,7 @@ from UM.Logger import Logger from UM.SaveFile import SaveFile -from UM.Settings.ProfileWriter import ProfileWriter +from cura.ProfileWriter import ProfileWriter ## Writes profiles to Cura's own profile format with config files.