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.
|
||||
# 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", [
|
||||
"GUID", # Type: str
|
||||
"id", # Type: str
|
||||
"type", # Type: str
|
||||
"status", # Type: str
|
||||
"base_file", # Type: str
|
||||
"setting_version", # Type: int
|
||||
"version", # Type: int
|
||||
"name", # Type: str
|
||||
"brand", # Type: str
|
||||
"material", # Type: str
|
||||
"color_name", # Type: str
|
||||
"color_code", # Type: str
|
||||
"description", # Type: str
|
||||
"adhesion_info", # Type: str
|
||||
"approximate_diameter", # Type: str
|
||||
"properties", # Type: str
|
||||
"definition", # Type: str
|
||||
"compatible" # Type: str
|
||||
])
|
||||
## Base model that maps kwargs to instance attributes.
|
||||
class BaseModel:
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update(kwargs)
|
||||
|
||||
|
||||
## Class representing a material that was fetched from the cluster API.
|
||||
class ClusterMaterial(BaseModel):
|
||||
def __init__(self, **kwargs):
|
||||
self.guid = None # type: str
|
||||
self.material = None # type: str
|
||||
self.brand = None # type: str
|
||||
self.version = None # type: int
|
||||
self.color = None # type: str
|
||||
self.density = None # type: str
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
## 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