diff options
| author | Jason Kölker <jason@koelker.net> | 2011-09-27 17:20:40 -0500 |
|---|---|---|
| committer | Jason Kölker <jason@koelker.net> | 2011-09-27 17:20:40 -0500 |
| commit | 67de41b219b7e3d017de5b654dccdcdfa0c7b81a (patch) | |
| tree | 826a71945d05f99b68edf009165ca62975534ec8 /openstack | |
| parent | f66de377d9a66928e691e10c94baa0b64006805f (diff) | |
| download | oslo-67de41b219b7e3d017de5b654dccdcdfa0c7b81a.tar.gz oslo-67de41b219b7e3d017de5b654dccdcdfa0c7b81a.tar.xz oslo-67de41b219b7e3d017de5b654dccdcdfa0c7b81a.zip | |
pull parse_mailmap str_dict_replace from nova
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/openstack/common/utils.py b/openstack/common/utils.py index 0d2f89e..e431d1f 100644 --- a/openstack/common/utils.py +++ b/openstack/common/utils.py @@ -20,6 +20,7 @@ System-level utilities and helper functions. """ import datetime +import os import sys from openstack.common import exception @@ -87,3 +88,21 @@ def isotime(at=None): def parse_isotime(timestr): return datetime.datetime.strptime(timestr, TIME_FORMAT) + + +def parse_mailmap(mailmap='.mailmap'): + mapping = {} + if os.path.exists(mailmap): + fp = open(mailmap, 'r') + for l in fp: + l = l.strip() + if not l.startswith('#') and ' ' in l: + canonical_email, alias = l.split(' ') + mapping[alias] = canonical_email + return mapping + + +def str_dict_replace(s, mapping): + for s1, s2 in mapping.iteritems(): + s = s.replace(s1, s2) + return s |
