megfile 2.2.8__py3-none-any.whl → 2.2.8.post1__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/cli.py +4 -3
- megfile/http_path.py +61 -2
- megfile/sftp_path.py +1 -0
- megfile/version.py +1 -1
- {megfile-2.2.8.dist-info → megfile-2.2.8.post1.dist-info}/METADATA +1 -1
- {megfile-2.2.8.dist-info → megfile-2.2.8.post1.dist-info}/RECORD +11 -11
- {megfile-2.2.8.dist-info → megfile-2.2.8.post1.dist-info}/LICENSE +0 -0
- {megfile-2.2.8.dist-info → megfile-2.2.8.post1.dist-info}/LICENSE.pyre +0 -0
- {megfile-2.2.8.dist-info → megfile-2.2.8.post1.dist-info}/WHEEL +0 -0
- {megfile-2.2.8.dist-info → megfile-2.2.8.post1.dist-info}/entry_points.txt +0 -0
- {megfile-2.2.8.dist-info → megfile-2.2.8.post1.dist-info}/top_level.txt +0 -0
megfile/cli.py
CHANGED
|
@@ -13,7 +13,7 @@ from tqdm import tqdm
|
|
|
13
13
|
from megfile.hdfs_path import DEFAULT_HDFS_TIMEOUT
|
|
14
14
|
from megfile.interfaces import FileEntry
|
|
15
15
|
from megfile.lib.glob import get_non_glob_dir, has_magic
|
|
16
|
-
from megfile.smart import _smart_sync_single_file, smart_copy, smart_getmd5, smart_getmtime, smart_getsize, smart_glob_stat, smart_isdir, smart_isfile, smart_makedirs, smart_move, smart_open, smart_path_join, smart_remove, smart_rename, smart_scan_stat, smart_scandir, smart_stat, smart_sync, smart_sync_with_progress, smart_touch, smart_unlink
|
|
16
|
+
from megfile.smart import _smart_sync_single_file, smart_copy, smart_exists, smart_getmd5, smart_getmtime, smart_getsize, smart_glob_stat, smart_isdir, smart_isfile, smart_makedirs, smart_move, smart_open, smart_path_join, smart_remove, smart_rename, smart_scan_stat, smart_scandir, smart_stat, smart_sync, smart_sync_with_progress, smart_touch, smart_unlink
|
|
17
17
|
from megfile.smart_path import SmartPath
|
|
18
18
|
from megfile.utils import get_human_size
|
|
19
19
|
from megfile.version import VERSION
|
|
@@ -288,7 +288,7 @@ def sync(
|
|
|
288
288
|
src_root_path = get_non_glob_dir(src_path)
|
|
289
289
|
|
|
290
290
|
def scan_func(path):
|
|
291
|
-
for glob_file_entry in smart_glob_stat(path):
|
|
291
|
+
for glob_file_entry in smart_glob_stat(path, missing_ok=False):
|
|
292
292
|
if glob_file_entry.is_file():
|
|
293
293
|
yield glob_file_entry
|
|
294
294
|
else:
|
|
@@ -297,7 +297,8 @@ def sync(
|
|
|
297
297
|
yield file_entry
|
|
298
298
|
else:
|
|
299
299
|
src_root_path = src_path
|
|
300
|
-
scan_func = partial(
|
|
300
|
+
scan_func = partial(
|
|
301
|
+
smart_scan_stat, followlinks=True, missing_ok=False)
|
|
301
302
|
|
|
302
303
|
if progress_bar and not quiet:
|
|
303
304
|
print('building progress bar', end='\r')
|
megfile/http_path.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import io
|
|
1
2
|
import time
|
|
2
3
|
from functools import partial
|
|
3
4
|
from io import BufferedReader
|
|
4
5
|
from logging import getLogger as get_logger
|
|
5
|
-
from typing import Iterable, Optional, Union
|
|
6
|
+
from typing import Iterable, Iterator, Optional, Union
|
|
6
7
|
|
|
7
8
|
import requests
|
|
8
9
|
|
|
@@ -31,7 +32,8 @@ max_retries = 10
|
|
|
31
32
|
|
|
32
33
|
def get_http_session(
|
|
33
34
|
timeout: int = 10,
|
|
34
|
-
status_forcelist: Iterable[int] = (502, 503,
|
|
35
|
+
status_forcelist: Iterable[int] = (500, 502, 503,
|
|
36
|
+
504)) -> requests.Session:
|
|
35
37
|
session = requests.Session()
|
|
36
38
|
|
|
37
39
|
def after_callback(response, *args, **kwargs):
|
|
@@ -44,12 +46,69 @@ def get_http_session(
|
|
|
44
46
|
'send http request: %s %r, with parameters: %s', method, url,
|
|
45
47
|
kwargs)
|
|
46
48
|
|
|
49
|
+
def retry_callback(
|
|
50
|
+
error,
|
|
51
|
+
method,
|
|
52
|
+
url,
|
|
53
|
+
params=None,
|
|
54
|
+
data=None,
|
|
55
|
+
headers=None,
|
|
56
|
+
cookies=None,
|
|
57
|
+
files=None,
|
|
58
|
+
auth=None,
|
|
59
|
+
timeout=None,
|
|
60
|
+
allow_redirects=True,
|
|
61
|
+
proxies=None,
|
|
62
|
+
hooks=None,
|
|
63
|
+
stream=None,
|
|
64
|
+
verify=None,
|
|
65
|
+
cert=None,
|
|
66
|
+
json=None,
|
|
67
|
+
**kwargs,
|
|
68
|
+
):
|
|
69
|
+
if data and hasattr(data, 'seek'):
|
|
70
|
+
data.seek(0)
|
|
71
|
+
elif isinstance(data, Iterator):
|
|
72
|
+
_logger.warning(f'Can not retry http request with iterator data')
|
|
73
|
+
raise
|
|
74
|
+
if files:
|
|
75
|
+
|
|
76
|
+
def seek_or_reopen(file_object):
|
|
77
|
+
if isinstance(file_object, (str, bytes)):
|
|
78
|
+
return file_object
|
|
79
|
+
elif hasattr(file_object, 'seek'):
|
|
80
|
+
file_object.seek(0)
|
|
81
|
+
return file_object
|
|
82
|
+
elif hasattr(file_object, 'name'):
|
|
83
|
+
with SmartPath(file_object.name).open('rb') as f:
|
|
84
|
+
return io.BytesIO(f.read())
|
|
85
|
+
else:
|
|
86
|
+
_logger.warning(
|
|
87
|
+
f'Can not retry http request, because the file object is not seekable and unsupport "name"'
|
|
88
|
+
)
|
|
89
|
+
raise
|
|
90
|
+
|
|
91
|
+
for key, file_info in files.items():
|
|
92
|
+
if hasattr(file_info, 'seek'):
|
|
93
|
+
file_info.seek(0)
|
|
94
|
+
elif isinstance(file_info,
|
|
95
|
+
(tuple, list)) and len(file_info) >= 2:
|
|
96
|
+
file_info = list(file_info)
|
|
97
|
+
if isinstance(file_info[1],
|
|
98
|
+
(tuple, list)) and len(file_info[1]) >= 2:
|
|
99
|
+
file_info[1] = list(file_info[1])
|
|
100
|
+
file_info[1] = seek_or_reopen(file_info[1])
|
|
101
|
+
else:
|
|
102
|
+
file_info[1] = seek_or_reopen(file_info[1])
|
|
103
|
+
files[key] = file_info
|
|
104
|
+
|
|
47
105
|
session.request = patch_method(
|
|
48
106
|
partial(session.request, timeout=timeout),
|
|
49
107
|
max_retries=max_retries,
|
|
50
108
|
should_retry=http_should_retry,
|
|
51
109
|
before_callback=before_callback,
|
|
52
110
|
after_callback=after_callback,
|
|
111
|
+
retry_callback=retry_callback,
|
|
53
112
|
)
|
|
54
113
|
return session
|
|
55
114
|
|
megfile/sftp_path.py
CHANGED
megfile/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "2.2.8"
|
|
1
|
+
VERSION = "2.2.8.post1"
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
megfile/__init__.py,sha256=MT8SIXsmEUvtSpd1GHv6e3fFfR1gRnlEdkNNqv3gngo,6534
|
|
2
|
-
megfile/cli.py,sha256=
|
|
2
|
+
megfile/cli.py,sha256=lzIMM13Kqd06H7tudM6Yw2OKxXnLC369cv15ggVtMyc,20002
|
|
3
3
|
megfile/errors.py,sha256=ATLYeKgfppA3cb1lNwzWf0AcKAJksr6KXPglpJa2j2w,13198
|
|
4
4
|
megfile/fs.py,sha256=OfY0z4GSl8fT3mDGdeqP2hWFsd1QJl-h8RkSbg6-M8I,11547
|
|
5
5
|
megfile/fs_path.py,sha256=CyOd_hOFGaYeq8CLSqF3B3ns52GMuugy9b5PD-yK0I4,38789
|
|
6
6
|
megfile/hdfs.py,sha256=aAkHobOO0nDcLoqj0tx_1tvgoLOCooTWuukq0pO-nQA,9156
|
|
7
7
|
megfile/hdfs_path.py,sha256=tgB2-lOqscnLRttyhm6gaD3WE-txYV6bqTH0kHeW2T8,26644
|
|
8
8
|
megfile/http.py,sha256=a3oAuARSSaIU8VMx86Mui0N5Vh-EI0AoHnwxRU5DSMU,2032
|
|
9
|
-
megfile/http_path.py,sha256=
|
|
9
|
+
megfile/http_path.py,sha256=pbMPE5bK7rjoFXBHVVD-O9BtPnFwsK1boHBJg6YERcQ,11420
|
|
10
10
|
megfile/interfaces.py,sha256=h3tWE8hVt5S-HopaMAX6lunPJ97vzhv6jH_2HubcDNc,6219
|
|
11
11
|
megfile/pathlike.py,sha256=Ere6tMf2nsI7bDsZo0WBzl_2HRrS_4iKOpYp0zZltAU,29487
|
|
12
12
|
megfile/s3.py,sha256=siBZfveWX1TDA4Mp41UvugcG3zlrhl_iPUbixUp1TmI,12352
|
|
13
13
|
megfile/s3_path.py,sha256=-u4g6uQ2JuMuzgvjw4KMmdF3jXAGkRy2kRRgAGcEgQ8,88778
|
|
14
14
|
megfile/sftp.py,sha256=JCkF2v1ZbHuIy_Bg3l85AesjFDimDzx9Gh1gRoMsahc,12524
|
|
15
|
-
megfile/sftp_path.py,sha256=
|
|
15
|
+
megfile/sftp_path.py,sha256=gz0tW3FUSY44kqoEygBMfq-WJR4vxaOuu850j-zZbtI,50576
|
|
16
16
|
megfile/smart.py,sha256=JH5zed90eQchS8GNQ7mbXvif-pNKjPjvnadMazKfQMs,33278
|
|
17
17
|
megfile/smart_path.py,sha256=Y0UFh4J2ccydRY2W-wX2ubaf9zzJx1M2nf-VLBGe4mk,6749
|
|
18
18
|
megfile/stdio.py,sha256=yRhlfUA2DHi3bq-9cXsSlbLCnHvS_zvglO2IYYyPsGc,707
|
|
19
19
|
megfile/stdio_path.py,sha256=eQulTXUwHvUKA-5PKCGfVNiEPkJhG9YtVhtU58OcmoM,2873
|
|
20
|
-
megfile/version.py,sha256=
|
|
20
|
+
megfile/version.py,sha256=9139fPUG0s02fyUGMvGdaft44dmi26CtzBhSkOtlTw0,25
|
|
21
21
|
megfile/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
megfile/lib/base_prefetch_reader.py,sha256=SjrBffHVgvJnYtr8HNqiOozP9OJRYS37Eu1KQcZu1Z8,13221
|
|
23
23
|
megfile/lib/combine_reader.py,sha256=XFSqEY5A5X5Uf7eQ6AXAzrvNteESSXvKNVPktGjo3KY,4546
|
|
@@ -42,10 +42,10 @@ megfile/lib/stdio_handler.py,sha256=QDWtcZxz-hzi-rqQUiSlR3NrihX1fjK_Rj9T2mdTFEg,
|
|
|
42
42
|
megfile/lib/url.py,sha256=VbQLjo0s4AaV0iSk66BcjI68aUTcN9zBZ5x6-cM4Qvs,103
|
|
43
43
|
megfile/utils/__init__.py,sha256=qdX8FF_dYFKwp1BIWx3JeSGd91s7AKUDSEpDv9tORcM,9162
|
|
44
44
|
megfile/utils/mutex.py,sha256=-2KH3bNovKRd9zvsXq9n3bWM7rQdoG9hO7tUPxVG_Po,2538
|
|
45
|
-
megfile-2.2.8.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
46
|
-
megfile-2.2.8.dist-info/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
|
|
47
|
-
megfile-2.2.8.dist-info/METADATA,sha256=
|
|
48
|
-
megfile-2.2.8.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
49
|
-
megfile-2.2.8.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
|
|
50
|
-
megfile-2.2.8.dist-info/top_level.txt,sha256=i3rMgdU1ZAJekAceojhA-bkm3749PzshtRmLTbeLUPQ,8
|
|
51
|
-
megfile-2.2.8.dist-info/RECORD,,
|
|
45
|
+
megfile-2.2.8.post1.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
46
|
+
megfile-2.2.8.post1.dist-info/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
|
|
47
|
+
megfile-2.2.8.post1.dist-info/METADATA,sha256=tEAeR70I3W2r9ZDfy5uxC5tAhG43ghUfmU84qnFggYg,8968
|
|
48
|
+
megfile-2.2.8.post1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
49
|
+
megfile-2.2.8.post1.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
|
|
50
|
+
megfile-2.2.8.post1.dist-info/top_level.txt,sha256=i3rMgdU1ZAJekAceojhA-bkm3749PzshtRmLTbeLUPQ,8
|
|
51
|
+
megfile-2.2.8.post1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|