mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Move serialised version number to top of GCode reader/writer
The version number is more clearly exposed there. Contributes to issue CURA-34.
This commit is contained in:
parent
a12246781d
commit
cfa4382052
2 changed files with 14 additions and 2 deletions
|
@ -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?
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue