|
10 | 10 | Iterable, |
11 | 11 | Literal, |
12 | 12 | Optional, |
| 13 | + TypedDict, |
13 | 14 | Union, |
14 | 15 | cast, |
15 | 16 | ) |
16 | 17 |
|
17 | 18 | from re import Pattern |
18 | 19 |
|
19 | | -from .api_types_generated import ( |
20 | | - DirEntry, |
21 | | - FileInfo, |
22 | | - FsFileHandle, |
23 | | - WalkEntry, |
24 | | -) |
25 | 20 | from .process import AbortSignal |
26 | 21 | from .stream import stream_data |
27 | 22 | from .utils import convert_to_camel_case, convert_to_snake_case |
|
31 | 26 | from .bridge import AsyncBridge |
32 | 27 |
|
33 | 28 |
|
| 29 | +class DirEntry(TypedDict): |
| 30 | + name: str |
| 31 | + """The file or directory name.""" |
| 32 | + |
| 33 | + is_file: bool |
| 34 | + """Whether the entry is a file.""" |
| 35 | + |
| 36 | + is_directory: bool |
| 37 | + """Whether the entry is a directory.""" |
| 38 | + |
| 39 | + is_symlink: bool |
| 40 | + """Whether the entry is a symbolic link.""" |
| 41 | + |
| 42 | + |
| 43 | +class FileInfo(TypedDict): |
| 44 | + is_file: bool |
| 45 | + """Whether the path is a file.""" |
| 46 | + |
| 47 | + is_directory: bool |
| 48 | + """Whether the path is a directory.""" |
| 49 | + |
| 50 | + is_symlink: bool |
| 51 | + """Whether the path is a symbolic link.""" |
| 52 | + |
| 53 | + size: int |
| 54 | + """The size of the file in bytes.""" |
| 55 | + |
| 56 | + mtime: str |
| 57 | + """The last modification time of the file.""" |
| 58 | + |
| 59 | + atime: str |
| 60 | + """The last access time of the file.""" |
| 61 | + |
| 62 | + birthtime: str |
| 63 | + """The creation time of the file.""" |
| 64 | + |
| 65 | + ctime: str |
| 66 | + """The last status change time of the file.""" |
| 67 | + |
| 68 | + dev: int |
| 69 | + """The device ID.""" |
| 70 | + |
| 71 | + ino: int |
| 72 | + """The inode number.""" |
| 73 | + |
| 74 | + mode: int |
| 75 | + """The file mode.""" |
| 76 | + |
| 77 | + nlink: int |
| 78 | + """The number of hard links pointing to this file.""" |
| 79 | + |
| 80 | + uid: int |
| 81 | + """The user ID of the owner.""" |
| 82 | + |
| 83 | + gid: int |
| 84 | + """The group ID of the owner.""" |
| 85 | + |
| 86 | + rdev: int |
| 87 | + """The device ID of this file.""" |
| 88 | + |
| 89 | + blksize: int |
| 90 | + """The block size for filesystem I/O.""" |
| 91 | + |
| 92 | + blocks: int |
| 93 | + """The number of blocks allocated in 512-byte units""" |
| 94 | + |
| 95 | + is_block_device: bool |
| 96 | + """Whether the path is a block device.""" |
| 97 | + |
| 98 | + is_char_device: bool |
| 99 | + """Whether the path is a character device.""" |
| 100 | + |
| 101 | + is_fifo: bool |
| 102 | + """Whether the path is a FIFO.""" |
| 103 | + |
| 104 | + is_socket: bool |
| 105 | + """Whether the path is a socket.""" |
| 106 | + |
| 107 | + |
| 108 | +class WalkEntry(TypedDict): |
| 109 | + path: str |
| 110 | + """The full path of the entry.""" |
| 111 | + |
| 112 | + name: str |
| 113 | + """The file or directory name.""" |
| 114 | + |
| 115 | + is_file: bool |
| 116 | + """Whether the entry is a file.""" |
| 117 | + |
| 118 | + is_directory: bool |
| 119 | + """Whether the entry is a directory.""" |
| 120 | + |
| 121 | + is_symlink: bool |
| 122 | + """Whether the entry is a symbolic link.""" |
| 123 | + |
| 124 | + |
| 125 | +class FsFileHandle(TypedDict): |
| 126 | + file_handle_id: int |
| 127 | + |
| 128 | + |
34 | 129 | class AsyncFsFile: |
35 | 130 | def __init__(self, rpc: AsyncRpcClient, fd: int): |
36 | 131 | self._rpc = rpc |
|
0 commit comments