11# created from https://docs.python.org/2/library/os.html
22
3+ import sys
34from typing import (
45 Mapping , MutableMapping , Dict , List , Any , Tuple , Iterator , overload , Union , AnyStr ,
56 Optional , Generic , Set , Callable , Text , Sequence , IO , NamedTuple
@@ -94,10 +95,58 @@ WUNTRACED = 0 # Unix only
9495
9596TMP_MAX = 0 # Undocumented, but used by tempfile
9697_PathType = Union [bytes , Text ]
97- _StatVFS = NamedTuple ('_StatVFS' , [('f_bsize' , int ), ('f_frsize' , int ), ('f_blocks' , int ),
98- ('f_bfree' , int ), ('f_bavail' , int ), ('f_files' , int ),
99- ('f_ffree' , int ), ('f_favail' , int ), ('f_flag' , int ),
100- ('f_namemax' , int )])
98+
99+ class stat_result (NamedTuple ('stat_result' , [
100+ ('st_mode' , int ),
101+ ('st_ino' , int ),
102+ ('st_dev' , int ),
103+ ('st_nlink' , int ),
104+ ('st_uid' , int ),
105+ ('st_gid' , int ),
106+ ('st_size' , int ),
107+ ('st_atime' , float ),
108+ ('st_mtime' , float ),
109+ ('st_ctime' , float )])):
110+
111+ # For backward compatibility, the return value of stat() is also
112+ # accessible as a tuple of at least 10 integers giving the most important
113+ # (and portable) members of the stat structure, in the order st_mode,
114+ # st_ino, st_dev, st_nlink, st_uid, st_gid, st_size, st_atime, st_mtime,
115+ # st_ctime. More items may be added at the end by some implementations.
116+
117+ if sys .version_info >= (3 , 3 ):
118+ st_atime_ns = ... # type: int
119+ st_mtime_ns = ... # type: int
120+ st_ctime_ns = ... # type: int
121+
122+ # On some Unix systems (such as Linux), the following attributes may also
123+ # be available:
124+ st_blocks = ... # type: int
125+ st_blksize = ... # type: int
126+ st_rdev = ... # type: int
127+ st_flags = ... # type: int
128+
129+ # On other Unix systems (such as FreeBSD), the following attributes may be
130+ # available (but may be only filled out if root tries to use them):
131+ st_gen = ... # type: int
132+ st_birthtime = ... # type: int
133+
134+ # On Mac OS systems, the following attributes may also be available:
135+ st_rsize = ... # type: int
136+ st_creator = ... # type: int
137+ st_type = ... # type: int
138+
139+ statvfs_result = NamedTuple ('statvfs_result' , [
140+ ('f_bsize' , int ),
141+ ('f_frsize' , int ),
142+ ('f_blocks' , int ),
143+ ('f_bfree' , int ),
144+ ('f_bavail' , int ),
145+ ('f_files' , int ),
146+ ('f_ffree' , int ),
147+ ('f_favail' , int ),
148+ ('f_flag' , int ),
149+ ('f_namemax' , int )])
101150def ctermid () -> str : ... # Unix only
102151def getegid () -> int : ... # Unix only
103152def geteuid () -> int : ... # Unix only
@@ -140,8 +189,8 @@ def fchmod(fd: int, mode: int) -> None: ... # Unix only
140189def fchown (fd : int , uid : int , gid : int ) -> None : ... # Unix only
141190def fdatasync (fd : int ) -> None : ... # Unix only, not Mac
142191def fpathconf (fd : int , name : Union [str , int ]) -> int : ... # Unix only
143- def fstat (fd : int ) -> Any : ...
144- def fstatvfs (fd : int ) -> _StatVFS : ... # Unix only
192+ def fstat (fd : int ) -> stat_result : ...
193+ def fstatvfs (fd : int ) -> statvfs_result : ... # Unix only
145194def fsync (fd : int ) -> None : ...
146195def ftruncate (fd : int , length : int ) -> None : ... # Unix only
147196def isatty (fd : int ) -> bool : ... # Unix only
@@ -168,7 +217,7 @@ def lchmod(path: _PathType, mode: int) -> None: ... # Unix only
168217def lchown (path : _PathType , uid : int , gid : int ) -> None : ... # Unix only
169218def link (src : _PathType , link_name : _PathType ) -> None : ...
170219def listdir (path : AnyStr ) -> List [AnyStr ]: ...
171- def lstat (path : _PathType ) -> Any : ...
220+ def lstat (path : _PathType ) -> stat_result : ...
172221def mkfifo (path : _PathType , mode : int = ...) -> None : ... # Unix only
173222def mknod (filename : _PathType , mode : int = ..., device : int = ...) -> None : ...
174223def major (device : int ) -> int : ...
@@ -183,12 +232,12 @@ def removedirs(path: _PathType) -> None: ...
183232def rename (src : _PathType , dst : _PathType ) -> None : ...
184233def renames (old : _PathType , new : _PathType ) -> None : ...
185234def rmdir (path : _PathType ) -> None : ...
186- def stat (path : _PathType ) -> Any : ...
187235@overload
188- def stat_float_times (newvalue : bool = ... ) -> None : ...
236+ def stat_float_times (newvalue : bool ) -> None : ...
189237@overload
190238def stat_float_times () -> bool : ...
191- def statvfs (path : _PathType ) -> _StatVFS : ... # Unix only
239+ def stat (path : _PathType ) -> stat_result : ...
240+ def statvfs (path : _PathType ) -> statvfs_result : ... # Unix only
192241def symlink (source : _PathType , link_name : _PathType ) -> None : ...
193242def unlink (path : _PathType ) -> None : ...
194243def utime (path : _PathType , times : Optional [Tuple [float , float ]]) -> None : ...
0 commit comments