Return None if config file wasn't correct

This was actually specified in the original function description.

Contributes to issue CURA-844.
This commit is contained in:
Ghostkeeper 2016-04-19 16:08:47 +02:00 committed by Ghostkeeper
parent 0d553c10f1
commit 724f9ce010
2 changed files with 8 additions and 2 deletions

View file

@ -13,7 +13,10 @@ import io #To write config files to strings as if they were files.
# \return A machine instance instance, or None if the file format is
# incorrect.
def importVersion1(serialised):
try:
return MachineInstance(serialised)
except configparser.Error, SettingsError.InvalidFormatError, SettingsError.InvalidVersionError:
return None
## A representation of a machine instance used as intermediary form for
# conversion from one format to the other.

View file

@ -12,7 +12,10 @@ import io #To write config files to strings as if they were files.
# \param serialised The serialised form of a profile in version 1.
# \return A profile instance, or None if the file format is incorrect.
def importVersion1(serialised):
try:
return Profile(serialised)
except configparser.Error, SettingsError.InvalidFormatError, SettingsError.InvalidVersionError:
return None
## A representation of a profile used as intermediary form for conversion from
# one format to the other.