summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/utils.py19
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