From 936578f35937eeecd7aa1155f5574f8def58f528 Mon Sep 17 00:00:00 2001 From: Fabian Schindler Date: Thu, 25 Apr 2024 16:04:10 +0200 Subject: [PATCH] Adding a dict class to pass through keys as values --- pygeofilter/util.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pygeofilter/util.py b/pygeofilter/util.py index 06cd2a0..ceceb10 100644 --- a/pygeofilter/util.py +++ b/pygeofilter/util.py @@ -25,6 +25,7 @@ # THE SOFTWARE. # ------------------------------------------------------------------------------ +from collections.abc import Mapping import re from datetime import date, datetime, timedelta @@ -141,3 +142,15 @@ def like_pattern_to_re(like, nocase, wildcard, single_char, escape_char): like_pattern_to_re_pattern(like, wildcard, single_char, escape_char), flags=flags, ) + + +class IdempotentDict(Mapping): + "A dict class that always returns the key" + def __getitem__(self, key): + return key + + def __iter__(self): + return iter(()) + + def __len__(self) -> int: + return 0