@@ -111,6 +111,11 @@ def parse_arg(cls, disk_config: dict[str, Any]) -> DiskLayoutConfiguration | Non
111111 device_partitions : list [PartitionModification ] = []
112112
113113 for partition in entry .get ('partitions' , []):
114+ flags = [
115+ flag for f in partition .get ('flags' , [])
116+ if (flag := PartitionFlag .from_string (f ))
117+ ]
118+
114119 device_partition = PartitionModification (
115120 status = ModificationStatus (partition ['status' ]),
116121 fs_type = FilesystemType (partition ['fs_type' ]) if partition .get ('fs_type' ) else None ,
@@ -120,7 +125,7 @@ def parse_arg(cls, disk_config: dict[str, Any]) -> DiskLayoutConfiguration | Non
120125 mountpoint = Path (partition ['mountpoint' ]) if partition ['mountpoint' ] else None ,
121126 dev_path = Path (partition ['dev_path' ]) if partition ['dev_path' ] else None ,
122127 type = PartitionType (partition ['type' ]),
123- flags = [ PartitionFlag [ f ] for f in partition . get ( ' flags' , [])] ,
128+ flags = flags ,
124129 btrfs_subvols = SubvolumeModification .parse_args (partition .get ('btrfs' , [])),
125130 )
126131 # special 'invisible attr to internally identify the part mod
@@ -388,7 +393,7 @@ def from_partition(
388393 btrfs_subvol_infos : list [_BtrfsSubvolumeInfo ] = []
389394 ) -> _PartitionInfo :
390395 partition_type = PartitionType .get_type_from_code (partition .type )
391- flags = [f for f in PartitionFlag if partition .getFlag (f .value )]
396+ flags = [f for f in PartitionFlag if partition .getFlag (f .flag_id )]
392397
393398 start = Size (
394399 partition .geometry .start ,
@@ -579,11 +584,32 @@ def get_partition_code(self) -> int | None:
579584 return None
580585
581586
582- class PartitionFlag (Enum ):
587+ @dataclass (frozen = True )
588+ class PartitionFlagDataMixin :
589+ flag_id : int
590+ alias : str | None = None
591+
592+
593+ class PartitionFlag (PartitionFlagDataMixin , Enum ):
583594 Boot = parted .PARTITION_BOOT
584- XBOOTLDR = parted .PARTITION_BLS_BOOT # Note: parted calls this bls_boot
595+ XBOOTLDR = parted .PARTITION_BLS_BOOT , " bls_boot"
585596 ESP = parted .PARTITION_ESP
586597
598+ @property
599+ def description (self ) -> str :
600+ return self .alias or self .name .lower ()
601+
602+ @classmethod
603+ def from_string (cls , s : str ) -> PartitionFlag | None :
604+ s = s .lower ()
605+
606+ for partition_flag in cls :
607+ if s in (partition_flag .name .lower (), partition_flag .alias ):
608+ return partition_flag
609+
610+ debug (f'Partition flag not supported: { s } ' )
611+ return None
612+
587613
588614class PartitionGUID (Enum ):
589615 """
@@ -829,7 +855,7 @@ def json(self) -> dict[str, Any]:
829855 'fs_type' : self .fs_type .value if self .fs_type else None ,
830856 'mountpoint' : str (self .mountpoint ) if self .mountpoint else None ,
831857 'mount_options' : self .mount_options ,
832- 'flags' : [f .name for f in self .flags ],
858+ 'flags' : [f .description for f in self .flags ],
833859 'dev_path' : str (self .dev_path ) if self .dev_path else None ,
834860 'btrfs' : [vol .json () for vol in self .btrfs_subvols ]
835861 }
@@ -848,7 +874,7 @@ def table_data(self) -> dict[str, Any]:
848874 'FS type' : self .fs_type .value if self .fs_type else 'Unknown' ,
849875 'Mountpoint' : self .mountpoint if self .mountpoint else '' ,
850876 'Mount options' : ', ' .join (self .mount_options ),
851- 'Flags' : ', ' .join ([f .name for f in self .flags ]),
877+ 'Flags' : ', ' .join ([f .description for f in self .flags ]),
852878 }
853879
854880 if self .btrfs_subvols :
0 commit comments