Skip to content

Commit ab5ca9c

Browse files
committed
core: materialize branding pipeline through Core normalizer
1 parent 26397f9 commit ab5ca9c

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

scripts/normalize_core_media_policy.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from pathlib import Path
1414
from typing import Any
1515

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+
1619
ROOT = Path(__file__).resolve().parents[1]
1720
OVERRIDES = ROOT / "provider-overrides.json"
1821
MANIFEST = ROOT / "manifest.json"
@@ -120,6 +123,14 @@ def normalize_source_files(*, apply: bool) -> list[str]:
120123
changed.append("scripts/publish_desktop_runtime_compat.py:provider_specific_target")
121124
if apply:
122125
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")
123134
return changed
124135

125136

@@ -153,13 +164,12 @@ def _assert_branding_inventory() -> None:
153164

154165
def _assert_branding_pipeline_order() -> None:
155166
source = APPLY_OVERRIDES.read_text(encoding="utf-8")
167+
assert_branding_pipeline_contract(source)
156168
presentation = source.find('"scope": "global_stream_presentation"')
157169
branding = source.find('"scope": "global_provider_branding"')
158170
final_return = source.find(" if text == original_text:", branding)
159171
if presentation < 0 or branding < 0 or final_return < 0 or not (presentation < branding < final_return):
160172
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")
163173

164174

165175
def assert_policy(value: dict[str, Any]) -> None:

0 commit comments

Comments
 (0)