Fix code-style

This commit is contained in:
Diego Prado Gesto 2018-07-03 12:06:06 +02:00
parent e983a9a9e7
commit 762a1b1bfd
13 changed files with 47 additions and 33 deletions

View file

@ -4,6 +4,7 @@
import os
import urllib.parse
import uuid
from typing import Any
from typing import Dict, Union
from PyQt5.QtCore import QObject, QUrl, QVariant
@ -43,7 +44,7 @@ class ContainerManager(QObject):
self._machine_manager = self._application.getMachineManager()
self._material_manager = self._application.getMaterialManager()
self._quality_manager = self._application.getQualityManager()
self._container_name_filters = {}
self._container_name_filters = {} # type: Dict[str, Dict[str, Any]]
@pyqtSlot(str, str, result=str)
def getContainerMetaDataEntry(self, container_id, entry_name):

View file

@ -244,8 +244,9 @@ class CuraContainerStack(ContainerStack):
#
# \throws InvalidContainerStackError Raised when no definition can be found for the stack.
@override(ContainerStack)
def deserialize(self, contents: str, file_name: Optional[str] = None) -> None:
super().deserialize(contents, file_name)
def deserialize(self, serialized: str, file_name: Optional[str] = None) -> str:
# update the serialized data first
serialized = super().deserialize(serialized, file_name)
new_containers = self._containers.copy()
while len(new_containers) < len(_ContainerIndexes.IndexTypeMap):
@ -253,10 +254,11 @@ class CuraContainerStack(ContainerStack):
# Validate and ensure the list of containers matches with what we expect
for index, type_name in _ContainerIndexes.IndexTypeMap.items():
container = None
try:
container = new_containers[index]
except IndexError:
container = None
pass
if type_name == "definition":
if not container or not isinstance(container, DefinitionContainer):
@ -283,6 +285,9 @@ class CuraContainerStack(ContainerStack):
from cura.Settings.CuraStackBuilder import CuraStackBuilder
CuraStackBuilder.createDefinitionChangesContainer(self, self.getId() + "_settings")
## TODO; Deserialize the containers.
return serialized
## protected:
# Helper to make sure we emit a PyQt signal on container changes.

View file

@ -3,7 +3,7 @@
import collections
import time
from typing import Any, Callable, List, Dict, TYPE_CHECKING, Optional
from typing import Any, Callable, List, Dict, TYPE_CHECKING, Optional, cast
from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
@ -1137,7 +1137,7 @@ class MachineManager(QObject):
quality_changes_container = self._empty_quality_changes_container
quality_container = self._empty_quality_container
if quality_changes_group.node_for_global and quality_changes_group.node_for_global.getContainer():
quality_changes_container = quality_changes_group.node_for_global.getContainer()
quality_changes_container = cast(InstanceContainer, quality_changes_group.node_for_global.getContainer())
if quality_group is not None and quality_group.node_for_global and quality_group.node_for_global.getContainer():
quality_container = quality_group.node_for_global.getContainer()
@ -1153,7 +1153,7 @@ class MachineManager(QObject):
quality_changes_container = self._empty_quality_changes_container
quality_container = self._empty_quality_container
if quality_changes_node and quality_changes_node.getContainer():
quality_changes_container = quality_changes_node.getContainer()
quality_changes_container = cast(InstanceContainer, quality_changes_node.getContainer())
if quality_node and quality_node.getContainer():
quality_container = quality_node.getContainer()
@ -1279,7 +1279,7 @@ class MachineManager(QObject):
continue
# The current material is not available, find the preferred one
material_node = self._material_manager.getDefaultMaterial(self._global_container_stack, position, current_variant_name)
material_node = self._material_manager.getDefaultMaterial(self._global_container_stack, position_item, current_variant_name)
if material_node is not None:
self._setMaterial(position_item, material_node)

View file

@ -19,6 +19,8 @@ class PerObjectContainerStack(CuraContainerStack):
context.pushContainer(self)
global_stack = Application.getInstance().getGlobalContainerStack()
if not global_stack:
return None
# Return the user defined value if present, otherwise, evaluate the value according to the default routine.
if self.getContainer(0).hasProperty(key, property_name):

View file

@ -171,7 +171,8 @@ class SettingInheritanceManager(QObject):
return False
## Also check if the top container is not a setting function (this happens if the inheritance is restored).
if isinstance(stack.getTop().getProperty(key, "value"), SettingFunction):
user_container = stack.getTop()
if user_container and isinstance(user_container.getProperty(key, "value"), SettingFunction):
return False
## Mash all containers for all the stacks together.