Cura/cura/Settings/AbstractMachine.py
Casper Lamboo 35502e45fa
Apply suggestions from code review
CURA-9277

Co-authored-by: Jelle Spijker <j.spijker@ultimaker.com>
2022-08-22 14:48:04 +02:00

35 lines
1.4 KiB
Python

from typing import List
from UM.Settings.ContainerStack import ContainerStack
from cura.CuraApplication import CuraApplication
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
from cura.Settings.GlobalStack import GlobalStack
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
from UM.Settings.ContainerRegistry import ContainerRegistry
class AbstractMachine(GlobalStack):
""" Represents a group of machines of the same type. This allows the user to select settings before selecting a printer. """
def __init__(self, container_id: str) -> None:
super().__init__(container_id)
self.setMetaDataEntry("type", "abstract_machine")
def getMachines(self) -> List[ContainerStack]:
application = CuraApplication.getInstance()
registry = application.getContainerRegistry()
printer_type = self.definition.getId()
return [machine for machine in registry.findContainerStacks(type="machine") if machine.definition.id == printer_type and ConnectionType.CloudConnection in machine.configuredConnectionTypes]
## private:
_abstract_machine_mime = MimeType(
name = "application/x-cura-abstract-machine",
comment = "Cura Abstract Machine",
suffixes = ["global.cfg"]
)
MimeTypeDatabase.addMimeType(_abstract_machine_mime)
ContainerRegistry.addContainerTypeByName(AbstractMachine, "abstract_machine", _abstract_machine_mime.name)