diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 02727dec4c..524e4662d5 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -11,6 +11,13 @@ import re #Regular expressions for parsing escape characters in the settings. # It reads the profile data from g-code files and stores it in a new profile. # This class currently does not process the rest of the g-code in any way. class GCodeProfileReader(ProfileReader): + ## The file format version of the serialised g-code. + # + # It can only read settings with the same version as the version it was + # written with. If the file format is changed in a way that breaks reverse + # compatibility, increment this version number! + version = 1 + ## Initialises the g-code reader as a profile reader. def __init__(self): super().__init__() @@ -22,7 +29,6 @@ class GCodeProfileReader(ProfileReader): # specified file was no g-code or contained no parsable profile, \code # None \endcode is returned. def read(self, file_name): - version = 1 #IF YOU CHANGE THIS FUNCTION IN A WAY THAT BREAKS REVERSE COMPATIBILITY, INCREMENT THIS VERSION NUMBER! prefix = ";SETTING_" + str(version) + " " #Loading all settings from the file. They are all at the end, but Python has no reverse seek any more since Python3. TODO: Consider moving settings to the start? diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index 69a94f59d3..20a32f7822 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -9,6 +9,13 @@ import re #For escaping characters in the settings. class GCodeWriter(MeshWriter): + ## The file format version of the serialised g-code. + # + # It can only read settings with the same version as the version it was + # written with. If the file format is changed in a way that breaks reverse + # compatibility, increment this version number! + version = 1 + def __init__(self): super().__init__() @@ -36,7 +43,6 @@ class GCodeWriter(MeshWriter): # \param profile The profile to serialise. # \return A serialised string of the profile. def _serialiseProfile(self, profile): - version = 1 #IF YOU CHANGE THIS FUNCTION IN A WAY THAT BREAKS REVERSE COMPATIBILITY, INCREMENT THIS VERSION NUMBER! prefix = ";SETTING_" + str(version) + " " #The prefix to put before each line. serialised = profile.serialise()