~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
381
381
    return realname, (username + '@' + socket.gethostname())
382
382
 
383
383
 
 
384
def extract_email_address(e):
 
385
    """Return just the address part of an email string.
 
386
    
 
387
    That is just the user@domain part, nothing else. 
 
388
    This part is required to contain only ascii characters.
 
389
    If it can't be extracted, raises an error.
 
390
    
 
391
    >>> extract_email_address('Jane Tester <jane@test.com>')
 
392
    "jane@test.com"
 
393
    """
 
394
    m = re.search(r'[\w+.-]+@[\w+.-]+', e)
 
395
    if not m:
 
396
        raise BzrError("%r doesn't seem to contain "
 
397
                       "a reasonable email address" % e)
 
398
    return m.group(0)