1
1
from collections .abc import Sequence
2
+ from datetime import datetime
2
3
from pathlib import Path , PurePosixPath
3
4
from typing import Any , AsyncIterator , Optional
4
5
10
11
from ...types import (
11
12
CapacityUsage ,
12
13
DirEntry ,
14
+ DirEntryType ,
13
15
FSPerfMetric ,
14
16
QuotaConfig ,
15
17
QuotaUsage ,
18
+ Stat ,
16
19
TreeUsage ,
17
20
VFolderID ,
18
21
)
19
22
from ..abc import AbstractFSOpModel , AbstractQuotaModel , AbstractVolume
20
23
21
24
25
+ async def _return_empty_dir_entry () -> AsyncIterator [DirEntry ]:
26
+ yield DirEntry (
27
+ "" , Path (), DirEntryType .FILE , Stat (0 , "" , 0 , datetime .now (), datetime .now ()), ""
28
+ )
29
+
30
+
22
31
class NoopQuotaModel (AbstractQuotaModel ):
23
32
def __init__ (self ) -> None :
24
- return
33
+ pass
25
34
26
35
def mangle_qspath (self , ref : VFolderID | QuotaScopeID | str | None ) -> Path :
27
36
return Path ()
@@ -32,32 +41,32 @@ async def create_quota_scope(
32
41
options : Optional [QuotaConfig ] = None ,
33
42
extra_args : Optional [dict [str , Any ]] = None ,
34
43
) -> None :
35
- raise NotImplementedError
44
+ pass
36
45
37
46
async def describe_quota_scope (
38
47
self ,
39
48
quota_scope_id : QuotaScopeID ,
40
49
) -> Optional [QuotaUsage ]:
41
- raise NotImplementedError
50
+ pass
42
51
43
52
async def update_quota_scope (
44
53
self ,
45
54
quota_scope_id : QuotaScopeID ,
46
55
config : QuotaConfig ,
47
56
) -> None :
48
- raise NotImplementedError
57
+ pass
49
58
50
59
async def unset_quota (
51
60
self ,
52
61
quota_scope_id : QuotaScopeID ,
53
62
) -> None :
54
- raise NotImplementedError
63
+ pass
55
64
56
65
async def delete_quota_scope (
57
66
self ,
58
67
quota_scope_id : QuotaScopeID ,
59
68
) -> None :
60
- raise NotImplementedError
69
+ pass
61
70
62
71
63
72
class NoopFSOpModel (AbstractFSOpModel ):
@@ -69,40 +78,40 @@ async def copy_tree(
69
78
src_path : Path ,
70
79
dst_path : Path ,
71
80
) -> None :
72
- raise NotImplementedError
81
+ pass
73
82
74
83
async def move_tree (
75
84
self ,
76
85
src_path : Path ,
77
86
dst_path : Path ,
78
87
) -> None :
79
- raise NotImplementedError
88
+ pass
80
89
81
90
async def delete_tree (
82
91
self ,
83
92
path : Path ,
84
93
) -> None :
85
- raise NotImplementedError
94
+ pass
86
95
87
96
def scan_tree (
88
97
self ,
89
98
path : Path ,
90
99
* ,
91
100
recursive : bool = True ,
92
101
) -> AsyncIterator [DirEntry ]:
93
- raise NotImplementedError
102
+ return _return_empty_dir_entry ()
94
103
95
104
async def scan_tree_usage (
96
105
self ,
97
106
path : Path ,
98
107
) -> TreeUsage :
99
- raise NotImplementedError
108
+ return TreeUsage ( 0 , 0 )
100
109
101
110
async def scan_tree_size (
102
111
self ,
103
112
path : Path ,
104
113
) -> BinarySize :
105
- raise NotImplementedError
114
+ return BinarySize ( 0 )
106
115
107
116
108
117
class NoopVolume (AbstractVolume ):
@@ -148,13 +157,13 @@ async def get_vfolder_mount(self, vfid: VFolderID, subpath: str) -> Path:
148
157
return Path ()
149
158
150
159
async def put_metadata (self , vfid : VFolderID , payload : bytes ) -> None :
151
- raise NotImplementedError
160
+ pass
152
161
153
162
async def get_metadata (self , vfid : VFolderID ) -> bytes :
154
- raise NotImplementedError
163
+ return b""
155
164
156
165
async def get_performance_metric (self ) -> FSPerfMetric :
157
- raise NotImplementedError
166
+ return FSPerfMetric ( 0 , 0 , 0 , 0 , 0.0 , 0.0 )
158
167
159
168
async def get_fs_usage (self ) -> CapacityUsage :
160
169
return CapacityUsage (0 , 0 )
@@ -178,7 +187,7 @@ def scandir(
178
187
* ,
179
188
recursive : bool = True ,
180
189
) -> AsyncIterator [DirEntry ]:
181
- raise NotImplementedError
190
+ return _return_empty_dir_entry ()
182
191
183
192
async def mkdir (
184
193
self ,
@@ -188,7 +197,7 @@ async def mkdir(
188
197
parents : bool = False ,
189
198
exist_ok : bool = False ,
190
199
) -> None :
191
- raise NotImplementedError
200
+ pass
192
201
193
202
async def rmdir (
194
203
self ,
@@ -197,42 +206,42 @@ async def rmdir(
197
206
* ,
198
207
recursive : bool = False ,
199
208
) -> None :
200
- raise NotImplementedError
209
+ pass
201
210
202
211
async def move_file (
203
212
self ,
204
213
vfid : VFolderID ,
205
214
src : PurePosixPath ,
206
215
dst : PurePosixPath ,
207
216
) -> None :
208
- raise NotImplementedError
217
+ pass
209
218
210
219
async def move_tree (
211
220
self ,
212
221
vfid : VFolderID ,
213
222
src : PurePosixPath ,
214
223
dst : PurePosixPath ,
215
224
) -> None :
216
- raise NotImplementedError
225
+ pass
217
226
218
227
async def copy_file (
219
228
self ,
220
229
vfid : VFolderID ,
221
230
src : PurePosixPath ,
222
231
dst : PurePosixPath ,
223
232
) -> None :
224
- raise NotImplementedError
233
+ pass
225
234
226
235
async def prepare_upload (self , vfid : VFolderID ) -> str :
227
- raise NotImplementedError
236
+ return ""
228
237
229
238
async def add_file (
230
239
self ,
231
240
vfid : VFolderID ,
232
241
relpath : PurePosixPath ,
233
242
payload : AsyncIterator [bytes ],
234
243
) -> None :
235
- raise NotImplementedError
244
+ pass
236
245
237
246
def read_file (
238
247
self ,
@@ -241,7 +250,10 @@ def read_file(
241
250
* ,
242
251
chunk_size : int = 0 ,
243
252
) -> AsyncIterator [bytes ]:
244
- raise NotImplementedError
253
+ async def _noop () -> AsyncIterator [bytes ]:
254
+ yield b""
255
+
256
+ return _noop ()
245
257
246
258
async def delete_files (
247
259
self ,
@@ -250,7 +262,7 @@ async def delete_files(
250
262
* ,
251
263
recursive : bool = False ,
252
264
) -> None :
253
- raise NotImplementedError
265
+ pass
254
266
255
267
256
268
def init_noop_volume (
0 commit comments