Codestyle: Start comments with space

We didn't really discuss this one, but apparently it's in PEP8 so I'd better do it.

Contributes to issue CURA-844.
This commit is contained in:
Ghostkeeper 2016-04-28 12:15:43 +02:00
parent 0e92929be4
commit 7ad2fbc95d
3 changed files with 19 additions and 19 deletions

View File

@ -26,9 +26,9 @@ class MachineInstance:
# \param serialised A string with the contents of a machine instance file. # \param serialised A string with the contents of a machine instance file.
def __init__(self, serialised): def __init__(self, serialised):
config = configparser.ConfigParser(interpolation = None) config = configparser.ConfigParser(interpolation = None)
config.read_string(serialised) #Read the input string as config file. config.read_string(serialised) # Read the input string as config file.
#Checking file correctness. # Checking file correctness.
if not config.has_section("general"): if not config.has_section("general"):
raise SettingsError.InvalidFormatError("general") raise SettingsError.InvalidFormatError("general")
if not config.has_option("general", "version"): if not config.has_option("general", "version"):
@ -37,7 +37,7 @@ class MachineInstance:
raise SettingsError.InvalidFormatError("general/name") raise SettingsError.InvalidFormatError("general/name")
if not config.has_option("general", "type"): if not config.has_option("general", "type"):
raise SettingsError.InvalidFormatError("general/type") raise SettingsError.InvalidFormatError("general/type")
if int(config.get("general", "version")) != 1: #Explicitly hard-code version 1, since if this number changes the programmer MUST change this entire function. if int(config.get("general", "version")) != 1: # Explicitly hard-code version 1, since if this number changes the programmer MUST change this entire function.
raise SettingsError.InvalidVersionError("Version upgrade intermediary version 1") raise SettingsError.InvalidVersionError("Version upgrade intermediary version 1")
self._type_name = config.get("general", "type") self._type_name = config.get("general", "type")
@ -58,13 +58,13 @@ 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 exportVersion2(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.
config.add_section("general") config.add_section("general")
config.set("general", "name", self._name) config.set("general", "name", self._name)
config.set("general", "type", self._type_name) config.set("general", "type", self._type_name)
config.set("general", "version", "2") #Hard-code version 2, since if this number changes the programmer MUST change this entire function. config.set("general", "version", "2") # Hard-code version 2, since if this number changes the programmer MUST change this entire function.
if self._variant_name: if self._variant_name:
config.set("general", "variant", self._variant_name) config.set("general", "variant", self._variant_name)
if self._key: if self._key:

View File

@ -27,13 +27,13 @@ class Profile:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
#Check correctness. # Check correctness.
if not parser.has_section("general"): if not parser.has_section("general"):
raise SettingsError.InvalidFormatError("general") raise SettingsError.InvalidFormatError("general")
if not parser.has_option("general", "version") or int(parser.get("general", "version")) != 1: #Hard-coded profile version here. If this number changes the entire function needs to change. if not parser.has_option("general", "version") or int(parser.get("general", "version")) != 1: #Hard-coded profile version here. If this number changes the entire function needs to change.
raise SettingsError.InvalidVersionError("Version upgrade intermediary version 1") raise SettingsError.InvalidVersionError("Version upgrade intermediary version 1")
#Parse the general section. # Parse the general section.
self._name = parser.get("general", "name") self._name = parser.get("general", "name")
self._type = parser.get("general", "type", fallback = None) self._type = parser.get("general", "type", fallback = None)
if "weight" in parser["general"]: if "weight" in parser["general"]:
@ -50,13 +50,13 @@ class Profile:
else: else:
self._material_name = None self._material_name = None
#Parse the settings. # Parse the settings.
self._settings = {} self._settings = {}
if parser.has_section("settings"): if parser.has_section("settings"):
for key, value in parser["settings"].items(): for key, value in parser["settings"].items():
self._settings[key] = value self._settings[key] = value
#Parse the defaults and the disabled defaults. # Parse the defaults and the disabled defaults.
self._changed_settings_defaults = {} self._changed_settings_defaults = {}
if parser.has_section("defaults"): if parser.has_section("defaults"):
for key, value in parser["defaults"].items(): for key, value in parser["defaults"].items():
@ -73,11 +73,11 @@ 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 exportVersion2(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)
config.add_section("general") config.add_section("general")
config.set("general", "version", "2") #Hard-coded profile version 2 config.set("general", "version", "2") # Hard-coded profile version 2
config.set("general", "name", self._name) config.set("general", "name", self._name)
if self._type: if self._type:
config.set("general", "type", self._type) config.set("general", "type", self._type)
@ -107,7 +107,7 @@ class Profile:
if self._disabled_settings_defaults: if self._disabled_settings_defaults:
VersionUpgrade21to22.VersionUpgrade21to22.translateSettingNames(self._disabled_settings_defaults) VersionUpgrade21to22.VersionUpgrade21to22.translateSettingNames(self._disabled_settings_defaults)
config.add_section("disabled_defaults") config.add_section("disabled_defaults")
disabled_defaults_string = str(self._disabled_settings_defaults[0]) #Must be at least 1 item, otherwise we wouldn't enter this if statement. disabled_defaults_string = str(self._disabled_settings_defaults[0]) # Must be at least 1 item, otherwise we wouldn't enter this if statement.
for item in self._disabled_settings_defaults[1:]: for item in self._disabled_settings_defaults[1:]:
disabled_defaults_string += "," + str(item) disabled_defaults_string += "," + str(item)

View File

@ -1,10 +1,10 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2016 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
from UM.VersionUpgrade import VersionUpgrade #Superclass of the plugin. from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin.
from . import MachineInstance #To upgrade machine instances. from . import MachineInstance # To upgrade machine instances.
from . import Profile #To upgrade profiles. from . import Profile # To upgrade profiles.
## Converts configuration from Cura 2.1's file formats to Cura 2.2's. ## Converts configuration from Cura 2.1's file formats to Cura 2.2's.
# #
@ -28,7 +28,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# not of the correct format. # not of the correct format.
def upgradeProfile(self, serialised): def upgradeProfile(self, serialised):
profile = Profile.importVersion1(serialised) profile = Profile.importVersion1(serialised)
if not profile: #Invalid file format. if not profile: # Invalid file format.
return None return None
return profile.exportVersion2() return profile.exportVersion2()
@ -42,10 +42,10 @@ class VersionUpgrade21to22(VersionUpgrade):
@staticmethod @staticmethod
def translateSettings(settings): def translateSettings(settings):
for key, value in settings.items(): for key, value in settings.items():
if key == "speed_support_lines": #Setting key was changed for 2.2. if key == "speed_support_lines": # Setting key was changed for 2.2.
del settings[key] del settings[key]
settings["speed_support_infill"] = value settings["speed_support_infill"] = value
if key == "retraction_combing": #Combing was made into an enum instead of a boolean. if key == "retraction_combing": # Combing was made into an enum instead of a boolean.
settings[key] = "off" if (value == "False") else "all" settings[key] = "off" if (value == "False") else "all"
return settings return settings