/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Robert Collins
  • Date: 2008-02-13 03:30:01 UTC
  • mfrom: (3221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3224.
  • Revision ID: robertc@robertcollins.net-20080213033001-rw70ul0zb02ph856
Merge to fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
    urlutils,
85
85
    win32utils,
86
86
    )
87
 
import bzrlib.util.configobj.configobj as configobj
 
87
from bzrlib.util.configobj import configobj
88
88
""")
89
89
 
90
90
 
759
759
        if base is None:
760
760
            base = os.environ.get('HOME', None)
761
761
        if base is None:
762
 
            raise errors.BzrError('You must have one of BZR_HOME, APPDATA, or HOME set')
 
762
            raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
 
763
                                  ' or HOME set')
763
764
        return osutils.pathjoin(base, 'bazaar', '2.0')
764
765
    else:
765
766
        # cygwin, linux, and darwin all have a $HOME directory
861
862
    return realname, (username + '@' + socket.gethostname())
862
863
 
863
864
 
 
865
def parse_username(username):
 
866
    """Parse e-mail username and return a (name, address) tuple."""
 
867
    match = re.match(r'(.*?)\s*<?([\w+.-]+@[\w+.-]+)>?', username)
 
868
    if match is None:
 
869
        return (username, '')
 
870
    else:
 
871
        return (match.group(1), match.group(2))
 
872
 
 
873
 
864
874
def extract_email_address(e):
865
875
    """Return just the address part of an email string.
866
 
    
 
876
 
867
877
    That is just the user@domain part, nothing else. 
868
878
    This part is required to contain only ascii characters.
869
879
    If it can't be extracted, raises an error.
870
 
    
 
880
 
871
881
    >>> extract_email_address('Jane Tester <jane@test.com>')
872
882
    "jane@test.com"
873
883
    """
874
 
    m = re.search(r'[\w+.-]+@[\w+.-]+', e)
875
 
    if not m:
 
884
    name, email = parse_username(e)
 
885
    if not email:
876
886
        raise errors.NoEmailInUsername(e)
877
 
    return m.group(0)
 
887
    return email
878
888
 
879
889
 
880
890
class TreeConfig(IniBasedConfig):