| 754 | |
| 755 | |
| 756 | class PartitionType(StrEnum): |
| 757 | BOOT = auto() |
| 758 | PRIMARY = auto() |
| 759 | _UNKNOWN = 'unknown' |
| 760 | |
| 761 | @classmethod |
| 762 | def get_type_from_code(cls, code: int) -> Self: |
| 763 | if code == parted.PARTITION_NORMAL: |
| 764 | return cls.PRIMARY |
| 765 | else: |
| 766 | debug(f'Partition code not supported: {code}') |
| 767 | return cls._UNKNOWN |
| 768 | |
| 769 | def get_partition_code(self) -> int | None: |
| 770 | if self == PartitionType.PRIMARY: |
| 771 | return parted.PARTITION_NORMAL |
| 772 | elif self == PartitionType.BOOT: |
| 773 | return parted.PARTITION_BOOT |
| 774 | return None |
| 775 | |
| 776 | |
| 777 | @dataclass(frozen=True) |