Add os.scandir and os.DirEntry (#424)

Introduced in Python 3.5
This commit is contained in:
Daniël van Eeden
2016-08-04 00:40:00 +02:00
committed by Matthias Kramm
parent 51a519b358
commit d315ceb060

View File

@@ -105,6 +105,20 @@ WNOHANG = 0 # Unix only
TMP_MAX = 0 # Undocumented, but used by tempfile
# ----- os classes (structures) -----
if sys.version_info >= (3, 5):
class DirEntry:
# This is what the scandir interator yields
# The constructor is hidden
name = ''
path = ''
def inode(self) -> int: ...
def is_dir(self, follow_symlinks: bool = ...) -> bool: ...
def is_file(self, follow_symlinks: bool = ...) -> bool: ...
def is_symlink(self) -> bool: ...
def stat(self) -> stat_result: ...
class stat_result:
# For backward compatibility, the return value of stat() is also
# accessible as a tuple of at least 10 integers giving the most important
@@ -259,6 +273,11 @@ def renames(old: AnyStr, new: AnyStr) -> None: ...
if sys.version_info >= (3, 3):
def replace(src: AnyStr, dst: AnyStr) -> None: ...
def rmdir(path: AnyStr) -> None: ...
if sys.version_info >= (3, 5):
@overload
def scandir(path: str = ...) -> Iterator[DirEntry]: ...
@overload
def scandir(path: bytes) -> Iterator[DirEntry]: ...
def stat(path: AnyStr) -> stat_result: ...
def stat_float_times(newvalue: Union[bool, None] = ...) -> bool: ...
def statvfs(path: str) -> statvfs_result: ... # Unix only