From 187d9ea5e480de6486e4a5c5a43345b0a74ca6bd Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 20 Nov 2026 19:05:35 +0100 Subject: [PATCH] refactor: look regions up through lookup_slot lookup_regions walked the destination, its suffixes and the name again. It now projects the entry lookup_slot finds. No behavior change. --- scripts/resolve/regions.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/scripts/resolve/regions.py b/scripts/resolve/regions.py index cce718132..e94df785e 100644 --- a/scripts/resolve/regions.py +++ b/scripts/resolve/regions.py @@ -72,20 +72,12 @@ def build_region_index(profiles: dict) -> dict[str, dict]: def lookup_regions(index: dict[str, dict], destination: str, name: str) -> set[str]: """Look a candidate file up in the region index. - Tries the full destination, then progressively shorter path suffixes, then - the bare name. Suffix matching bridges a platform entry whose destination - carries an extra prefix to the profile entry that declares the region. + Tried in lookup_slot's order: the full destination, then progressively + shorter path suffixes, then the bare name. Suffix matching bridges a + platform entry whose destination carries an extra prefix to the profile + entry that declares the region. """ - if destination: - entry = index.get(destination) - if entry: - return set() if entry.get("has_untagged") else set(entry["regions"]) - parts = destination.split("/") - for i in range(1, len(parts)): - entry = index.get("/".join(parts[i:])) - if entry: - return set() if entry.get("has_untagged") else set(entry["regions"]) - entry = index.get(name) + entry = lookup_slot(index, destination, name) if not entry or entry.get("has_untagged"): return set() return set(entry["regions"])