mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 02:39:20 +00:00
feat: enhance os
type decls
This commit is contained in:
parent
107d466e57
commit
21fcf23827
7 changed files with 93 additions and 29 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
.MINYEAR: {1}
|
||||
.MAXYEAR: {9999}
|
||||
.UTC: .TimeZone
|
||||
|
||||
.TimeDelta = 'timedelta': ClassType
|
||||
.TimeDelta <: Eq
|
||||
|
@ -73,9 +74,7 @@
|
|||
replace: (self: .Time, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .Time
|
||||
isoformat: (self: .Time, timespec := Str) -> Str
|
||||
.DateTime = 'datetime': ClassType
|
||||
.DateTime <: Eq
|
||||
.DateTime <: Hash
|
||||
.DateTime <: Ord
|
||||
.DateTime <: .Date
|
||||
.DateTime.
|
||||
__call__: (year: 0..9999, month: 1..12, day: 1..31, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .DateTime
|
||||
__eq__: (self: .DateTime, other: .DateTime) -> Bool
|
||||
|
@ -102,10 +101,9 @@
|
|||
replace: (self: .DateTime, year := 0..9999, month := 1..12, day := 1..31, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .DateTime
|
||||
utcoffset: (self: .DateTime) -> .TimeDelta or NoneType
|
||||
.TimeZone = 'timezone': ClassType
|
||||
.TimeZone <: Eq
|
||||
.TimeZone <: Hash
|
||||
.TimeZone <: Ord
|
||||
.TimeZone <: .TZInfo
|
||||
.TimeZone.
|
||||
utc: .TimeZone
|
||||
__eq__: (self: .TimeZone, other: .TimeZone) -> Bool
|
||||
__ne__: (self: .TimeZone, other: .TimeZone) -> Bool
|
||||
__lt__: (self: .TimeZone, other: .TimeZone) -> Bool
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
name: Str
|
||||
path: Str
|
||||
inode: (self: .DirEntry) -> Nat
|
||||
is_dir: (self: .DirEntry) -> Bool
|
||||
is_file: (self: .DirEntry) -> Bool
|
||||
is_dir: (self: .DirEntry, follow_symlinks := Bool) -> Bool
|
||||
is_file: (self: .DirEntry, follow_symlinks := Bool) -> Bool
|
||||
is_symlink: (self: .DirEntry) -> Bool
|
||||
is_junction: (self: .DirEntry) -> Bool
|
||||
stat: (self: .DirEntry, follow_symlinks := Bool) -> .StatResult
|
||||
|
||||
.StatResult = 'stat_result': ClassType
|
||||
.StatResult.
|
||||
|
@ -30,6 +32,17 @@
|
|||
st_ctime_ns: Nat
|
||||
st_birthtime: Float
|
||||
st_birthtime_ns: Nat
|
||||
st_blocks: Nat
|
||||
st_blksize: Nat
|
||||
st_rdev: Nat
|
||||
st_flags: Nat
|
||||
st_gen: Nat
|
||||
st_fstype: Nat
|
||||
st_rsize: Nat
|
||||
st_creator: Nat
|
||||
st_type: Nat
|
||||
st_file_attributes: Nat
|
||||
st_reparse_tag: Nat
|
||||
|
||||
# TODO: _Environ
|
||||
.environ: {Str: Str}
|
||||
|
@ -40,6 +53,10 @@ The name of the operating system dependent module imported. The following names
|
|||
'''
|
||||
.name: Str
|
||||
.supports_bytes_environ: Bool
|
||||
.supports_dir_fd: Set Subroutine, _
|
||||
.supports_effective_ids: Set Subroutine, _
|
||||
.supports_fd: Set Subroutine, _
|
||||
.supports_follow_symlinks: Set Subroutine, _
|
||||
|
||||
.F_LOCK: Nat
|
||||
.F_TLOCK: Nat
|
||||
|
@ -135,6 +152,13 @@ The name of the operating system dependent module imported. The following names
|
|||
.fstatvfs!: (fd: Nat or FileDescriptor) => .StatResult
|
||||
.fsync!: (fd: Nat or FileDescriptor) => NoneType
|
||||
.ftruncate!: (fd: Nat or FileDescriptor, length: Nat) => NoneType
|
||||
.fwalk!: (
|
||||
top := PathLike,
|
||||
topdown := Bool,
|
||||
onerror := Subroutine,
|
||||
follow_symlinks := Bool,
|
||||
dir_fd := Nat or FileDescriptor,
|
||||
) => Iterator [Str, [Str; _], [Str; _], Nat]
|
||||
.get_blocking!: (fd: Nat or FileDescriptor) => Bool
|
||||
.get_exec_path!: (env := {Str: Str}) => [Str; _]
|
||||
.getcwd!: () => Str
|
||||
|
@ -152,6 +176,7 @@ The name of the operating system dependent module imported. The following names
|
|||
.getpid!: () => Nat
|
||||
.getppid!: () => Nat
|
||||
.getpriority!: (which: Nat, who: Nat) => Nat
|
||||
.getrandom!: (size: Nat) => Bytes
|
||||
.getresgid!: () => (Nat, Nat, Nat)
|
||||
.getresuid!: () => (Nat, Nat, Nat)
|
||||
.getsid!: (pid: Nat) => Nat
|
||||
|
@ -201,7 +226,22 @@ The name of the operating system dependent module imported. The following names
|
|||
.setreuid!: (ruid: Nat, euid: Nat) => NoneType
|
||||
.setsid!: () => Nat
|
||||
.setuid!: (uid: Nat) => NoneType
|
||||
.statvfs!: (path: PathLike) => NamedTuple {
|
||||
.f_bsize = Nat;
|
||||
.f_frsize = Nat;
|
||||
.f_blocks = Nat;
|
||||
.f_bfree = Nat;
|
||||
.f_bavail = Nat;
|
||||
.f_files = Nat;
|
||||
.f_ffree = Nat;
|
||||
.f_favail = Nat;
|
||||
.f_flag = Nat;
|
||||
.f_namemax = Nat;
|
||||
.f_fsid = Nat;
|
||||
}
|
||||
.strerror: (code: Nat) -> Str
|
||||
.symlink!: (src: PathLike, dst: PathLike, target_is_directory := Bool, dir_fd := Nat or FileDescriptor) => NoneType
|
||||
.sync!: () => NoneType
|
||||
|
||||
.umask!: (mask: Nat) => Nat
|
||||
# posix = pyimport "posix"
|
||||
|
@ -213,8 +253,15 @@ The name of the operating system dependent module imported. The following names
|
|||
version = Str;
|
||||
machine = Str;
|
||||
}
|
||||
.unlink!: (path: PathLike, dir_fd := Nat or FileDescriptor) => NoneType
|
||||
.unsetenv!: (key: Str) => NoneType
|
||||
.unshare!: (flags: Nat) => NoneType
|
||||
|
||||
.getrandom!: (size: Nat) => Bytes
|
||||
.urandom!: (size: Nat) => Bytes
|
||||
.utime!: (path: PathLike, times := (Float, Float)) => NoneType
|
||||
|
||||
.walk!: (
|
||||
top: PathLike,
|
||||
topdown := Bool,
|
||||
onerror := Subroutine,
|
||||
followlinks := Bool
|
||||
) => Iterator [Str, [Str; _], [Str; _]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue