/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 breezy/osutils.py

  • Committer: Breezy landing bot
  • Author(s): Martin
  • Date: 2017-06-10 02:49:30 UTC
  • mfrom: (6677.1.4 py3_bootstrap)
  • Revision ID: breezy.the.bot@gmail.com-20170610024930-enw8wdbjy9s4dtnm
Progress on Python 3 to get TestCaseWithTransport working

Merged from https://code.launchpad.net/~gz/brz/py3_bootstrap/+merge/325439

Show diffs side-by-side

added added

removed removed

Lines of Context:
349
349
def _posix_getuser_unicode():
350
350
    """Get username from environment or password database as unicode"""
351
351
    name = getpass.getuser()
 
352
    if PY3:
 
353
        return name
352
354
    user_encoding = get_user_encoding()
353
355
    try:
354
356
        return name.decode(user_encoding)
994
996
    """
995
997
    s = ''
996
998
    for raw_byte in rand_bytes(num):
997
 
        s += ALNUM[ord(raw_byte) % 36]
 
999
        if not PY3:
 
1000
            s += ALNUM[ord(raw_byte) % 36]
 
1001
        else:
 
1002
            s += ALNUM[raw_byte % 36]
998
1003
    return s
999
1004
 
1000
1005
 
1106
1111
 
1107
1112
    This supports Unicode or plain string objects.
1108
1113
    """
1109
 
    lines = s.split('\n')
1110
 
    result = [line + '\n' for line in lines[:-1]]
 
1114
    nl = b'\n' if isinstance(s, bytes) else u'\n'
 
1115
    lines = s.split(nl)
 
1116
    result = [line + nl for line in lines[:-1]]
1111
1117
    if lines[-1]:
1112
1118
        result.append(lines[-1])
1113
1119
    return result
2038
2044
        return win32utils.get_host_name()
2039
2045
    else:
2040
2046
        import socket
 
2047
        if PY3:
 
2048
            return socket.gethostname()
2041
2049
        return socket.gethostname().decode(get_user_encoding())
2042
2050
 
2043
2051