# HG changeset patch # User Sean Farley # Date 1395678060 18000 # Node ID 77594c88d91f7b414aff01fc289f6ad86a820218 # Parent 53184be1b1fdb3334b3a90e2e89da75e0cf8f403 maps: add custom get method Similar to dict.get, except we use our own matching function. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -60,6 +60,12 @@ class BaseMap(dict): return regex return None + def get(self, key, default=None): + '''Similar to dict.get, except we use our own matcher, _findkey.''' + if self._findkey(key): + return self[key] + return default + def load(self, path): '''Load mappings from a file at the specified path.''' path = os.path.expandvars(path)