~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Packman
  • Date: 2012-02-01 12:31:53 UTC
  • mto: (6437.23.4 2.5)
  • mto: This revision was merged to the branch mainline in revision 6459.
  • Revision ID: martin.packman@canonical.com-20120201123153-dklmkf7wlurfba26
Add and test osutils._get_home_dir for unicode access to home location across platforms

Show diffs side-by-side

added added

removed removed

Lines of Context:
342
342
        raise errors.BadFilenameEncoding(val, _fs_enc)
343
343
 
344
344
 
 
345
def _posix_get_home_dir():
 
346
    """Get the home directory of the current user as a unicode path"""
 
347
    path = posixpath.expanduser("~")
 
348
    try:
 
349
        return path.decode(_fs_enc)
 
350
    except UnicodeDecodeError:
 
351
        raise errors.BadFilenameEncoding(path, _fs_enc)
 
352
 
 
353
 
345
354
def _posix_getuser_unicode():
346
355
    """Get username from environment or password database as unicode"""
347
356
    name = getpass.getuser()
448
457
pathjoin = os.path.join
449
458
normpath = _posix_normpath
450
459
path_from_environ = _posix_path_from_environ
 
460
_get_home_dir = _posix_get_home_dir
451
461
getuser_unicode = _posix_getuser_unicode
452
462
getcwd = os.getcwdu
453
463
rename = os.rename
511
521
    if f is not None:
512
522
        get_unicode_argv = f
513
523
    path_from_environ = win32utils.get_environ_unicode
 
524
    _get_home_dir = win32utils.get_home_location
514
525
    getuser_unicode = win32utils.get_user_name
515
526
 
516
527
elif sys.platform == 'darwin':