@@ -8,16 +8,95 @@ from . import path
88from mypy_extensions import NoReturn
99
1010error = OSError
11+ SEEK_SET = 0
12+ SEEK_CUR = 0
13+ SEEK_END = 0
14+
15+ # More constants, copied from stdlib/3/os/__init__.pyi
16+ O_RDONLY = 0
17+ O_WRONLY = 0
18+ O_RDWR = 0
19+ O_APPEND = 0
20+ O_CREAT = 0
21+ O_EXCL = 0
22+ O_TRUNC = 0
23+ O_DSYNC = 0 # Unix only
24+ O_RSYNC = 0 # Unix only
25+ O_SYNC = 0 # Unix only
26+ O_NDELAY = 0 # Unix only
27+ O_NONBLOCK = 0 # Unix only
28+ O_NOCTTY = 0 # Unix only
29+ O_SHLOCK = 0 # Unix only
30+ O_EXLOCK = 0 # Unix only
31+ O_BINARY = 0 # Windows only
32+ O_NOINHERIT = 0 # Windows only
33+ O_SHORT_LIVED = 0 # Windows only
34+ O_TEMPORARY = 0 # Windows only
35+ O_RANDOM = 0 # Windows only
36+ O_SEQUENTIAL = 0 # Windows only
37+ O_TEXT = 0 # Windows only
38+ O_ASYNC = 0 # Gnu extension if in C library
39+ O_DIRECT = 0 # Gnu extension if in C library
40+ O_DIRECTORY = 0 # Gnu extension if in C library
41+ O_NOFOLLOW = 0 # Gnu extension if in C library
42+ O_NOATIME = 0 # Gnu extension if in C library
43+ O_LARGEFILE = 0 # Gnu extension if in C library
44+
45+ curdir = ... # type: str
46+ pardir = ... # type: str
47+ sep = ... # type: str
48+ altsep = ... # type: str
49+ extsep = ... # type: str
50+ pathsep = ... # type: str
51+ defpath = ... # type: str
52+ linesep = ... # type: str
53+ devnull = ... # type: str
1154name = ... # type: str
1255
56+ F_OK = 0
57+ R_OK = 0
58+ W_OK = 0
59+ X_OK = 0
60+
1361class _Environ (MutableMapping [str , str ]):
1462 def copy (self ) -> Dict [str , str ]: ...
1563
1664environ = ... # type: _Environ
65+ confstr_names = ... # type: Mapping[str, int]
66+ pathconf_names = ... # type: Mapping[str, int]
67+ sysconf_names = ... # type: Mapping[str, int]
68+ EX_OK = 0 # Unix only
69+ EX_USAGE = 0 # Unix only
70+ EX_DATAERR = 0 # Unix only
71+ EX_NOINPUT = 0 # Unix only
72+ EX_NOUSER = 0 # Unix only
73+ EX_NOHOST = 0 # Unix only
74+ EX_UNAVAILABLE = 0 # Unix only
75+ EX_SOFTWARE = 0 # Unix only
76+ EX_OSERR = 0 # Unix only
77+ EX_OSFILE = 0 # Unix only
78+ EX_CANTCREAT = 0 # Unix only
79+ EX_IOERR = 0 # Unix only
80+ EX_TEMPFAIL = 0 # Unix only
81+ EX_PROTOCOL = 0 # Unix only
82+ EX_NOPERM = 0 # Unix only
83+ EX_CONFIG = 0 # Unix only
84+ P_NOWAIT = 0
85+ P_NOWAITO = 0
86+ P_WAIT = 0
87+ # P_DETACH = 0 # Windows only
88+ # P_OVERLAY = 0 # Windows only
1789
18- def chdir (path : unicode ) -> None : ...
19- def fchdir (fd : int ) -> None : ...
20- def getcwd () -> str : ...
90+ # wait()/waitpid() options
91+ WNOHANG = 0 # Unix only
92+ WCONTINUED = 0 # some Unix systems
93+ WUNTRACED = 0 # Unix only
94+
95+ TMP_MAX = 0
96+ _StatVFS = NamedTuple ('_StatVFS' , [('f_bsize' , int ), ('f_frsize' , int ), ('f_blocks' , int ),
97+ ('f_bfree' , int ), ('f_bavail' , int ), ('f_files' , int ),
98+ ('f_ffree' , int ), ('f_favail' , int ), ('f_flag' , int ),
99+ ('f_namemax' , int )])
21100def ctermid () -> str : ...
22101def getegid () -> int : ...
23102def geteuid () -> int : ...
@@ -38,10 +117,7 @@ def setegid(egid: int) -> None: ...
38117def seteuid (euid : int ) -> None : ...
39118def setgid (gid : int ) -> None : ...
40119def setgroups (groups : Sequence [int ]) -> None : ...
41-
42- # TODO(MichalPokorny)
43120def setpgrp (* args ) -> None : ...
44-
45121def setpgid (pid : int , pgrp : int ) -> None : ...
46122def setregid (rgid : int , egid : int ) -> None : ...
47123def setresgid (rgid : int , egid : int , sgid : int ) -> None : ...
@@ -50,46 +126,24 @@ def setreuid(ruid: int, euid: int) -> None: ...
50126def getsid (pid : int ) -> int : ...
51127def setsid () -> None : ...
52128def setuid (pid : int ) -> None : ...
53-
54129def strerror (code : int ) -> str : ...
55-
56130def umask (mask : int ) -> int : ...
57131def uname () -> Tuple [str , str , str , str , str ]: ...
58132def unsetenv (varname : str ) -> None : ...
59-
60- # TODO(MichalPokorny)
61133def fdopen (fd : int , * args , ** kwargs ) -> IO [Any ]: ...
62- def popen (command : str , * args , ** kwargs ) -> Optional [IO [Any ]]: ...
63- def tmpfile () -> IO [Any ]: ...
64-
65- def tmpnam () -> str : ...
66- def tempnam (dir : str = ..., prefix : str = ...) -> str : ...
67-
68- def popen2 (cmd : str , * args , ** kwargs ) -> Tuple [IO [Any ], IO [Any ]]: ...
69- def popen3 (cmd : str , * args , ** kwargs ) -> Tuple [IO [Any ], IO [Any ], IO [Any ]]: ...
70- def popen4 (cmd : str , * args , ** kwargs ) -> Tuple [IO [Any ], IO [Any ]]: ...
71-
72134def close (fd : int ) -> None : ...
73135def closerange (fd_low : int , fd_high : int ) -> None : ...
74136def dup (fd : int ) -> int : ...
75137def dup2 (fd : int , fd2 : int ) -> None : ...
76138def fchmod (fd : int , mode : int ) -> None : ...
77139def fchown (fd : int , uid : int , gid : int ) -> None : ...
78140def fdatasync (fd : int ) -> None : ...
79- def fpathconf (fd : int , name : str ) -> None : ...
80-
81- # TODO(prvak)
82141def fstat (fd : int ) -> Any : ...
142+ def fstatvfs (fd : int ) -> _StatVFS : ...
83143def fsync (fd : int ) -> None : ...
84144def ftruncate (fd : int , length : int ) -> None : ...
85145def isatty (fd : int ) -> bool : ...
86-
87146def lseek (fd : int , pos : int , how : int ) -> None : ...
88- SEEK_SET = 0
89- SEEK_CUR = 0
90- SEEK_END = 0
91-
92- # TODO(prvak): maybe file should be unicode? (same with all other paths...)
93147def open (file : unicode , flags : int , mode : int = ...) -> int : ...
94148def openpty () -> Tuple [int , int ]: ...
95149def pipe () -> Tuple [int , int ]: ...
@@ -98,15 +152,11 @@ def tcgetpgrp(fd: int) -> int: ...
98152def tcsetpgrp (fd : int , pg : int ) -> None : ...
99153def ttyname (fd : int ) -> str : ...
100154def write (fd : int , str : str ) -> int : ...
101-
102- # TODO: O_*
103-
104155def access (path : unicode , mode : int ) -> bool : ...
105- F_OK = 0
106- R_OK = 0
107- W_OK = 0
108- X_OK = 0
109-
156+ def fpathconf (fd : int , name : str ) -> None : ...
157+ def chdir (path : unicode ) -> None : ...
158+ def fchdir (fd : int ) -> None : ...
159+ def getcwd () -> str : ...
110160def getcwdu () -> unicode : ...
111161def chflags (path : unicode , flags : int ) -> None : ...
112162def chroot (path : unicode ) -> None : ...
@@ -117,10 +167,7 @@ def lchmod(path: unicode, uid: int, gid: int) -> None: ...
117167def lchown (path : unicode , uid : int , gid : int ) -> None : ...
118168def link (source : unicode , link_name : unicode ) -> None : ...
119169def listdir (path : AnyStr ) -> List [AnyStr ]: ...
120-
121- # TODO(MichalPokorny)
122170def lstat (path : unicode ) -> Any : ...
123-
124171def mkfifo (path : unicode , mode : int = ...) -> None : ...
125172def mknod (filename : unicode , mode : int = ..., device : int = ...) -> None : ...
126173def major (device : int ) -> int : ...
@@ -129,73 +176,45 @@ def makedev(major: int, minor: int) -> int: ...
129176def mkdir (path : unicode , mode : int = ...) -> None : ...
130177def makedirs (path : unicode , mode : int = ...) -> None : ...
131178def pathconf (path : unicode , name : str ) -> str : ...
132-
133- pathconf_names = ... # type: Mapping[str, int]
134-
135179def readlink (path : AnyStr ) -> AnyStr : ...
136180def remove (path : unicode ) -> None : ...
137181def removedirs (path : unicode ) -> None : ...
138182def rename (src : unicode , dst : unicode ) -> None : ...
139183def renames (old : unicode , new : unicode ) -> None : ...
140184def rmdir (path : unicode ) -> None : ...
141-
142- # TODO(MichalPokorny)
143185def stat (path : unicode ) -> Any : ...
144-
145- _StatVFS = NamedTuple ('_StatVFS' , [('f_bsize' , int ), ('f_frsize' , int ), ('f_blocks' , int ),
146- ('f_bfree' , int ), ('f_bavail' , int ), ('f_files' , int ),
147- ('f_ffree' , int ), ('f_favail' , int ), ('f_flag' , int ),
148- ('f_namemax' , int )])
149-
150- def fstatvfs (fd : int ) -> _StatVFS : ...
186+ @overload
187+ def stat_float_times (newvalue : bool = ...) -> None : ...
188+ @overload
189+ def stat_float_times () -> bool : ...
151190def statvfs (path : unicode ) -> _StatVFS : ...
152-
153- def walk (top : AnyStr , topdown : bool = ..., onerror : Any = ...,
154- followlinks : bool = ...) -> Iterator [Tuple [AnyStr , List [AnyStr ],
155- List [AnyStr ]]]: ...
156-
157191def symlink (source : unicode , link_name : unicode ) -> None : ...
158192def unlink (path : unicode ) -> None : ...
159193def utime (path : unicode , times : Optional [Tuple [int , int ]]) -> None : ...
194+ def walk (top : AnyStr , topdown : bool = ..., onerror : Any = ...,
195+ followlinks : bool = ...) -> Iterator [Tuple [AnyStr , List [AnyStr ],
196+ List [AnyStr ]]]: ...
160197
161198def abort () -> None : ...
162-
163- EX_OK = 0 # Unix only
164- EX_USAGE = 0 # Unix only
165- EX_DATAERR = 0 # Unix only
166- EX_NOINPUT = 0 # Unix only
167- EX_NOUSER = 0 # Unix only
168- EX_NOHOST = 0 # Unix only
169- EX_UNAVAILABLE = 0 # Unix only
170- EX_SOFTWARE = 0 # Unix only
171- EX_OSERR = 0 # Unix only
172- EX_OSFILE = 0 # Unix only
173- EX_CANTCREAT = 0 # Unix only
174- EX_IOERR = 0 # Unix only
175- EX_TEMPFAIL = 0 # Unix only
176- EX_PROTOCOL = 0 # Unix only
177- EX_NOPERM = 0 # Unix only
178- EX_CONFIG = 0 # Unix only
179-
180199def execl (file : AnyStr , * args ) -> None : ...
181200def execle (file : AnyStr , * args ) -> None : ...
182201def execlp (file : AnyStr , * args ) -> None : ...
183202def execlpe (file : AnyStr , * args ) -> None : ...
184- def execvp (file : AnyStr , args : Union [Tuple [AnyStr ], List [AnyStr ]]) -> None : ...
185- def execvpe (file : AnyStr , args : Union [Tuple [AnyStr ], List [AnyStr ]], env : Mapping [AnyStr , AnyStr ]) -> None : ...
186203def execv (path : AnyStr , args : Union [Tuple [AnyStr ], List [AnyStr ]]) -> None : ...
187204def execve (path : AnyStr , args : Union [Tuple [AnyStr ], List [AnyStr ]], env : Mapping [AnyStr , AnyStr ]) -> None : ...
188-
205+ def execvp (file : AnyStr , args : Union [Tuple [AnyStr ], List [AnyStr ]]) -> None : ...
206+ def execvpe (file : AnyStr , args : Union [Tuple [AnyStr ], List [AnyStr ]], env : Mapping [AnyStr , AnyStr ]) -> None : ...
189207def _exit (n : int ) -> NoReturn : ...
190-
191208def fork () -> int : ...
192209def forkpty () -> Tuple [int , int ]: ...
193-
194210def kill (pid : int , sig : int ) -> None : ...
195211def killpg (pgid : int , sig : int ) -> None : ...
196212def nice (increment : int ) -> int : ...
197-
198213# TODO: plock, popen*, P_*
214+ def popen (command : str , * args , ** kwargs ) -> Optional [IO [Any ]]: ...
215+ def popen2 (cmd : str , * args , ** kwargs ) -> Tuple [IO [Any ], IO [Any ]]: ...
216+ def popen3 (cmd : str , * args , ** kwargs ) -> Tuple [IO [Any ], IO [Any ], IO [Any ]]: ...
217+ def popen4 (cmd : str , * args , ** kwargs ) -> Tuple [IO [Any ], IO [Any ]]: ...
199218
200219def spawnl (mode : int , path : AnyStr , arg0 : AnyStr , * args : AnyStr ) -> int : ...
201220def spawnle (mode : int , path : AnyStr , arg0 : AnyStr ,
@@ -215,89 +234,26 @@ def startfile(path: unicode, operation: str = ...) -> None: ... # Windows only
215234def system (command : unicode ) -> int : ...
216235def times () -> Tuple [float , float , float , float , float ]: ...
217236def wait () -> Tuple [int , int ]: ... # Unix only
237+ def waitpid (pid : int , options : int ) -> Tuple [int , int ]: ...
218238def wait3 (options : int ) -> Tuple [int , int , Any ]: ... # Unix only
219239def wait4 (pid : int , options : int ) -> Tuple [int , int , Any ]: ... # Unix only
220- def waitpid (pid : int , options : int ) -> Tuple [int , int ]: ...
221-
240+ def WCOREDUMP (status : int ) -> bool : ...
241+ def WIFCONTINUED (status : int ) -> bool : ...
242+ def WIFSTOPPED (status : int ) -> bool : ...
243+ def WIFSIGNALED (status : int ) -> bool : ...
244+ def WIFEXITED (status : int ) -> bool : ...
245+ def WEXITSTATUS (status : int ) -> int : ...
246+ def WSTOPSIG (status : int ) -> int : ...
247+ def WTERMSIG (status : int ) -> int : ...
222248def confstr (name : Union [str , int ]) -> Optional [str ]: ...
223- confstr_names = ... # type: Mapping[str, int]
224-
225249def getloadavg () -> Tuple [float , float , float ]: ...
226-
227250def sysconf (name : Union [str , int ]) -> int : ...
228- sysconf_names = ... # type: Mapping[str, int]
229-
230- curdir = ... # type: str
231- pardir = ... # type: str
232- sep = ... # type: str
233- altsep = ... # type: str
234- extsep = ... # type: str
235- pathsep = ... # type: str
236- defpath = ... # type: str
237- linesep = ... # type: str
238- devnull = ... # type: str
239-
240251def urandom (n : int ) -> str : ...
241252
242- # More constants, copied from stdlib/3/os/__init__.pyi
243-
244- O_RDONLY = 0
245- O_WRONLY = 0
246- O_RDWR = 0
247- O_APPEND = 0
248- O_CREAT = 0
249- O_EXCL = 0
250- O_TRUNC = 0
251- O_DSYNC = 0 # Unix only
252- O_RSYNC = 0 # Unix only
253- O_SYNC = 0 # Unix only
254- O_NDELAY = 0 # Unix only
255- O_NONBLOCK = 0 # Unix only
256- O_NOCTTY = 0 # Unix only
257- O_SHLOCK = 0 # Unix only
258- O_EXLOCK = 0 # Unix only
259- O_BINARY = 0 # Windows only
260- O_NOINHERIT = 0 # Windows only
261- O_SHORT_LIVED = 0 # Windows only
262- O_TEMPORARY = 0 # Windows only
263- O_RANDOM = 0 # Windows only
264- O_SEQUENTIAL = 0 # Windows only
265- O_TEXT = 0 # Windows only
266- O_ASYNC = 0 # Gnu extension if in C library
267- O_DIRECT = 0 # Gnu extension if in C library
268- O_DIRECTORY = 0 # Gnu extension if in C library
269- O_NOFOLLOW = 0 # Gnu extension if in C library
270- O_NOATIME = 0 # Gnu extension if in C library
271- O_LARGEFILE = 0 # Gnu extension if in C library
272-
273- P_NOWAIT = 0
274- P_NOWAITO = 0
275- P_WAIT = 0
276- # P_DETACH = 0 # Windows only
277- # P_OVERLAY = 0 # Windows only
278-
279- # wait()/waitpid() options
280- WNOHANG = 0 # Unix only
281- WCONTINUED = 0 # some Unix systems
282- WUNTRACED = 0 # Unix only
253+ def tmpfile () -> IO [Any ]: ...
254+ def tmpnam () -> str : ...
255+ def tempnam (dir : str = ..., prefix : str = ...) -> str : ...
283256
284257P_ALL = 0
285258WEXITED = 0
286259WNOWAIT = 0
287-
288- TMP_MAX = 0
289-
290- # Below are Unix-only
291- def WCOREDUMP (status : int ) -> bool : ...
292- def WEXITSTATUS (status : int ) -> int : ...
293- def WIFCONTINUED (status : int ) -> bool : ...
294- def WIFEXITED (status : int ) -> bool : ...
295- def WIFSIGNALED (status : int ) -> bool : ...
296- def WIFSTOPPED (status : int ) -> bool : ...
297- def WSTOPSIG (status : int ) -> int : ...
298- def WTERMSIG (status : int ) -> int : ...
299-
300- @overload
301- def stat_float_times (newvalue : bool = ...) -> None : ...
302- @overload
303- def stat_float_times () -> bool : ...
0 commit comments