megfile 3.1.0.post2__py3-none-any.whl → 3.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- megfile/lib/base_prefetch_reader.py +13 -7
- megfile/lib/combine_reader.py +1 -0
- megfile/lib/glob.py +10 -3
- megfile/lib/s3_buffered_writer.py +3 -1
- megfile/lib/s3_cached_handler.py +3 -1
- megfile/lib/s3_limited_seekable_writer.py +1 -0
- megfile/lib/s3_memory_handler.py +3 -1
- megfile/lib/s3_pipe_handler.py +3 -1
- megfile/lib/shadow_handler.py +1 -0
- megfile/utils/__init__.py +3 -1
- megfile/version.py +1 -1
- {megfile-3.1.0.post2.dist-info → megfile-3.1.1.dist-info}/METADATA +1 -1
- {megfile-3.1.0.post2.dist-info → megfile-3.1.1.dist-info}/RECORD +18 -18
- {megfile-3.1.0.post2.dist-info → megfile-3.1.1.dist-info}/LICENSE +0 -0
- {megfile-3.1.0.post2.dist-info → megfile-3.1.1.dist-info}/LICENSE.pyre +0 -0
- {megfile-3.1.0.post2.dist-info → megfile-3.1.1.dist-info}/WHEEL +0 -0
- {megfile-3.1.0.post2.dist-info → megfile-3.1.1.dist-info}/entry_points.txt +0 -0
- {megfile-3.1.0.post2.dist-info → megfile-3.1.1.dist-info}/top_level.txt +0 -0
|
@@ -47,8 +47,15 @@ class BasePrefetchReader(Readable[bytes], Seekable, ABC):
|
|
|
47
47
|
if block_forward is None:
|
|
48
48
|
block_forward = max(block_capacity - 1, 1)
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if block_capacity <= block_forward:
|
|
51
|
+
# TODO: replace AssertionError with ValueError in 4.0.0
|
|
52
|
+
raise AssertionError(
|
|
53
|
+
'block_capacity should greater than block_forward, '
|
|
54
|
+
'got: block_capacity=%s, block_forward=%s' %
|
|
55
|
+
(block_capacity, block_forward))
|
|
56
|
+
|
|
57
|
+
# user maybe put block_size with 'numpy.uint64' type
|
|
58
|
+
block_size = int(block_size)
|
|
52
59
|
|
|
53
60
|
self._max_retries = max_retries
|
|
54
61
|
self._block_size = block_size
|
|
@@ -123,9 +130,9 @@ class BasePrefetchReader(Readable[bytes], Seekable, ABC):
|
|
|
123
130
|
|
|
124
131
|
Returns the new absolute position.
|
|
125
132
|
'''
|
|
133
|
+
offset = int(offset) # user maybe put offset with 'numpy.uint64' type
|
|
126
134
|
if self.closed:
|
|
127
135
|
raise IOError('file already closed: %r' % self.name)
|
|
128
|
-
|
|
129
136
|
if whence == os.SEEK_CUR:
|
|
130
137
|
target_offset = self._offset + offset
|
|
131
138
|
elif whence == os.SEEK_END:
|
|
@@ -159,10 +166,9 @@ class BasePrefetchReader(Readable[bytes], Seekable, ABC):
|
|
|
159
166
|
if self._offset >= self._content_size:
|
|
160
167
|
return b''
|
|
161
168
|
|
|
162
|
-
if size is None:
|
|
169
|
+
if size is None or size < 0:
|
|
163
170
|
size = self._content_size - self._offset
|
|
164
171
|
else:
|
|
165
|
-
assert size >= 0, 'size should greater than 0, got: %r' % size
|
|
166
172
|
size = min(size, self._content_size - self._offset)
|
|
167
173
|
|
|
168
174
|
if self._block_forward == 1:
|
|
@@ -196,6 +202,7 @@ class BasePrefetchReader(Readable[bytes], Seekable, ABC):
|
|
|
196
202
|
|
|
197
203
|
Retain newline. A non-negative size argument limits the maximum
|
|
198
204
|
number of bytes to return (an incomplete line may be returned then).
|
|
205
|
+
If the size argument is negative, read until EOF is reached.
|
|
199
206
|
Return an empty bytes object at EOF.
|
|
200
207
|
'''
|
|
201
208
|
if self.closed:
|
|
@@ -206,10 +213,9 @@ class BasePrefetchReader(Readable[bytes], Seekable, ABC):
|
|
|
206
213
|
if self._offset >= self._content_size:
|
|
207
214
|
return b''
|
|
208
215
|
|
|
209
|
-
if size is None:
|
|
216
|
+
if size is None or size < 0:
|
|
210
217
|
size = self._content_size - self._offset
|
|
211
218
|
else:
|
|
212
|
-
assert size >= 0, 'size should greater than 0, got: %r' % size
|
|
213
219
|
size = min(size, self._content_size - self._offset)
|
|
214
220
|
|
|
215
221
|
data = self._buffer.readline(size)
|
megfile/lib/combine_reader.py
CHANGED
|
@@ -99,6 +99,7 @@ class CombineReader(Readable, Seekable):
|
|
|
99
99
|
return buffer.getvalue() # pyre-ignore[7]
|
|
100
100
|
|
|
101
101
|
def seek(self, offset: int, whence: int = os.SEEK_SET) -> int:
|
|
102
|
+
offset = int(offset) # user maybe put offset with 'numpy.uint64' type
|
|
102
103
|
if whence == os.SEEK_SET:
|
|
103
104
|
target_offset = offset
|
|
104
105
|
elif whence == os.SEEK_CUR:
|
megfile/lib/glob.py
CHANGED
|
@@ -74,7 +74,9 @@ def iglob(
|
|
|
74
74
|
it = _iglob(pathname, recursive, False, fs)
|
|
75
75
|
if recursive and _isrecursive(pathname):
|
|
76
76
|
s = next(it) # skip empty string
|
|
77
|
-
|
|
77
|
+
if s:
|
|
78
|
+
# TODO: replace AssertionError with OSError in 4.0.0
|
|
79
|
+
raise AssertionError("iglob with recursive=True error")
|
|
78
80
|
return it
|
|
79
81
|
|
|
80
82
|
|
|
@@ -88,7 +90,10 @@ def _iglob(pathname: str, recursive: bool, dironly: bool,
|
|
|
88
90
|
if protocol:
|
|
89
91
|
dirname = "://".join([protocol, dirname])
|
|
90
92
|
if not has_magic(pathname):
|
|
91
|
-
|
|
93
|
+
if dironly:
|
|
94
|
+
# TODO: replace AssertionError with OSError in 4.0.0
|
|
95
|
+
raise AssertionError(
|
|
96
|
+
"can't use dironly with non-magic patterns in _iglob")
|
|
92
97
|
if basename:
|
|
93
98
|
if fs.exists(pathname):
|
|
94
99
|
yield pathname
|
|
@@ -150,7 +155,9 @@ def _glob0(dirname: str, basename: str, dironly: bool, fs: FSFunc) -> List[str]:
|
|
|
150
155
|
# directory.
|
|
151
156
|
def _glob2(dirname: str, pattern: str, dironly: bool,
|
|
152
157
|
fs: FSFunc) -> Iterator[str]:
|
|
153
|
-
|
|
158
|
+
if not _isrecursive(pattern):
|
|
159
|
+
# TODO: replace AssertionError with OSError in 4.0.0
|
|
160
|
+
raise AssertionError("error call '_glob2' with non-glob pattern")
|
|
154
161
|
yield pattern[:0]
|
|
155
162
|
yield from _rlistdir(dirname, dironly, fs)
|
|
156
163
|
|
|
@@ -53,7 +53,9 @@ class S3BufferedWriter(Writable[bytes]):
|
|
|
53
53
|
self._client = s3_client
|
|
54
54
|
self._profile_name = profile_name
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
# user maybe put block_size with 'numpy.uint64' type
|
|
57
|
+
self._block_size = int(block_size)
|
|
58
|
+
|
|
57
59
|
self._max_block_size = max_block_size
|
|
58
60
|
self._max_buffer_size = max_buffer_size
|
|
59
61
|
self._total_buffer_size = 0
|
megfile/lib/s3_cached_handler.py
CHANGED
|
@@ -19,7 +19,9 @@ class S3CachedHandler(S3MemoryHandler):
|
|
|
19
19
|
remove_cache_when_open: bool = True,
|
|
20
20
|
profile_name: Optional[str] = None):
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
if mode not in ('rb', 'wb', 'ab', 'rb+', 'wb+', 'ab+'):
|
|
23
|
+
# TODO: replace AssertionError with ValueError in 4.0.0
|
|
24
|
+
raise AssertionError('unacceptable mode: %r' % mode)
|
|
23
25
|
|
|
24
26
|
self._bucket = bucket
|
|
25
27
|
self._key = key
|
|
@@ -63,6 +63,7 @@ class S3LimitedSeekableWriter(S3BufferedWriter, Seekable):
|
|
|
63
63
|
if self.closed:
|
|
64
64
|
raise IOError('file already closed: %r' % self.name)
|
|
65
65
|
|
|
66
|
+
offset = int(offset) # user maybe put offset with 'numpy.uint64' type
|
|
66
67
|
if whence == os.SEEK_SET:
|
|
67
68
|
target_offset = offset
|
|
68
69
|
elif whence == os.SEEK_CUR:
|
megfile/lib/s3_memory_handler.py
CHANGED
|
@@ -17,7 +17,9 @@ class S3MemoryHandler(Readable[bytes], Seekable, Writable[bytes]):
|
|
|
17
17
|
s3_client,
|
|
18
18
|
profile_name: Optional[str] = None):
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
if mode not in ('rb', 'wb', 'ab', 'rb+', 'wb+', 'ab+'):
|
|
21
|
+
# TODO: replace AssertionError with ValueError in 4.0.0
|
|
22
|
+
raise AssertionError('unacceptable mode: %r' % mode)
|
|
21
23
|
|
|
22
24
|
self._bucket = bucket
|
|
23
25
|
self._key = key
|
megfile/lib/s3_pipe_handler.py
CHANGED
|
@@ -36,7 +36,9 @@ class S3PipeHandler(Readable[bytes], Writable[bytes]):
|
|
|
36
36
|
join_thread: bool = True,
|
|
37
37
|
profile_name: Optional[str] = None):
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
if mode not in ('rb', 'wb'):
|
|
40
|
+
# TODO: replace AssertionError with ValueError in 4.0.0
|
|
41
|
+
raise AssertionError('unacceptable mode: %r' % mode)
|
|
40
42
|
|
|
41
43
|
self._bucket = bucket
|
|
42
44
|
self._key = key
|
megfile/lib/shadow_handler.py
CHANGED
|
@@ -44,6 +44,7 @@ class ShadowHandler(Readable, Seekable, Writable, BaseShadowHandler):
|
|
|
44
44
|
return get_content_size(self._file_object, intrusive=self._intrusive)
|
|
45
45
|
|
|
46
46
|
def seek(self, offset: int, whence: int = os.SEEK_SET) -> int:
|
|
47
|
+
offset = int(offset) # user maybe put offset with 'numpy.uint64' type
|
|
47
48
|
if whence == os.SEEK_SET:
|
|
48
49
|
self._offset = offset
|
|
49
50
|
elif whence == os.SEEK_CUR:
|
megfile/utils/__init__.py
CHANGED
|
@@ -190,7 +190,9 @@ def binary_open(open_func):
|
|
|
190
190
|
|
|
191
191
|
def get_human_size(size_bytes: float) -> str:
|
|
192
192
|
'''Get human-readable size, e.g. `100MB`'''
|
|
193
|
-
|
|
193
|
+
if size_bytes < 0:
|
|
194
|
+
# TODO: replace AssertionError with ValueError in 4.0.0
|
|
195
|
+
raise AssertionError('negative size: %r' % size_bytes)
|
|
194
196
|
if size_bytes == 0:
|
|
195
197
|
return '0 B'
|
|
196
198
|
size_name = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')
|
megfile/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "3.1.
|
|
1
|
+
VERSION = "3.1.1"
|
|
@@ -19,37 +19,37 @@ megfile/smart.py,sha256=jOTBBbDKpLuRbob9-Omj_GRsk66Vpql7LPJX4xCm5fs,36024
|
|
|
19
19
|
megfile/smart_path.py,sha256=OMTM9JeowIa6j2Yn8XEH-HS4gWD3gBkKgSj8GBD08Bk,6734
|
|
20
20
|
megfile/stdio.py,sha256=rsBMGr4LaFYOQjL-6k4GE_WznLsa8cPzMhSVNEEDh5o,671
|
|
21
21
|
megfile/stdio_path.py,sha256=2n3gTEN1-7d8cCRsQJ7zj8rdP1VPlgr78oSClYndxXI,2806
|
|
22
|
-
megfile/version.py,sha256=
|
|
22
|
+
megfile/version.py,sha256=_DO4G2zWDcG7gSWIzdTDMHAx4XjUc5Vq4U89Oj2xeWY,19
|
|
23
23
|
megfile/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
-
megfile/lib/base_prefetch_reader.py,sha256=
|
|
25
|
-
megfile/lib/combine_reader.py,sha256=
|
|
24
|
+
megfile/lib/base_prefetch_reader.py,sha256=Di2xCkf-Pci7BvJs5sosymKT8sJfdgYY8fTHIk_LEBc,13471
|
|
25
|
+
megfile/lib/combine_reader.py,sha256=ePUMwDxdL1oPqgZLAj7RvHeJ5NROcjPWNwLMuiv7Z5M,4641
|
|
26
26
|
megfile/lib/compare.py,sha256=yG2fZve_gMg32rQVCdwixBdqgYRsjn-24TqhALQaOrA,2233
|
|
27
27
|
megfile/lib/compat.py,sha256=0wt3_atcYhSLCxUj_WuDlQa3E1atjZfwJQ12thiFh5Q,234
|
|
28
28
|
megfile/lib/fnmatch.py,sha256=qtlTdOoowgUvQuZNDrzvEl7hA4Sdtifa9eXd47LEJZY,4082
|
|
29
|
-
megfile/lib/glob.py,sha256=
|
|
29
|
+
megfile/lib/glob.py,sha256=imsjV_lgCLteEacrId0uJU7w77A0tpRrAcKtWfUrzDU,10149
|
|
30
30
|
megfile/lib/hdfs_prefetch_reader.py,sha256=ytp0td83M8NheMCBtQjrQpvGaBvConpRqgd8xSqdi-E,2092
|
|
31
31
|
megfile/lib/hdfs_tools.py,sha256=t4GeoBxO0HPahIQDrsK17WBsLZtcfAaNwWfappzZ5q8,442
|
|
32
32
|
megfile/lib/http_prefetch_reader.py,sha256=Owc_eaDGS752QnzatOnZ3zp19DuuftxWPS8kTXidi1A,4359
|
|
33
33
|
megfile/lib/joinpath.py,sha256=D4Px6-lnDDpYs1LMUHkTIGqMPJQ0oCBGfTzREs373iU,929
|
|
34
34
|
megfile/lib/lazy_handler.py,sha256=V_dQR2ac7LXJ6u__R5_VauvmxqQVdjydNIKwJjYUBeQ,1862
|
|
35
|
-
megfile/lib/s3_buffered_writer.py,sha256=
|
|
36
|
-
megfile/lib/s3_cached_handler.py,sha256=
|
|
37
|
-
megfile/lib/s3_limited_seekable_writer.py,sha256=
|
|
38
|
-
megfile/lib/s3_memory_handler.py,sha256=
|
|
39
|
-
megfile/lib/s3_pipe_handler.py,sha256=
|
|
35
|
+
megfile/lib/s3_buffered_writer.py,sha256=UW_C6dtvzIEydapsHnPYWMn2xmz0Ah0jD7hrdUxqcoM,7127
|
|
36
|
+
megfile/lib/s3_cached_handler.py,sha256=1laCBQxG_PMp7Tk9_wY9XXDF-Ev4EREt1LPojetiA6A,1530
|
|
37
|
+
megfile/lib/s3_limited_seekable_writer.py,sha256=6Hzy8sdiRDQMQ0os175weu5vYUfcEP-L4ztknCQETf8,6318
|
|
38
|
+
megfile/lib/s3_memory_handler.py,sha256=02yivynhVWLKWtdf0_3N1-ipYOSGgFEmutYkpXzrXUU,4225
|
|
39
|
+
megfile/lib/s3_pipe_handler.py,sha256=9dcW0WKmjETLjK-m6QW4EvuvaEjCqUI9BavOeWmuB6Y,3705
|
|
40
40
|
megfile/lib/s3_prefetch_reader.py,sha256=ofzSn_MC6INAZY83oA3Dq1QNI0SS2b-NP6Ov8ajjLos,4283
|
|
41
41
|
megfile/lib/s3_share_cache_reader.py,sha256=AFwpyFQq4y-PXTnbFoXxLMQOJFIcJXUgVTrDMCuAMUg,3629
|
|
42
|
-
megfile/lib/shadow_handler.py,sha256=
|
|
42
|
+
megfile/lib/shadow_handler.py,sha256=Kb4CcfoMBdp822A5teSjNVG_6waAy5AUUHrW1qaRqEI,2722
|
|
43
43
|
megfile/lib/stdio_handler.py,sha256=t2hxBE1vo25-kS6QQRMiDEG95rdMVx2z6wTnwuN6NUc,1968
|
|
44
44
|
megfile/lib/url.py,sha256=VbQLjo0s4AaV0iSk66BcjI68aUTcN9zBZ5x6-cM4Qvs,103
|
|
45
|
-
megfile/utils/__init__.py,sha256=
|
|
45
|
+
megfile/utils/__init__.py,sha256=5gf_KfoqCvX6sVNLLZYUsGJL_zzesuQPj0znGC-HG8I,8946
|
|
46
46
|
megfile/utils/mutex.py,sha256=-2KH3bNovKRd9zvsXq9n3bWM7rQdoG9hO7tUPxVG_Po,2538
|
|
47
47
|
scripts/convert_results_to_sarif.py,sha256=SI0vw4TrpJ9gAZ2pH8ywu-lXMYeZ-TYW2dLEHw5Rx84,4218
|
|
48
48
|
scripts/generate_file.py,sha256=OLAH9iZKQlHTjuV8zpC6exCXLS6bNdu4Njoc3IKO9Sc,10173
|
|
49
|
-
megfile-3.1.
|
|
50
|
-
megfile-3.1.
|
|
51
|
-
megfile-3.1.
|
|
52
|
-
megfile-3.1.
|
|
53
|
-
megfile-3.1.
|
|
54
|
-
megfile-3.1.
|
|
55
|
-
megfile-3.1.
|
|
49
|
+
megfile-3.1.1.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
50
|
+
megfile-3.1.1.dist-info/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
|
|
51
|
+
megfile-3.1.1.dist-info/METADATA,sha256=honpFcwkQykVvHhlx_PQlEfOh6TgkPgk2FbdspMjc64,9106
|
|
52
|
+
megfile-3.1.1.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
53
|
+
megfile-3.1.1.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
|
|
54
|
+
megfile-3.1.1.dist-info/top_level.txt,sha256=oTnYXo1Z3V61qSWAKtnY9RkDgRSHvfRN38FQae6E0W0,50
|
|
55
|
+
megfile-3.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|