# HG changeset patch -- Bitbucket.org # Project pylib # URL http://bitbucket.org/hpk42/pylib/overview # User holger krekel <hol...@merlinux.eu> # Date 1290425642 -3600 # Node ID 7799c5a50b52b28ebcf1eb543c97d790ec53db4f # Parent eaeb7575fbcf599a10741528a3f000a01125e58a fix samefile() impl on windows
--- a/py/_path/local.py +++ b/py/_path/local.py @@ -68,10 +68,6 @@ class PosixPath(common.PathBase): target = self.sep.join(('..', )*n + (relsource, )) py.error.checked_call(os.symlink, target, self.strpath) - def samefile(self, other): - """ return True if other refers to the same stat object as self. """ - return py.error.checked_call(os.path.samefile, str(self), str(other)) - def getuserid(user): import pwd if not isinstance(user, int): @@ -160,6 +156,14 @@ class LocalPath(FSBase): def __lt__(self, other): return str(self) < str(other) + def samefile(self, other): + """ return True if 'other' references the same file as 'self'. """ + if self == other: + return True + if not iswin32: + return py.error.checked_call(os.path.samefile, str(self), str(other)) + return False + def remove(self, rec=1, ignore_errors=False): """ remove a file or directory (or a directory tree if rec=1). if ignore_errors is True, errors while removing directories will --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ def main(): long_description = open('README.txt').read(), install_requires=['py>=1.3.9', ], # force newer py version which removes 'py' namespace # # so we can occupy it - version='2.0.0.dev7', + version='2.0.0.dev8', url='http://pylib.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], --- a/testing/path/test_local.py +++ b/testing/path/test_local.py @@ -420,6 +420,10 @@ def test_samefile(tmpdir): assert tmpdir.samefile(tmpdir) p = tmpdir.ensure("hello") assert p.samefile(p) + if sys.platform == "win32": + p1 = p.__class__(str(p).lower()) + p2 = p.__class__(str(p).upper()) + assert p1.samefile(p2) def test_mkdtemp_rootdir(tmpdir): dtmp = local.mkdtemp(rootdir=tmpdir) --- a/py/__init__.py +++ b/py/__init__.py @@ -8,7 +8,7 @@ dictionary or an import path. (c) Holger Krekel and others, 2004-2010 """ -__version__ = '2.0.0.dev7' +__version__ = '2.0.0.dev8' from py import _apipkg _______________________________________________ py-svn mailing list py-svn@codespeak.net http://codespeak.net/mailman/listinfo/py-svn