1
1
# created from https://docs.python.org/2/library/os.html
2
2
3
+ import sys
3
4
from typing import (
4
5
Mapping , MutableMapping , Dict , List , Any , Tuple , Iterator , overload , Union , AnyStr ,
5
6
Optional , Generic , Set , Callable , Text , Sequence , IO , NamedTuple
@@ -94,10 +95,58 @@ WUNTRACED = 0 # Unix only
94
95
95
96
TMP_MAX = 0 # Undocumented, but used by tempfile
96
97
_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 )])
101
150
def ctermid () -> str : ... # Unix only
102
151
def getegid () -> int : ... # Unix only
103
152
def geteuid () -> int : ... # Unix only
@@ -140,8 +189,8 @@ def fchmod(fd: int, mode: int) -> None: ... # Unix only
140
189
def fchown (fd : int , uid : int , gid : int ) -> None : ... # Unix only
141
190
def fdatasync (fd : int ) -> None : ... # Unix only, not Mac
142
191
def 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
145
194
def fsync (fd : int ) -> None : ...
146
195
def ftruncate (fd : int , length : int ) -> None : ... # Unix only
147
196
def isatty (fd : int ) -> bool : ... # Unix only
@@ -168,7 +217,7 @@ def lchmod(path: _PathType, mode: int) -> None: ... # Unix only
168
217
def lchown (path : _PathType , uid : int , gid : int ) -> None : ... # Unix only
169
218
def link (src : _PathType , link_name : _PathType ) -> None : ...
170
219
def listdir (path : AnyStr ) -> List [AnyStr ]: ...
171
- def lstat (path : _PathType ) -> Any : ...
220
+ def lstat (path : _PathType ) -> stat_result : ...
172
221
def mkfifo (path : _PathType , mode : int = ...) -> None : ... # Unix only
173
222
def mknod (filename : _PathType , mode : int = ..., device : int = ...) -> None : ...
174
223
def major (device : int ) -> int : ...
@@ -183,12 +232,12 @@ def removedirs(path: _PathType) -> None: ...
183
232
def rename (src : _PathType , dst : _PathType ) -> None : ...
184
233
def renames (old : _PathType , new : _PathType ) -> None : ...
185
234
def rmdir (path : _PathType ) -> None : ...
186
- def stat (path : _PathType ) -> Any : ...
187
235
@overload
188
- def stat_float_times (newvalue : bool = ... ) -> None : ...
236
+ def stat_float_times (newvalue : bool ) -> None : ...
189
237
@overload
190
238
def 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
192
241
def symlink (source : _PathType , link_name : _PathType ) -> None : ...
193
242
def unlink (path : _PathType ) -> None : ...
194
243
def utime (path : _PathType , times : Optional [Tuple [float , float ]]) -> None : ...
0 commit comments