~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Vincent Ladeuil
  • Date: 2009-04-16 16:57:28 UTC
  • mto: (4331.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4332.
  • Revision ID: v.ladeuil+lp@free.fr-20090416165728-lnobbei6iew38g2d
Test and implements osutils.readlink().

* bzrlib/tests/test_osutils.py:
(TestDirReader.test_symlink): Fix typo.
(TestReadLink): Explain the need for osutils.readlink().

* bzrlib/osutils.py:
(readlink): Reliable version handling unicode paths only.

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