|
13 | 13 | from pathlib import Path |
14 | 14 | from typing import Any |
15 | 15 |
|
| 16 | +from normalize_provider_branding_pipeline import assert_contract as assert_branding_pipeline_contract |
| 17 | +from normalize_provider_branding_pipeline import normalize as normalize_branding_pipeline |
| 18 | + |
16 | 19 | ROOT = Path(__file__).resolve().parents[1] |
17 | 20 | OVERRIDES = ROOT / "provider-overrides.json" |
18 | 21 | MANIFEST = ROOT / "manifest.json" |
@@ -120,6 +123,14 @@ def normalize_source_files(*, apply: bool) -> list[str]: |
120 | 123 | changed.append("scripts/publish_desktop_runtime_compat.py:provider_specific_target") |
121 | 124 | if apply: |
122 | 125 | DESKTOP_COMPAT.write_text(source.replace(_PURSTREAM_DESKTOP_TARGET, ""), encoding="utf-8") |
| 126 | + |
| 127 | + apply_source = APPLY_OVERRIDES.read_text(encoding="utf-8") |
| 128 | + normalized_apply, branding_changes = normalize_branding_pipeline(apply_source) |
| 129 | + assert_branding_pipeline_contract(normalized_apply) |
| 130 | + if branding_changes: |
| 131 | + changed.extend(f"scripts/apply_provider_overrides.py:{item}" for item in branding_changes) |
| 132 | + if apply: |
| 133 | + APPLY_OVERRIDES.write_text(normalized_apply, encoding="utf-8") |
123 | 134 | return changed |
124 | 135 |
|
125 | 136 |
|
@@ -153,13 +164,12 @@ def _assert_branding_inventory() -> None: |
153 | 164 |
|
154 | 165 | def _assert_branding_pipeline_order() -> None: |
155 | 166 | source = APPLY_OVERRIDES.read_text(encoding="utf-8") |
| 167 | + assert_branding_pipeline_contract(source) |
156 | 168 | presentation = source.find('"scope": "global_stream_presentation"') |
157 | 169 | branding = source.find('"scope": "global_provider_branding"') |
158 | 170 | final_return = source.find(" if text == original_text:", branding) |
159 | 171 | if presentation < 0 or branding < 0 or final_return < 0 or not (presentation < branding < final_return): |
160 | 172 | raise ValueError("provider branding must execute after stream presentation and before final return") |
161 | | - if 'GLOBAL_PROVIDER_BRANDING = "scripts/provider_patches/global_provider_branding_v1.py"' not in source: |
162 | | - raise ValueError("controlled provider branding constant is missing") |
163 | 173 |
|
164 | 174 |
|
165 | 175 | def assert_policy(value: dict[str, Any]) -> None: |
|
0 commit comments