~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Johan Walles
  • Date: 2009-05-06 05:36:28 UTC
  • mfrom: (4332 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4343.
  • Revision ID: johan.walles@gmail.com-20090506053628-tbf1wz4a0m9t684g
MergeĀ fromĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
933
933
            and sys.platform not in ('cygwin', 'win32'))
934
934
 
935
935
 
 
936
def readlink(abspath):
 
937
    """Return a string representing the path to which the symbolic link points.
 
938
 
 
939
    :param abspath: The link absolute unicode path.
 
940
 
 
941
    This his guaranteed to return the symbolic link in unicode in all python
 
942
    versions.
 
943
    """
 
944
    link = abspath.encode(_fs_enc)
 
945
    target = os.readlink(link)
 
946
    target = target.decode(_fs_enc)
 
947
    return target
 
948
 
 
949
 
936
950
def contains_whitespace(s):
937
951
    """True if there are any whitespace characters in s."""
938
952
    # string.whitespace can include '\xa0' in certain locales, because it is
1400
1414
            #       for win98 anyway.
1401
1415
            try:
1402
1416
                from bzrlib._walkdirs_win32 import Win32ReadDir
1403
 
            except ImportError:
1404
 
                _selected_dir_reader = UnicodeDirReader()
1405
 
            else:
1406
1417
                _selected_dir_reader = Win32ReadDir()
1407
 
        elif fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968'):
 
1418
            except ImportError:
 
1419
                pass
 
1420
        elif fs_encoding in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968'):
1408
1421
            # ANSI_X3.4-1968 is a form of ASCII
1409
 
            _selected_dir_reader = UnicodeDirReader()
1410
 
        else:
1411
1422
            try:
1412
1423
                from bzrlib._readdir_pyx import UTF8DirReader
1413
 
            except ImportError:
1414
 
                # No optimised code path
1415
 
                _selected_dir_reader = UnicodeDirReader()
1416
 
            else:
1417
1424
                _selected_dir_reader = UTF8DirReader()
 
1425
            except ImportError:
 
1426
                pass
 
1427
 
 
1428
    if _selected_dir_reader is None:
 
1429
        # Fallback to the python version
 
1430
        _selected_dir_reader = UnicodeDirReader()
 
1431
 
1418
1432
    # 0 - relpath, 1- basename, 2- kind, 3- stat, 4-toppath
1419
1433
    # But we don't actually uses 1-3 in pending, so set them to None
1420
1434
    pending = [[_selected_dir_reader.top_prefix_to_starting_dir(top, prefix)]]