-
-
Notifications
You must be signed in to change notification settings - Fork 775
Use declarative summary method for all sub-configs #4739
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
base: master
Are you sure you want to change the base?
Changes from all commits
c66ca3f
0ed4ab7
e75e775
b65f591
6c21490
e96ca1b
303f7f4
ab7e458
015a74b
f2be09c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
| from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration | ||
| from archinstall.lib.models.authentication import AuthenticationConfiguration | ||
| from archinstall.lib.models.bootloader import Bootloader, BootloaderConfiguration | ||
| from archinstall.lib.models.config import SubConfig | ||
| from archinstall.lib.models.config import SubConfig, SummaryLevel | ||
| from archinstall.lib.models.device import DiskEncryption, DiskLayoutConfiguration | ||
| from archinstall.lib.models.locale import LocaleConfiguration | ||
| from archinstall.lib.models.mirrors import MirrorConfiguration | ||
|
|
@@ -95,55 +95,6 @@ class ArchConfigType(StrEnum): | |
| PACMAN_CONFIG = auto() | ||
| CUSTOM_COMMANDS = auto() | ||
|
|
||
| def text(self) -> str: | ||
| match self: | ||
| case ArchConfigType.ARCHINSTALL_LANGUAGE: | ||
| return tr('ArchInstall Language') | ||
| case ArchConfigType.VERSION: | ||
| return tr('Version') | ||
| case ArchConfigType.SCRIPT: | ||
| return tr('Installation Script') | ||
| case ArchConfigType.LOCALE_CONFIG: | ||
| return tr('Locales') | ||
| case ArchConfigType.DISK_CONFIG: | ||
| return tr('Disk configuration') | ||
| case ArchConfigType.PROFILE_CONFIG: | ||
| return tr('Profile') | ||
| case ArchConfigType.MIRROR_CONFIG: | ||
| return tr('Mirrors and repositories') | ||
| case ArchConfigType.NETWORK_CONFIG: | ||
| return tr('Network') | ||
| case ArchConfigType.BOOTLOADER_CONFIG: | ||
| return tr('Bootloader') | ||
| case ArchConfigType.APP_CONFIG: | ||
| return tr('Application') | ||
| case ArchConfigType.AUTH_CONFIG: | ||
| return tr('Authentication') | ||
| case ArchConfigType.SWAP: | ||
| return tr('Swap') | ||
| case ArchConfigType.HOSTNAME: | ||
| return tr('Hostname') | ||
| case ArchConfigType.KERNELS: | ||
| return tr('Kernels') | ||
| case ArchConfigType.NTP: | ||
| return tr('Automatic time sync (NTP)') | ||
| case ArchConfigType.TIMEZONE: | ||
| return tr('Timezone') | ||
| case ArchConfigType.SERVICES: | ||
| return tr('Services') | ||
| case ArchConfigType.PACKAGES: | ||
| return tr('Additional packages') | ||
| case ArchConfigType.PACMAN_CONFIG: | ||
| return tr('Pacman') | ||
| case ArchConfigType.CUSTOM_COMMANDS: | ||
| return tr('Custom commands') | ||
| case ArchConfigType.USERS: | ||
| return tr('Users') | ||
| case ArchConfigType.ROOT_ENC_PASSWORD: | ||
| return tr('Root encrypted password') | ||
| case ArchConfigType.ENCRYPTION_PASSWORD: | ||
| return tr('Disk encryption password') | ||
|
|
||
|
|
||
| USER_CONFIG_FILE: Path = Path('user_configuration.json') | ||
| USER_CREDS_FILE: Path = Path('user_credentials.json') | ||
|
|
@@ -442,7 +393,7 @@ def save_user_creds( | |
| target.write_text(data) | ||
| target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) | ||
|
|
||
| def as_summary(self) -> str: | ||
| def as_summary(self, level: SummaryLevel = SummaryLevel.Basic) -> str: | ||
| """ | ||
| Render a concise two-column summary of the current configuration. | ||
|
|
||
|
|
@@ -451,15 +402,14 @@ def as_summary(self) -> str: | |
| cfg: dict[str, str | list[str] | bool] = {} | ||
|
|
||
| for key, value in self.plain_cfg().items(): | ||
| cfg[key.text()] = value | ||
|
|
||
| for config_type, obj in self.sub_cfg().items(): | ||
| if not hasattr(obj, 'summary'): | ||
| continue | ||
| if isinstance(value, list): | ||
| value = ', '.join(value) | ||
| cfg[key.title()] = value | ||
|
|
||
| summary = obj.summary() | ||
| for sub_config in self.sub_cfg().values(): | ||
| summary = sub_config.summary(level) | ||
|
Contributor
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. The |
||
| if summary: | ||
| cfg[config_type.text()] = summary | ||
| cfg[sub_config.NAME] = summary | ||
|
|
||
| simple_summary = as_key_value_pair(cfg, ignore_empty=True) | ||
|
|
||
|
|
||
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.
Since there is no change to the following, I do not see how
SummaryLevel.Detailedis ever used:master:
archinstall/archinstall/lib/global_menu.py
Line 533 in eba1c1a
pull request branch:
https://github.com/svartkanin/archinstall/blob/f2be09cf8a5b67d373f9f30a1879073f459d5fef/archinstall/lib/global_menu.py#L533
All the code conditional on
levelbeingSummaryLevel.Detailedinsummarymethods will be dead code.