From 51da23465b7445971f859305974673417585c2d2 Mon Sep 17 00:00:00 2001 From: Antonio Cordero Balcazar Date: Sat, 16 May 2026 20:51:50 +0200 Subject: [PATCH] * Case insensitivity for extranetwork mapping lookup. --- ppp_enmappings.py | 14 ++++++++++++++ ppp_tree.py | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ppp_enmappings.py b/ppp_enmappings.py index 366bf43..d237644 100644 --- a/ppp_enmappings.py +++ b/ppp_enmappings.py @@ -92,6 +92,20 @@ class PPPExtraNetworkMappings: + self.cached_mappings.__sizeof__() ) + def get_mapping(self, key: str) -> PPPENMapping | None: + """ + Get an extra network mapping by key. + + Args: + key (str): The key of the extra network mapping in the format "kind:name". + Returns: + PPPENMapping | None: The extra network mapping if found, or None if not found + """ + for k, v in self.extranetwork_mappings.items(): + if k.lower() == key.lower(): + return v + return None + def refresh_extranetwork_mappings( self, debug_level: DEBUG_LEVEL, diff --git a/ppp_tree.py b/ppp_tree.py index 131ba54..4e502a1 100644 --- a/ppp_tree.py +++ b/ppp_tree.py @@ -1570,13 +1570,13 @@ class TreeProcessor(lark.visitors.Interpreter): compiled_extra_triggers = None if is_mapping: found = self.state.extranetwork_mappings_obj.cached_mappings.get(extnet_id, None) - # we assume the conditions do not change inside the prompt + # we assume the conditions do not change inside the prompt (although they could in some circumstances) found_in_cache = found is not None if found is None: found_mappings: list[PPPENMappingVariant] = [] else_mapping = None if self.state.extranetwork_mappings_obj: - enmapping = self.state.extranetwork_mappings_obj.extranetwork_mappings.get(extnet_id, None) + enmapping = self.state.extranetwork_mappings_obj.get_mapping(extnet_id) if enmapping: for v in enmapping.variants: cond = str(v.condition) if v.condition is not None else None