~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-05 19:55:59 UTC
  • mfrom: (4331.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090505195559-0qmeyyua7e407sym
(vila) Parametrize tests against dir readers and fix some unicode
        symlink latent bugs

Show diffs side-by-side

added added

removed removed

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