mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
STAR-322: Fixing style errors
This commit is contained in:
parent
7668801564
commit
d54fc4182b
15 changed files with 69 additions and 72 deletions
|
@ -1,7 +1,7 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from datetime import datetime, timezone
|
||||
from typing import Dict, Union, TypeVar, Type, List
|
||||
from typing import Dict, Union, TypeVar, Type, List, Any
|
||||
|
||||
from ...Models import BaseModel
|
||||
|
||||
|
@ -21,7 +21,7 @@ class BaseCloudModel(BaseModel):
|
|||
return type(self) != type(other) or self.toDict() != other.toDict()
|
||||
|
||||
## Converts the model into a serializable dictionary
|
||||
def toDict(self) -> Dict[str, any]:
|
||||
def toDict(self) -> Dict[str, Any]:
|
||||
return self.__dict__
|
||||
|
||||
# Type variable used in the parse methods below, which should be a subclass of BaseModel.
|
||||
|
@ -32,7 +32,7 @@ class BaseCloudModel(BaseModel):
|
|||
# \param values: The value of the model, which is usually a dictionary, but may also be already parsed.
|
||||
# \return An instance of the model_class given.
|
||||
@staticmethod
|
||||
def parseModel(model_class: Type[T], values: Union[T, Dict[str, any]]) -> T:
|
||||
def parseModel(model_class: Type[T], values: Union[T, Dict[str, Any]]) -> T:
|
||||
if isinstance(values, dict):
|
||||
return model_class(**values)
|
||||
return values
|
||||
|
@ -42,7 +42,7 @@ class BaseCloudModel(BaseModel):
|
|||
# \param values: The value of the list. Each value is usually a dictionary, but may also be already parsed.
|
||||
# \return A list of instances of the model_class given.
|
||||
@classmethod
|
||||
def parseModels(cls, model_class: Type[T], values: List[Union[T, Dict[str, any]]]) -> List[T]:
|
||||
def parseModels(cls, model_class: Type[T], values: List[Union[T, Dict[str, Any]]]) -> List[T]:
|
||||
return [cls.parseModel(model_class, value) for value in values]
|
||||
|
||||
## Parses the given date string.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import List, Optional, Union, Dict
|
||||
from typing import List, Optional, Union, Dict, Any
|
||||
|
||||
from cura.PrinterOutput.ConfigurationModel import ConfigurationModel
|
||||
from plugins.UM3NetworkPrinting.src.Cloud.CloudOutputController import CloudOutputController
|
||||
|
@ -36,12 +36,12 @@ class CloudClusterPrintJobStatus(BaseCloudModel):
|
|||
# \param uuid: UUID of this print job. Should be used for identification purposes.
|
||||
def __init__(self, created_at: str, force: bool, machine_variant: str, name: str, started: bool, status: str,
|
||||
time_total: int, uuid: str,
|
||||
configuration: List[Union[Dict[str, any], CloudClusterPrinterConfiguration]],
|
||||
constraints: List[Union[Dict[str, any], CloudClusterPrintJobConstraints]],
|
||||
configuration: List[Union[Dict[str, Any], CloudClusterPrinterConfiguration]],
|
||||
constraints: List[Union[Dict[str, Any], CloudClusterPrintJobConstraints]],
|
||||
last_seen: Optional[float] = None, network_error_count: Optional[int] = None,
|
||||
owner: Optional[str] = None, printer_uuid: Optional[str] = None, time_elapsed: Optional[int] = None,
|
||||
assigned_to: Optional[str] = None, **kwargs) -> None:
|
||||
self.assigned_to = assigned_to # type: str
|
||||
self.assigned_to = assigned_to
|
||||
self.configuration = self.parseModels(CloudClusterPrinterConfiguration, configuration)
|
||||
self.constraints = self.parseModels(CloudClusterPrintJobConstraints, constraints)
|
||||
self.created_at = created_at
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import Union, Dict, Optional
|
||||
from typing import Union, Dict, Optional, Any
|
||||
|
||||
from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel
|
||||
from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel
|
||||
|
@ -17,10 +17,10 @@ class CloudClusterPrinterConfiguration(BaseCloudModel):
|
|||
# \param nozzle_diameter: The diameter of the print core at this position in millimeters, e.g. '0.4'.
|
||||
# \param print_core_id: The type of print core inserted at this position, e.g. 'AA 0.4'.
|
||||
def __init__(self, extruder_index: int,
|
||||
material: Union[None, Dict[str, any], CloudClusterPrinterConfigurationMaterial],
|
||||
material: Union[None, Dict[str, Any], CloudClusterPrinterConfigurationMaterial],
|
||||
nozzle_diameter: Optional[str] = None, print_core_id: Optional[str] = None, **kwargs) -> None:
|
||||
self.extruder_index = extruder_index
|
||||
self.material = self.parseModel(CloudClusterPrinterConfigurationMaterial, material)
|
||||
self.material = self.parseModel(CloudClusterPrinterConfigurationMaterial, material) if material else None
|
||||
self.nozzle_diameter = nozzle_diameter
|
||||
self.print_core_id = print_core_id
|
||||
super().__init__(**kwargs)
|
||||
|
@ -28,11 +28,16 @@ class CloudClusterPrinterConfiguration(BaseCloudModel):
|
|||
## Updates the given output model.
|
||||
# \param model - The output model to update.
|
||||
def updateOutputModel(self, model: ExtruderOutputModel) -> None:
|
||||
model.updateHotendID(self.print_core_id)
|
||||
if self.print_core_id is not None:
|
||||
model.updateHotendID(self.print_core_id)
|
||||
|
||||
if model.activeMaterial is None or model.activeMaterial.guid != self.material.guid:
|
||||
material = self.material.createOutputModel()
|
||||
model.updateActiveMaterial(material)
|
||||
if self.material:
|
||||
active_material = model.activeMaterial
|
||||
if active_material is None or active_material.guid != self.material.guid:
|
||||
material = self.material.createOutputModel()
|
||||
model.updateActiveMaterial(material)
|
||||
else:
|
||||
model.updateActiveMaterial(None)
|
||||
|
||||
## Creates a configuration model
|
||||
def createConfigurationModel(self) -> ExtruderConfigurationModel:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import List, Union, Dict, Optional
|
||||
from typing import List, Union, Dict, Optional, Any
|
||||
|
||||
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
|
||||
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
|
||||
|
@ -24,7 +24,7 @@ class CloudClusterPrinterStatus(BaseCloudModel):
|
|||
# \param reserved_by: A printer can be claimed by a specific print job.
|
||||
def __init__(self, enabled: bool, firmware_version: str, friendly_name: str, ip_address: str, machine_variant: str,
|
||||
status: str, unique_name: str, uuid: str,
|
||||
configuration: List[Union[Dict[str, any], CloudClusterPrinterConfiguration]],
|
||||
configuration: List[Union[Dict[str, Any], CloudClusterPrinterConfiguration]],
|
||||
reserved_by: Optional[str] = None, **kwargs) -> None:
|
||||
|
||||
self.configuration = self.parseModels(CloudClusterPrinterConfiguration, configuration)
|
||||
|
|
|
@ -16,7 +16,7 @@ class CloudClusterResponse(BaseCloudModel):
|
|||
# \param status: The status of the cluster authentication (active or inactive).
|
||||
# \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on.
|
||||
def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str,
|
||||
host_version: Optional[str] = None, **kwargs):
|
||||
host_version: Optional[str] = None, **kwargs) -> None:
|
||||
self.cluster_id = cluster_id
|
||||
self.host_guid = host_guid
|
||||
self.host_name = host_name
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from datetime import datetime
|
||||
from typing import List, Dict, Union
|
||||
from typing import List, Dict, Union, Any
|
||||
|
||||
from .CloudClusterPrinterStatus import CloudClusterPrinterStatus
|
||||
from .CloudClusterPrintJobStatus import CloudClusterPrintJobStatus
|
||||
|
@ -16,8 +16,8 @@ class CloudClusterStatus(BaseCloudModel):
|
|||
# \param print_jobs: The latest status of each print job in the cluster.
|
||||
# \param generated_time: The datetime when the object was generated on the server-side.
|
||||
def __init__(self,
|
||||
printers: List[Union[CloudClusterPrinterStatus, Dict[str, any]]],
|
||||
print_jobs: List[Union[CloudClusterPrintJobStatus, Dict[str, any]]],
|
||||
printers: List[Union[CloudClusterPrinterStatus, Dict[str, Any]]],
|
||||
print_jobs: List[Union[CloudClusterPrintJobStatus, Dict[str, Any]]],
|
||||
generated_time: Union[str, datetime],
|
||||
**kwargs) -> None:
|
||||
self.generated_time = self.parseDate(generated_time)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import Dict, Optional
|
||||
from typing import Dict, Optional, Any
|
||||
|
||||
from .BaseCloudModel import BaseCloudModel
|
||||
|
||||
|
@ -18,7 +18,7 @@ class CloudErrorObject(BaseCloudModel):
|
|||
# \param http_status: The HTTP status code applicable to this problem, converted to string.
|
||||
# \param meta: Non-standard meta-information about the error, depending on the error code.
|
||||
def __init__(self, id: str, code: str, title: str, http_status: str, detail: Optional[str] = None,
|
||||
meta: Optional[Dict[str, any]] = None, **kwargs) -> None:
|
||||
meta: Optional[Dict[str, Any]] = None, **kwargs) -> None:
|
||||
self.id = id
|
||||
self.code = code
|
||||
self.http_status = http_status
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue