Skip to content

Commit

Permalink
feat: add tempfile module
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed May 25, 2023
1 parent 7e9cb51 commit 30eac6d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/erg_compiler/context/initialize/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
59 changes: 59 additions & 0 deletions crates/erg_compiler/lib/pystd/tempfile.d.er
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 30eac6d

Please sign in to comment.