Mercurial > hgsubversion
changeset 1396:77594c88d91f
maps: add custom get method
Similar to dict.get, except we use our own matching function.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 11:21:00 -0500 |
parents | 53184be1b1fd |
children | 304fdb9810a6 |
files | hgsubversion/maps.py |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)