-
-
Notifications
You must be signed in to change notification settings - Fork 736
Refactor FilesystemType #4417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Refactor FilesystemType #4417
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| import math | ||
| import uuid | ||
| from dataclasses import dataclass, field | ||
| from enum import Enum | ||
| from enum import Enum, StrEnum, auto | ||
| from pathlib import Path | ||
| from typing import NotRequired, Self, TypedDict, override | ||
| from uuid import UUID | ||
|
|
@@ -131,9 +131,14 @@ def parse_arg( | |
| for partition in entry.get('partitions', []): | ||
| flags = [flag for f in partition.get('flags', []) if (flag := PartitionFlag.from_string(f))] | ||
|
|
||
| if fs_type := partition.get('fs_type'): | ||
| fs_type = FilesystemType(fs_type) | ||
| else: | ||
| fs_type = None | ||
|
|
||
| device_partition = PartitionModification( | ||
| status=ModificationStatus(partition['status']), | ||
| fs_type=FilesystemType(partition['fs_type']) if partition.get('fs_type') else None, | ||
| fs_type=fs_type, | ||
|
Comment on lines
+134
to
+141
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this change mypy produces this error: |
||
| start=Size.parse_args(partition['start']), | ||
| length=Size.parse_args(partition['size']), | ||
| mount_options=partition['mount_options'], | ||
|
|
@@ -200,7 +205,7 @@ def parse_arg( | |
| def has_default_btrfs_vols(self) -> bool: | ||
| for mod in self.device_modifications: | ||
| for part in mod.partitions: | ||
| if not (part.is_create_or_modify() and part.fs_type == FilesystemType.Btrfs): | ||
| if not (part.is_create_or_modify() and part.fs_type == FilesystemType.BTRFS): | ||
| continue | ||
|
|
||
| if any(subvol.is_default_root() for subvol in part.btrfs_subvols): | ||
|
|
@@ -777,38 +782,38 @@ def bytes(self) -> builtins.bytes: | |
| return uuid.UUID(self.value).bytes | ||
|
|
||
|
|
||
| class FilesystemType(Enum): | ||
| Btrfs = 'btrfs' | ||
| Ext2 = 'ext2' | ||
| Ext3 = 'ext3' | ||
| Ext4 = 'ext4' | ||
| F2fs = 'f2fs' | ||
| Fat12 = 'fat12' | ||
| Fat16 = 'fat16' | ||
| Fat32 = 'fat32' | ||
| Ntfs = 'ntfs' | ||
| Xfs = 'xfs' | ||
| LinuxSwap = 'linux-swap' | ||
| class FilesystemType(StrEnum): | ||
| BTRFS = auto() | ||
| EXT2 = auto() | ||
| EXT3 = auto() | ||
| EXT4 = auto() | ||
| F2FS = auto() | ||
| FAT12 = auto() | ||
| FAT16 = auto() | ||
| FAT32 = auto() | ||
| NTFS = auto() | ||
| XFS = auto() | ||
| LINUX_SWAP = 'linux-swap' | ||
|
|
||
| # this is not a FS known to parted, so be careful | ||
| # with the usage from this enum | ||
| Crypto_luks = 'crypto_LUKS' | ||
| CRYPTO_LUKS = 'crypto_LUKS' | ||
|
|
||
| def is_crypto(self) -> bool: | ||
| return self == FilesystemType.Crypto_luks | ||
| return self == FilesystemType.CRYPTO_LUKS | ||
|
|
||
| @property | ||
| def parted_value(self) -> str: | ||
| return self.value + '(v1)' if self == FilesystemType.LinuxSwap else self.value | ||
| return self.value + '(v1)' if self == FilesystemType.LINUX_SWAP else self.value | ||
|
|
||
| @property | ||
| def installation_pkg(self) -> str | None: | ||
| match self: | ||
| case FilesystemType.Btrfs: | ||
| case FilesystemType.BTRFS: | ||
| return 'btrfs-progs' | ||
| case FilesystemType.Xfs: | ||
| case FilesystemType.XFS: | ||
| return 'xfsprogs' | ||
| case FilesystemType.F2fs: | ||
| case FilesystemType.F2FS: | ||
| return 'f2fs-tools' | ||
| case _: | ||
| return None | ||
|
|
@@ -953,7 +958,7 @@ def is_home(self) -> bool: | |
| return False | ||
|
|
||
| def is_swap(self) -> bool: | ||
| return self.fs_type == FilesystemType.LinuxSwap | ||
| return self.fs_type == FilesystemType.LINUX_SWAP | ||
|
|
||
| def is_modify(self) -> bool: | ||
| return self.status == ModificationStatus.Modify | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI there's a helper function
archinstall/archinstall/tui/ui/menu_item.py
Line 147 in bf9b9cb
it was introduced after this was implemented so one day we can move it :)