|
2 | 2 | import math |
3 | 3 | import uuid |
4 | 4 | from dataclasses import dataclass, field |
5 | | -from enum import Enum |
| 5 | +from enum import Enum, StrEnum, auto |
6 | 6 | from pathlib import Path |
7 | 7 | from typing import NotRequired, Self, TypedDict, override |
8 | 8 | from uuid import UUID |
@@ -131,9 +131,14 @@ def parse_arg( |
131 | 131 | for partition in entry.get('partitions', []): |
132 | 132 | flags = [flag for f in partition.get('flags', []) if (flag := PartitionFlag.from_string(f))] |
133 | 133 |
|
| 134 | + if fs_type := partition.get('fs_type'): |
| 135 | + fs_type = FilesystemType(fs_type) |
| 136 | + else: |
| 137 | + fs_type = None |
| 138 | + |
134 | 139 | device_partition = PartitionModification( |
135 | 140 | status=ModificationStatus(partition['status']), |
136 | | - fs_type=FilesystemType(partition['fs_type']) if partition.get('fs_type') else None, |
| 141 | + fs_type=fs_type, |
137 | 142 | start=Size.parse_args(partition['start']), |
138 | 143 | length=Size.parse_args(partition['size']), |
139 | 144 | mount_options=partition['mount_options'], |
@@ -777,17 +782,17 @@ def bytes(self) -> builtins.bytes: |
777 | 782 | return uuid.UUID(self.value).bytes |
778 | 783 |
|
779 | 784 |
|
780 | | -class FilesystemType(Enum): |
781 | | - BTRFS = 'btrfs' |
782 | | - EXT2 = 'ext2' |
783 | | - EXT3 = 'ext3' |
784 | | - EXT4 = 'ext4' |
785 | | - F2FS = 'f2fs' |
786 | | - FAT12 = 'fat12' |
787 | | - FAT16 = 'fat16' |
788 | | - FAT32 = 'fat32' |
789 | | - NTFS = 'ntfs' |
790 | | - XFS = 'xfs' |
| 785 | +class FilesystemType(StrEnum): |
| 786 | + BTRFS = auto() |
| 787 | + EXT2 = auto() |
| 788 | + EXT3 = auto() |
| 789 | + EXT4 = auto() |
| 790 | + F2FS = auto() |
| 791 | + FAT12 = auto() |
| 792 | + FAT16 = auto() |
| 793 | + FAT32 = auto() |
| 794 | + NTFS = auto() |
| 795 | + XFS = auto() |
791 | 796 | LINUX_SWAP = 'linux-swap' |
792 | 797 |
|
793 | 798 | # this is not a FS known to parted, so be careful |
|
0 commit comments