mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 09:53:37 +00:00
Update scandir 1.6 (c3592ee) → 1.9.0 (9ab3d1f).
This commit is contained in:
parent
345ded7ee0
commit
1a3f0e8a7e
1 changed files with 693 additions and 671 deletions
|
@ -23,7 +23,6 @@ from os import listdir, lstat, stat, strerror
|
||||||
from os.path import join, islink
|
from os.path import join, islink
|
||||||
from stat import S_IFDIR, S_IFLNK, S_IFREG
|
from stat import S_IFDIR, S_IFLNK, S_IFREG
|
||||||
import collections
|
import collections
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -41,7 +40,7 @@ if _scandir is None and ctypes is None:
|
||||||
warnings.warn("scandir can't find the compiled _scandir C module "
|
warnings.warn("scandir can't find the compiled _scandir C module "
|
||||||
"or ctypes, using slow generic fallback")
|
"or ctypes, using slow generic fallback")
|
||||||
|
|
||||||
__version__ = '1.6'
|
__version__ = '1.9.0'
|
||||||
__all__ = ['scandir', 'walk']
|
__all__ = ['scandir', 'walk']
|
||||||
|
|
||||||
# Windows FILE_ATTRIBUTE constants for interpreting the
|
# Windows FILE_ATTRIBUTE constants for interpreting the
|
||||||
|
@ -96,6 +95,10 @@ class GenericDirEntry(object):
|
||||||
self._lstat = lstat(self.path)
|
self._lstat = lstat(self.path)
|
||||||
return self._lstat
|
return self._lstat
|
||||||
|
|
||||||
|
# The code duplication below is intentional: this is for slightly
|
||||||
|
# better performance on systems that fall back to GenericDirEntry.
|
||||||
|
# It avoids an additional attribute lookup and method call, which
|
||||||
|
# are relatively slow on CPython.
|
||||||
def is_dir(self, follow_symlinks=True):
|
def is_dir(self, follow_symlinks=True):
|
||||||
try:
|
try:
|
||||||
st = self.stat(follow_symlinks=follow_symlinks)
|
st = self.stat(follow_symlinks=follow_symlinks)
|
||||||
|
@ -386,13 +389,17 @@ if sys.platform == 'win32':
|
||||||
|
|
||||||
if _scandir is not None:
|
if _scandir is not None:
|
||||||
scandir_c = _scandir.scandir
|
scandir_c = _scandir.scandir
|
||||||
|
DirEntry_c = _scandir.DirEntry
|
||||||
|
|
||||||
if _scandir is not None:
|
if _scandir is not None:
|
||||||
scandir = scandir_c
|
scandir = scandir_c
|
||||||
|
DirEntry = DirEntry_c
|
||||||
elif ctypes is not None:
|
elif ctypes is not None:
|
||||||
scandir = scandir_python
|
scandir = scandir_python
|
||||||
|
DirEntry = Win32DirEntryPython
|
||||||
else:
|
else:
|
||||||
scandir = scandir_generic
|
scandir = scandir_generic
|
||||||
|
DirEntry = GenericDirEntry
|
||||||
|
|
||||||
|
|
||||||
# Linux, OS X, and BSD implementation
|
# Linux, OS X, and BSD implementation
|
||||||
|
@ -415,6 +422,16 @@ elif sys.platform.startswith(('linux', 'darwin', 'sunos5')) or 'bsd' in sys.plat
|
||||||
('d_type', ctypes.c_byte),
|
('d_type', ctypes.c_byte),
|
||||||
('d_name', ctypes.c_char * 256),
|
('d_name', ctypes.c_char * 256),
|
||||||
)
|
)
|
||||||
|
elif 'openbsd' in sys.platform:
|
||||||
|
_fields_ = (
|
||||||
|
('d_ino', ctypes.c_uint64),
|
||||||
|
('d_off', ctypes.c_uint64),
|
||||||
|
('d_reclen', ctypes.c_uint16),
|
||||||
|
('d_type', ctypes.c_uint8),
|
||||||
|
('d_namlen', ctypes.c_uint8),
|
||||||
|
('__d_padding', ctypes.c_uint8 * 4),
|
||||||
|
('d_name', ctypes.c_char * 256),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
_fields_ = (
|
_fields_ = (
|
||||||
('d_ino', ctypes.c_uint32), # must be uint32, not ulong
|
('d_ino', ctypes.c_uint32), # must be uint32, not ulong
|
||||||
|
@ -564,18 +581,23 @@ elif sys.platform.startswith(('linux', 'darwin', 'sunos5')) or 'bsd' in sys.plat
|
||||||
|
|
||||||
if _scandir is not None:
|
if _scandir is not None:
|
||||||
scandir_c = _scandir.scandir
|
scandir_c = _scandir.scandir
|
||||||
|
DirEntry_c = _scandir.DirEntry
|
||||||
|
|
||||||
if _scandir is not None:
|
if _scandir is not None:
|
||||||
scandir = scandir_c
|
scandir = scandir_c
|
||||||
elif ctypes is not None:
|
DirEntry = DirEntry_c
|
||||||
|
elif ctypes is not None and have_dirent_d_type:
|
||||||
scandir = scandir_python
|
scandir = scandir_python
|
||||||
|
DirEntry = PosixDirEntry
|
||||||
else:
|
else:
|
||||||
scandir = scandir_generic
|
scandir = scandir_generic
|
||||||
|
DirEntry = GenericDirEntry
|
||||||
|
|
||||||
|
|
||||||
# Some other system -- no d_type or stat information
|
# Some other system -- no d_type or stat information
|
||||||
else:
|
else:
|
||||||
scandir = scandir_generic
|
scandir = scandir_generic
|
||||||
|
DirEntry = GenericDirEntry
|
||||||
|
|
||||||
|
|
||||||
def _walk(top, topdown=True, onerror=None, followlinks=False):
|
def _walk(top, topdown=True, onerror=None, followlinks=False):
|
||||||
|
|
Loading…
Reference in a new issue