mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-19 03:47:29 +08:00
Use simple models instead of namedtuples
Named tuples would throw a TypeError if an unknown attribute was set, but we just want to ignore those
This commit is contained in:
parent
59510487fa
commit
68a90ec510
@ -1,33 +1,42 @@
|
|||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2018 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
ClusterMaterial = namedtuple("ClusterMaterial", [
|
|
||||||
"guid", # Type: str
|
|
||||||
"material", # Type: str
|
|
||||||
"brand", # Type: str
|
|
||||||
"version", # Type: int
|
|
||||||
"color", # Type: str
|
|
||||||
"density" # Type: str
|
|
||||||
])
|
|
||||||
|
|
||||||
LocalMaterial = namedtuple("LocalMaterial", [
|
## Base model that maps kwargs to instance attributes.
|
||||||
"GUID", # Type: str
|
class BaseModel:
|
||||||
"id", # Type: str
|
def __init__(self, **kwargs):
|
||||||
"type", # Type: str
|
self.__dict__.update(kwargs)
|
||||||
"status", # Type: str
|
|
||||||
"base_file", # Type: str
|
|
||||||
"setting_version", # Type: int
|
## Class representing a material that was fetched from the cluster API.
|
||||||
"version", # Type: int
|
class ClusterMaterial(BaseModel):
|
||||||
"name", # Type: str
|
def __init__(self, **kwargs):
|
||||||
"brand", # Type: str
|
self.guid = None # type: str
|
||||||
"material", # Type: str
|
self.material = None # type: str
|
||||||
"color_name", # Type: str
|
self.brand = None # type: str
|
||||||
"color_code", # Type: str
|
self.version = None # type: int
|
||||||
"description", # Type: str
|
self.color = None # type: str
|
||||||
"adhesion_info", # Type: str
|
self.density = None # type: str
|
||||||
"approximate_diameter", # Type: str
|
super().__init__(**kwargs)
|
||||||
"properties", # Type: str
|
|
||||||
"definition", # Type: str
|
|
||||||
"compatible" # Type: str
|
## Class representing a local material that was fetched from the container registry.
|
||||||
])
|
class LocalMaterial(BaseModel):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
self.GUID = None # type: str
|
||||||
|
self.id = None # type: str
|
||||||
|
self.type = None # type: str
|
||||||
|
self.status = None # type: str
|
||||||
|
self.base_file = None # type: str
|
||||||
|
self.setting_version = None # type: int
|
||||||
|
self.version = None # type: int
|
||||||
|
self.brand = None # type: str
|
||||||
|
self.material = None # type: str
|
||||||
|
self.color_name = None # type: str
|
||||||
|
self.color_code = None # type: str
|
||||||
|
self.description = None # type: str
|
||||||
|
self.adhesion_info = None # type: str
|
||||||
|
self.approximate_diameter = None # type: str
|
||||||
|
self.definition = None # type: str
|
||||||
|
self.compatible = None # type: bool
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user