Don't read machine instances as preferences

Machine instances have the exact same file structure as preferences, except that machine instances require a name field (was already correctly implemented), but preferences didn't require it. This now forbids preferences to have a name field, so that the distinction between the two can be made.

Contributes to issue CURA-844.
This commit is contained in:
Ghostkeeper 2016-06-30 14:21:07 +02:00
parent 07b6507133
commit 922b0df60b

View file

@ -35,6 +35,8 @@ class Preferences:
raise UM.VersionUpgrade.FormatException("No \"version\" in \"general\" section.")
if int(self._config.get("general", "version")) != 2: # Explicitly hard-code version 2, since if this number changes the programmer MUST change this entire function.
raise UM.VersionUpgrade.InvalidVersionException("The version of this preferences file is wrong. It must be 2.")
if self._config.has_option("general", "name"): #This is probably a machine instance.
raise UM.VersionUpgrade.FormatException("There is a \"name\" field in this configuration file. I suspect it is not a preferences file.")
## Serialises these preferences as a preferences file of version 3.
#