Rev 3516: A couple small cleanups, make test_osutils more correct in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/win32_find_files
John Arbash Meinel
john at arbash-meinel.com
Thu Jul 17 05:50:03 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/win32_find_files
------------------------------------------------------------
revno: 3516
revision-id: john at arbash-meinel.com-20080717044957-xokssio0q76zy0q3
parent: john at arbash-meinel.com-20080717043518-c1ncnoygo3ppew2f
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: win32_find_files
timestamp: Wed 2008-07-16 23:49:57 -0500
message:
A couple small cleanups, make test_osutils more correct
-------------- next part --------------
=== modified file 'bzrlib/_walkdirs_win32.pyx'
--- a/bzrlib/_walkdirs_win32.pyx 2008-07-17 04:35:18 +0000
+++ b/bzrlib/_walkdirs_win32.pyx 2008-07-17 04:49:57 +0000
@@ -176,6 +176,11 @@
def __iter__(self):
return self
+ cdef object _get_kind(self, WIN32_FIND_DATAW *data):
+ if data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY:
+ return self._directory_kind
+ return self._file_kind
+
cdef _Win32Stat _get_stat_value(self, WIN32_FIND_DATAW *data):
"""Get the filename and the stat information."""
cdef _Win32Stat statvalue
@@ -190,11 +195,6 @@
statvalue.st_dev = 0
return statvalue
- cdef object _get_kind(self, WIN32_FIND_DATAW *data):
- if data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY:
- return self._directory_kind
- return self._file_kind
-
def _get_files_in(self, directory, relprefix):
cdef WIN32_FIND_DATAW search_data
cdef HANDLE hFindFile
@@ -219,7 +219,7 @@
if _should_skip(&search_data):
result = FindNextFileW(hFindFile, &search_data)
continue
- name_unicode = self._get_name(&search_data)
+ name_unicode = _get_name(&search_data)
name_utf8 = PyUnicode_AsUTF8String(name_unicode)
relpath = relprefix + name_utf8
abspath = directory + name_unicode
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2008-07-17 02:21:33 +0000
+++ b/bzrlib/osutils.py 2008-07-17 04:49:57 +0000
@@ -1283,8 +1283,8 @@
Because Win32 has a Unicode api, all of the 'path-from-top' entries will be
Unicode paths.
"""
- from bzrlib._walkdirs_win32 import _walkdirs_utf8_win32_find_file as wd
- return wd(top, prefix=prefix)
+ from bzrlib._walkdirs_win32 import Win32Finder
+ return Win32Finder(top, prefix=prefix)
def copy_tree(from_path, to_path, handlers={}):
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2008-07-17 02:37:13 +0000
+++ b/bzrlib/tests/test_osutils.py 2008-07-17 04:49:57 +0000
@@ -16,6 +16,7 @@
"""Tests for the osutils wrapper."""
+from cStringIO import StringIO
import errno
import os
import socket
@@ -48,38 +49,7 @@
from bzrlib.tests.file_utils import (
FakeReadFile,
)
-from cStringIO import StringIO
-
-
-class _Win32FileFeature(tests.Feature):
- """Test if win32file is available."""
-
- def _probe(self):
- try:
- import win32file
- except ImportError:
- return False
- else:
- return True
-
- def feature_name(self):
- return 'win32file'
-
-Win32FileFeature = _Win32FileFeature()
-
-
-class TestWin32FileFeature(tests.TestCase):
-
- def test_is_correct(self):
- try:
- import win32file
- except ImportError:
- self.assertFalse(Win32FileFeature.available())
- else:
- self.assertTrue(Win32FileFeature.available())
-
- def test_name(self):
- self.assertTrue('win32file' in str(Win32FileFeature))
+from bzrlib.tests.test__walkdirs_win32 import WalkdirsWin32Feature
class TestOSUtils(TestCaseInTempDir):
@@ -1009,7 +979,7 @@
self.assertEqual(expected_dirblocks, result)
def test__walkdirs_utf_win32_find_file(self):
- self.requireFeature(Win32FileFeature)
+ self.requireFeature(WalkdirsWin32Feature)
self.requireFeature(tests.UnicodeFilenameFeature)
name0u = u'0file-\xb6'
name1u = u'1dir-\u062c\u0648'
@@ -1063,7 +1033,7 @@
def test__walkdirs_utf_win32_find_file_stat_file(self):
"""make sure our Stat values are valid"""
- self.requireFeature(Win32FileFeature)
+ self.requireFeature(WalkdirsWin32Feature)
self.requireFeature(tests.UnicodeFilenameFeature)
name0u = u'0file-\xb6'
name0 = name0u.encode('utf8')
@@ -1086,7 +1056,7 @@
def test__walkdirs_utf_win32_find_file_stat_directory(self):
"""make sure our Stat values are valid"""
- self.requireFeature(Win32FileFeature)
+ self.requireFeature(WalkdirsWin32Feature)
self.requireFeature(tests.UnicodeFilenameFeature)
name0u = u'0dir-\u062c\u0648'
name0 = name0u.encode('utf8')
More information about the bazaar-commits
mailing list