Mercurial > hgsubversion
changeset 1399:3b96075bffa7
maps: add custom __contains__
Similar to dict.__contains__ except we our own matching function, _findkey.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 11:21:01 -0500 |
parents | 75745298d99d |
children | 3e264851f879 |
files | hgsubversion/maps.py |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -94,6 +94,10 @@ class BaseMap(dict): key = re.compile(re.escape(key)) super(BaseMap, self).__setitem__(key, value) + def __contains__(self, key): + '''Similar to dict.get, except we use our own matcher, _findkey.''' + return self._findkey(key) is not None + def load(self, path): '''Load mappings from a file at the specified path.''' path = os.path.expandvars(path)