~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/utils.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-12-13 10:17:01 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101213101701-txhhqbzsxw4avnxv
Tags: upstream-2011.1~bzr456
ImportĀ upstreamĀ versionĀ 2011.1~bzr456

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
    return datetime.datetime.strptime(timestr, TIME_FORMAT)
176
176
 
177
177
 
 
178
def parse_mailmap(mailmap='.mailmap'):
 
179
    mapping = {}
 
180
    if os.path.exists(mailmap):
 
181
        fp = open(mailmap, 'r')
 
182
        for l in fp:
 
183
            l = l.strip()
 
184
            if not l.startswith('#') and ' ' in l:
 
185
                canonical_email, alias = l.split(' ')
 
186
                mapping[alias] = canonical_email
 
187
    return mapping
 
188
 
 
189
 
 
190
def str_dict_replace(s, mapping):
 
191
    for s1, s2 in mapping.iteritems():
 
192
        s = s.replace(s1, s2)
 
193
    return s
 
194
 
 
195
 
178
196
class LazyPluggable(object):
179
197
    """A pluggable backend loaded lazily based on some value."""
180
198