diff options
| author | Soren Hansen <soren.hansen@rackspace.com> | 2010-11-29 13:14:26 +0100 |
|---|---|---|
| committer | Soren Hansen <soren.hansen@rackspace.com> | 2010-11-29 13:14:26 +0100 |
| commit | c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f (patch) | |
| tree | 15a73446e1daa6829a68e05a3cef862924428473 /nova/utils.py | |
| parent | b65b41e5957d5ded516343b3611292c9744d169f (diff) | |
| parent | 4f92d1d39fcfda4dad73e6e0339351f0d7d00d61 (diff) | |
| download | nova-c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f.tar.gz nova-c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f.tar.xz nova-c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f.zip | |
Merge trunk.
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py index e7892a212..142584df8 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -21,6 +21,7 @@ System-level utilities and helper functions. """ import datetime +import functools import inspect import logging import os @@ -174,6 +175,24 @@ 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 + + class LazyPluggable(object): """A pluggable backend loaded lazily based on some value.""" |
