Skip to content

Commit 30eac6d

Browse files
committed
feat: add tempfile module
1 parent 7e9cb51 commit 30eac6d

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

crates/erg_compiler/context/initialize/traits.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ impl Context {
423423
Const,
424424
None,
425425
);
426+
self.register_builtin_type(
427+
mono(MUTABLE_IO),
428+
io,
429+
Visibility::BUILTIN_PRIVATE,
430+
Const,
431+
None,
432+
);
426433
self.register_builtin_type(
427434
mono(MUTABLE_WRITABLE),
428435
writable,
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
io = pyimport "io"
2+
3+
._TemporaryFileWrapper!: ClassType
4+
._TemporaryFileWrapper! <: FileLike!
5+
._TemporaryFileWrapper!.
6+
name: Str
7+
delete: Bool
8+
file: io.BufferedRandom!
9+
close!: (self: ._TemporaryFileWrapper!) => NoneType
10+
11+
.TemporaryFile!: (
12+
mode := Str,
13+
buffering := Int,
14+
encoding := Str,
15+
newline := Str,
16+
suffix := Str,
17+
prefix := Str,
18+
dir := Str,
19+
) -> ._TemporaryFileWrapper!
20+
21+
.NamedTemporaryFile!: (
22+
mode := Str,
23+
buffering := Int,
24+
encoding := Str,
25+
newline := Str,
26+
suffix := Str,
27+
prefix := Str,
28+
dir := Str,
29+
delete := Bool,
30+
) -> ._TemporaryFileWrapper!
31+
32+
.TemporaryDirectory!: ClassType
33+
.TemporaryDirectory!.
34+
name: Str
35+
__call__: (
36+
suffix := Str,
37+
prefix := Str,
38+
dir := Str,
39+
) -> .TemporaryDirectory!
40+
cleanup!: (self: .TemporaryDirectory!) => NoneType
41+
42+
.mkstemp!: (
43+
suffix := Str,
44+
prefix := Str,
45+
dir := Str,
46+
text := Bool,
47+
) -> (Nat, Str)
48+
.mkdtemp!: (
49+
suffix := Str,
50+
prefix := Str,
51+
dir := Str,
52+
) -> Str
53+
54+
.gettempdir!: () => Str
55+
.gettempdirb!: () => Bytes
56+
.gettempprefix: () -> Str
57+
.gettempprefixb: () -> Bytes
58+
59+
.tempdir: Str or NoneType

0 commit comments

Comments
 (0)