feat: add tempfile module

This commit is contained in:
Shunsuke Shibayama 2023-05-25 14:20:22 +09:00
parent 7e9cb513af
commit 30eac6dbcf
2 changed files with 66 additions and 0 deletions

View file

@ -423,6 +423,13 @@ impl Context {
Const,
None,
);
self.register_builtin_type(
mono(MUTABLE_IO),
io,
Visibility::BUILTIN_PRIVATE,
Const,
None,
);
self.register_builtin_type(
mono(MUTABLE_WRITABLE),
writable,

View file

@ -0,0 +1,59 @@
io = pyimport "io"
._TemporaryFileWrapper!: ClassType
._TemporaryFileWrapper! <: FileLike!
._TemporaryFileWrapper!.
name: Str
delete: Bool
file: io.BufferedRandom!
close!: (self: ._TemporaryFileWrapper!) => NoneType
.TemporaryFile!: (
mode := Str,
buffering := Int,
encoding := Str,
newline := Str,
suffix := Str,
prefix := Str,
dir := Str,
) -> ._TemporaryFileWrapper!
.NamedTemporaryFile!: (
mode := Str,
buffering := Int,
encoding := Str,
newline := Str,
suffix := Str,
prefix := Str,
dir := Str,
delete := Bool,
) -> ._TemporaryFileWrapper!
.TemporaryDirectory!: ClassType
.TemporaryDirectory!.
name: Str
__call__: (
suffix := Str,
prefix := Str,
dir := Str,
) -> .TemporaryDirectory!
cleanup!: (self: .TemporaryDirectory!) => NoneType
.mkstemp!: (
suffix := Str,
prefix := Str,
dir := Str,
text := Bool,
) -> (Nat, Str)
.mkdtemp!: (
suffix := Str,
prefix := Str,
dir := Str,
) -> Str
.gettempdir!: () => Str
.gettempdirb!: () => Bytes
.gettempprefix: () -> Str
.gettempprefixb: () -> Bytes
.tempdir: Str or NoneType