1234567891011121314151617181920212223242526272829 |
- from dataclasses import dataclass
- from enum import Enum
- class WorkpieceColor(Enum):
- NONE = 'NONE'
- RED = 'RED'
- WHITE = 'WHITE'
- BLUE = 'BLUE'
- @dataclass
- class Workpiece:
- id: str
- color: WorkpieceColor
- state: str = 'raw' # 'raw'
- def __str__(self):
- return f"{type(self).__name__}(id={self.id}, color={self.color.value} state={self.state})"
- def __repr__(self):
- return f"{type(self).__name__}(id={self.id}, color={self.color.value} state={self.state})"
- def to_dict(self) -> dict:
- return {
- "id": self.id,
- "color": self.color.value,
- "state": self.state
- }
|