(
browser_name: str = "None",
browser_package: str = "",
include_browser_install: bool = False,
preset_key: str = step_catalog.STANDARD_PRESET_KEY,
)
| 99 | |
| 100 | |
| 101 | def build_install_plan( |
| 102 | browser_name: str = "None", |
| 103 | browser_package: str = "", |
| 104 | include_browser_install: bool = False, |
| 105 | preset_key: str = step_catalog.STANDARD_PRESET_KEY, |
| 106 | ) -> dict: |
| 107 | preset = step_catalog.preset_by_key(preset_key) |
| 108 | preset_plan = copy_metadata_value(preset.get("plan", {})) |
| 109 | preset_items = {} |
| 110 | for raw in preset_plan.get("items", []): |
| 111 | if isinstance(raw, dict) and str(raw.get("key", "")).strip(): |
| 112 | preset_items[str(raw.get("key", "")).strip()] = raw |
| 113 | items = [] |
| 114 | for slug in step_catalog.BOOL_OPTION_SLUGS + step_catalog.STEP_SLUGS: |
| 115 | raw_item = preset_items.get(slug, {}) |
| 116 | enabled = bool(raw_item.get("enabled", False if slug in step_catalog.BOOL_OPTION_SLUGS else True)) |
| 117 | item = { |
| 118 | "key": slug, |
| 119 | "text": str(raw_item.get("text", "")), |
| 120 | "tooltip": str(raw_item.get("tooltip", "")), |
| 121 | "enabled": enabled, |
| 122 | } |
| 123 | if slug == "browser-installation": |
| 124 | item["enabled"] = bool(include_browser_install and enabled) |
| 125 | items.append(item) |
| 126 | winutil_config = copy_metadata_value(preset_plan.get("winutil_config", step_catalog.default_winutil_config())) |
| 127 | win11debloat_args = copy_metadata_value(preset_plan.get("win11debloat_args", step_catalog.default_win11debloat_args_text())) |
| 128 | if isinstance(win11debloat_args, list): |
| 129 | win11debloat_args = " ".join([str(v).strip() for v in win11debloat_args if str(v).strip()]) |
| 130 | registry_changes = copy_metadata_value(preset_plan.get("registry_changes", None)) |
| 131 | if registry_changes is None: |
| 132 | registry_changes = default_registry_changes() |
| 133 | return { |
| 134 | "version": INSTALL_PLAN_VERSION, |
| 135 | "selected_preset_key": str(preset.get("key", step_catalog.STANDARD_PRESET_KEY)), |
| 136 | "selected_browser_name": browser_name, |
| 137 | "selected_browser_package": browser_package, |
| 138 | "include_browser_install": is_item_enabled({"items": items}, "browser-installation"), |
| 139 | "items": items, |
| 140 | "winutil_config": winutil_config, |
| 141 | "win11debloat_args": normalize_win11debloat_args_text(win11debloat_args), |
| 142 | "registry_changes": registry_changes, |
| 143 | "applied_background_path": str(preset_plan.get("applied_background_path", "")).strip(), |
| 144 | } |
| 145 | |
| 146 | |
| 147 | def normalize_item(item) -> dict: |
no test coverage detected