mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Rename import/export functions
They no longer mention the version number in their function names. I'd rather have named them import/export but that gave a name clash with Python's 'import' keyword. Contributes to issue CURA-844.
This commit is contained in:
parent
fdf37c2ab0
commit
f2f993916d
3 changed files with 8 additions and 8 deletions
|
@ -12,7 +12,7 @@ import io #To write config files to strings as if they were files.
|
||||||
# \param serialised The serialised form of a machine instance in version 1.
|
# \param serialised The serialised form of a machine instance in version 1.
|
||||||
# \return A machine instance instance, or None if the file format is
|
# \return A machine instance instance, or None if the file format is
|
||||||
# incorrect.
|
# incorrect.
|
||||||
def importVersion1(serialised):
|
def importFrom(serialised):
|
||||||
try:
|
try:
|
||||||
return MachineInstance(serialised)
|
return MachineInstance(serialised)
|
||||||
except (configparser.Error, SettingsError.InvalidFormatError, SettingsError.InvalidVersionError):
|
except (configparser.Error, SettingsError.InvalidFormatError, SettingsError.InvalidVersionError):
|
||||||
|
@ -57,7 +57,7 @@ class MachineInstance:
|
||||||
#
|
#
|
||||||
# \return A serialised form of this machine instance, serialised in
|
# \return A serialised form of this machine instance, serialised in
|
||||||
# version 2 of the file format.
|
# version 2 of the file format.
|
||||||
def exportVersion2(self):
|
def exportTo(self):
|
||||||
import VersionUpgrade21to22 # Import here to prevent circular dependencies.
|
import VersionUpgrade21to22 # Import here to prevent circular dependencies.
|
||||||
config = configparser.ConfigParser(interpolation = None) # Build a config file in the form of version 2.
|
config = configparser.ConfigParser(interpolation = None) # Build a config file in the form of version 2.
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import io #To write config files to strings as if they were files.
|
||||||
#
|
#
|
||||||
# \param serialised The serialised form of a profile in version 1.
|
# \param serialised The serialised form of a profile in version 1.
|
||||||
# \return A profile instance, or None if the file format is incorrect.
|
# \return A profile instance, or None if the file format is incorrect.
|
||||||
def importVersion1(serialised):
|
def importFrom(serialised):
|
||||||
try:
|
try:
|
||||||
return Profile(serialised)
|
return Profile(serialised)
|
||||||
except (configparser.Error, SettingsError.InvalidFormatError, SettingsError.InvalidVersionError):
|
except (configparser.Error, SettingsError.InvalidFormatError, SettingsError.InvalidVersionError):
|
||||||
|
@ -72,7 +72,7 @@ class Profile:
|
||||||
#
|
#
|
||||||
# \return A serialised form of this profile, serialised in version 2 of
|
# \return A serialised form of this profile, serialised in version 2 of
|
||||||
# the file format.
|
# the file format.
|
||||||
def exportVersion2(self):
|
def exportTo(self):
|
||||||
import VersionUpgrade21to22 # Import here to prevent circular dependencies.
|
import VersionUpgrade21to22 # Import here to prevent circular dependencies.
|
||||||
config = configparser.ConfigParser(interpolation = None)
|
config = configparser.ConfigParser(interpolation = None)
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ class VersionUpgrade21to22(VersionUpgrade):
|
||||||
# \return The serialised machine instance in version 2, or None if the
|
# \return The serialised machine instance in version 2, or None if the
|
||||||
# input was not of the correct format.
|
# input was not of the correct format.
|
||||||
def upgradeMachineInstance(self, serialised):
|
def upgradeMachineInstance(self, serialised):
|
||||||
machine_instance = MachineInstance.importVersion1(serialised)
|
machine_instance = MachineInstance.importFrom(serialised)
|
||||||
if not machine_instance: #Invalid file format.
|
if not machine_instance: #Invalid file format.
|
||||||
return None
|
return None
|
||||||
return machine_instance.exportVersion2()
|
return machine_instance.exportTo()
|
||||||
|
|
||||||
## Converts profiles from format version 1 to version 2.
|
## Converts profiles from format version 1 to version 2.
|
||||||
#
|
#
|
||||||
|
@ -27,10 +27,10 @@ class VersionUpgrade21to22(VersionUpgrade):
|
||||||
# \return The serialised profile in version 2, or None if the input was
|
# \return The serialised profile in version 2, or None if the input was
|
||||||
# not of the correct format.
|
# not of the correct format.
|
||||||
def upgradeProfile(self, serialised):
|
def upgradeProfile(self, serialised):
|
||||||
profile = Profile.importVersion1(serialised)
|
profile = Profile.importFrom(serialised)
|
||||||
if not profile: # Invalid file format.
|
if not profile: # Invalid file format.
|
||||||
return None
|
return None
|
||||||
return profile.exportVersion2()
|
return profile.exportTo()
|
||||||
|
|
||||||
## Translates settings for the change from Cura 2.1 to 2.2.
|
## Translates settings for the change from Cura 2.1 to 2.2.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue