megfile 2.2.10.post1__py3-none-any.whl → 3.0.0.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 +20 -15
- megfile/fs_path.py +1 -1
- megfile/lib/compat.py +0 -71
- megfile/version.py +1 -1
- {megfile-2.2.10.post1.dist-info → megfile-3.0.0.post1.dist-info}/METADATA +3 -4
- {megfile-2.2.10.post1.dist-info → megfile-3.0.0.post1.dist-info}/RECORD +11 -11
- {megfile-2.2.10.post1.dist-info → megfile-3.0.0.post1.dist-info}/LICENSE +0 -0
- {megfile-2.2.10.post1.dist-info → megfile-3.0.0.post1.dist-info}/LICENSE.pyre +0 -0
- {megfile-2.2.10.post1.dist-info → megfile-3.0.0.post1.dist-info}/WHEEL +0 -0
- {megfile-2.2.10.post1.dist-info → megfile-3.0.0.post1.dist-info}/entry_points.txt +0 -0
- {megfile-2.2.10.post1.dist-info → megfile-3.0.0.post1.dist-info}/top_level.txt +0 -0
megfile/cli.py
CHANGED
|
@@ -14,7 +14,7 @@ from megfile.config import DEFAULT_BLOCK_SIZE
|
|
|
14
14
|
from megfile.hdfs_path import DEFAULT_HDFS_TIMEOUT
|
|
15
15
|
from megfile.interfaces import FileEntry
|
|
16
16
|
from megfile.lib.glob import get_non_glob_dir, has_magic
|
|
17
|
-
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
|
+
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_readlink, smart_realpath, smart_remove, smart_rename, smart_scan_stat, smart_scandir, smart_stat, smart_sync, smart_sync_with_progress, smart_touch, smart_unlink
|
|
18
18
|
from megfile.smart_path import SmartPath
|
|
19
19
|
from megfile.utils import get_human_size
|
|
20
20
|
from megfile.version import VERSION
|
|
@@ -58,25 +58,23 @@ def get_echo_path(file_stat, base_path: str = "", full_path: bool = False):
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
def simple_echo(file_stat, base_path: str = "", full_path: bool = False):
|
|
61
|
-
|
|
61
|
+
return get_echo_path(file_stat, base_path, full_path)
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
def long_echo(file_stat, base_path: str = "", full_path: bool = False):
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
time.
|
|
69
|
-
|
|
70
|
-
get_echo_path(file_stat, base_path, full_path)))
|
|
65
|
+
return '%12d %s %s' % (
|
|
66
|
+
file_stat.stat.size,
|
|
67
|
+
time.strftime(
|
|
68
|
+
"%Y-%m-%d %H:%M:%S", time.localtime(file_stat.stat.mtime)),
|
|
69
|
+
get_echo_path(file_stat, base_path, full_path))
|
|
71
70
|
|
|
72
71
|
|
|
73
72
|
def human_echo(file_stat, base_path: str = "", full_path: bool = False):
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
time.
|
|
78
|
-
|
|
79
|
-
get_echo_path(file_stat, base_path, full_path)))
|
|
73
|
+
return '%10s %s %s' % (
|
|
74
|
+
get_human_size(file_stat.stat.size),
|
|
75
|
+
time.strftime(
|
|
76
|
+
"%Y-%m-%d %H:%M:%S", time.localtime(file_stat.stat.mtime)),
|
|
77
|
+
get_echo_path(file_stat, base_path, full_path))
|
|
80
78
|
|
|
81
79
|
|
|
82
80
|
def smart_list_stat(path):
|
|
@@ -108,7 +106,14 @@ def _ls(path: str, long: bool, recursive: bool, human_readable: bool):
|
|
|
108
106
|
total_size = 0
|
|
109
107
|
for file_stat in scan_func(path):
|
|
110
108
|
total_size += file_stat.stat.size
|
|
111
|
-
echo_func(file_stat, base_path, full_path=full_path)
|
|
109
|
+
output = echo_func(file_stat, base_path, full_path=full_path)
|
|
110
|
+
if file_stat.is_symlink():
|
|
111
|
+
try:
|
|
112
|
+
link = smart_readlink(file_stat.path)
|
|
113
|
+
except FileNotFoundError as e:
|
|
114
|
+
link = repr(e)
|
|
115
|
+
output += ' -> %s' % link
|
|
116
|
+
click.echo(output)
|
|
112
117
|
if long:
|
|
113
118
|
click.echo(f'total: {get_human_size(total_size)}')
|
|
114
119
|
|
megfile/fs_path.py
CHANGED
|
@@ -3,6 +3,7 @@ import io
|
|
|
3
3
|
import os
|
|
4
4
|
import pathlib
|
|
5
5
|
import shutil
|
|
6
|
+
from shutil import copytree
|
|
6
7
|
from stat import S_ISDIR as stat_isdir
|
|
7
8
|
from stat import S_ISLNK as stat_islnk
|
|
8
9
|
from typing import IO, AnyStr, BinaryIO, Callable, Iterator, List, Optional, Tuple, Union
|
|
@@ -10,7 +11,6 @@ from typing import IO, AnyStr, BinaryIO, Callable, Iterator, List, Optional, Tup
|
|
|
10
11
|
from megfile.errors import _create_missing_ok_generator
|
|
11
12
|
from megfile.interfaces import Access, ContextIterator, FileEntry, PathLike, StatResult
|
|
12
13
|
from megfile.lib.compare import is_same_file
|
|
13
|
-
from megfile.lib.compat import copytree
|
|
14
14
|
from megfile.lib.glob import iglob
|
|
15
15
|
from megfile.lib.url import get_url_scheme
|
|
16
16
|
from megfile.utils import cachedproperty, calculate_md5
|
megfile/lib/compat.py
CHANGED
|
@@ -13,74 +13,3 @@ def fspath(path) -> str:
|
|
|
13
13
|
if isinstance(result, bytes):
|
|
14
14
|
return result.decode()
|
|
15
15
|
return result
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import sys
|
|
19
|
-
|
|
20
|
-
if sys.version_info.major == 3 and sys.version_info.minor >= 8:
|
|
21
|
-
from shutil import copytree
|
|
22
|
-
else: # pragma: no cover
|
|
23
|
-
from shutil import Error, copy2, copystat
|
|
24
|
-
|
|
25
|
-
def copytree(
|
|
26
|
-
src,
|
|
27
|
-
dst,
|
|
28
|
-
symlinks=False,
|
|
29
|
-
ignore=None,
|
|
30
|
-
copy_function=copy2,
|
|
31
|
-
ignore_dangling_symlinks=False,
|
|
32
|
-
dirs_exist_ok=False):
|
|
33
|
-
names = os.listdir(src)
|
|
34
|
-
if ignore is not None:
|
|
35
|
-
ignored_names = ignore(src, names)
|
|
36
|
-
else:
|
|
37
|
-
ignored_names = set()
|
|
38
|
-
|
|
39
|
-
os.makedirs(dst, exist_ok=dirs_exist_ok)
|
|
40
|
-
errors = []
|
|
41
|
-
for name in names:
|
|
42
|
-
if name in ignored_names:
|
|
43
|
-
continue
|
|
44
|
-
srcname = os.path.join(src, name)
|
|
45
|
-
dstname = os.path.join(dst, name)
|
|
46
|
-
try:
|
|
47
|
-
if os.path.islink(srcname):
|
|
48
|
-
linkto = os.readlink(srcname)
|
|
49
|
-
if symlinks:
|
|
50
|
-
# We can't just leave it to `copy_function` because legacy
|
|
51
|
-
# code with a custom `copy_function` may rely on copytree
|
|
52
|
-
# doing the right thing.
|
|
53
|
-
os.symlink(linkto, dstname)
|
|
54
|
-
copystat(srcname, dstname, follow_symlinks=not symlinks)
|
|
55
|
-
else:
|
|
56
|
-
# ignore dangling symlink if the flag is on
|
|
57
|
-
if not os.path.exists(
|
|
58
|
-
linkto) and ignore_dangling_symlinks:
|
|
59
|
-
continue
|
|
60
|
-
# otherwise let the copy occurs. copy2 will raise an error
|
|
61
|
-
if os.path.isdir(srcname):
|
|
62
|
-
copytree(
|
|
63
|
-
srcname, dstname, symlinks, ignore,
|
|
64
|
-
copy_function)
|
|
65
|
-
else:
|
|
66
|
-
copy_function(srcname, dstname)
|
|
67
|
-
elif os.path.isdir(srcname):
|
|
68
|
-
copytree(srcname, dstname, symlinks, ignore, copy_function)
|
|
69
|
-
else:
|
|
70
|
-
# Will raise a SpecialFileError for unsupported file types
|
|
71
|
-
copy_function(srcname, dstname)
|
|
72
|
-
# catch the Error from the recursive copytree so that we can
|
|
73
|
-
# continue with other files
|
|
74
|
-
except Error as err:
|
|
75
|
-
errors.extend(err.args[0])
|
|
76
|
-
except OSError as why:
|
|
77
|
-
errors.append((srcname, dstname, str(why)))
|
|
78
|
-
try:
|
|
79
|
-
copystat(src, dst)
|
|
80
|
-
except OSError as why:
|
|
81
|
-
# Copying file access times may fail on Windows
|
|
82
|
-
if getattr(why, 'winerror', None) is None:
|
|
83
|
-
errors.append((src, dst, str(why)))
|
|
84
|
-
if errors:
|
|
85
|
-
raise Error(errors)
|
|
86
|
-
return dst
|
megfile/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "
|
|
1
|
+
VERSION = "3.0.0.post1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: megfile
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0.post1
|
|
4
4
|
Summary: Megvii file operation library
|
|
5
5
|
Home-page: https://github.com/megvii-research/megfile
|
|
6
6
|
Author: megvii
|
|
@@ -13,13 +13,12 @@ Classifier: Operating System :: POSIX :: Linux
|
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.8
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Requires-Python: >=3.8
|
|
23
22
|
Description-Content-Type: text/markdown
|
|
24
23
|
License-File: LICENSE
|
|
25
24
|
License-File: LICENSE.pyre
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
megfile/__init__.py,sha256=MT8SIXsmEUvtSpd1GHv6e3fFfR1gRnlEdkNNqv3gngo,6534
|
|
2
|
-
megfile/cli.py,sha256=
|
|
2
|
+
megfile/cli.py,sha256=yaECF7bn-_QjeK6MLnZgvgJjIHcUIQrrKVl_JaxOEDo,21283
|
|
3
3
|
megfile/config.py,sha256=Mz91CpRJJtepidOPXs98wYskmbbHRByG1VCeKJ81kVg,658
|
|
4
4
|
megfile/errors.py,sha256=Sbx3UEKnzuyUmB1tFU9cZv61Yr4dRa79J6D0UMmkvj4,13323
|
|
5
5
|
megfile/fs.py,sha256=OfY0z4GSl8fT3mDGdeqP2hWFsd1QJl-h8RkSbg6-M8I,11547
|
|
6
|
-
megfile/fs_path.py,sha256=
|
|
6
|
+
megfile/fs_path.py,sha256=sHn-sBcvq7SvYN71onkA_ssLs71NzM1MM3d3Sug8uzo,38237
|
|
7
7
|
megfile/hdfs.py,sha256=aAkHobOO0nDcLoqj0tx_1tvgoLOCooTWuukq0pO-nQA,9156
|
|
8
8
|
megfile/hdfs_path.py,sha256=rVmdHydhe0x6Vn7hblewghiWZIdZswe4hfxLOHm8vCM,26677
|
|
9
9
|
megfile/http.py,sha256=a3oAuARSSaIU8VMx86Mui0N5Vh-EI0AoHnwxRU5DSMU,2032
|
|
@@ -18,12 +18,12 @@ megfile/smart.py,sha256=YoRvxEaZ_C-A5gQlFEs4sGBJ6D26s0qYEBJEcny_jBg,33416
|
|
|
18
18
|
megfile/smart_path.py,sha256=Y0UFh4J2ccydRY2W-wX2ubaf9zzJx1M2nf-VLBGe4mk,6749
|
|
19
19
|
megfile/stdio.py,sha256=yRhlfUA2DHi3bq-9cXsSlbLCnHvS_zvglO2IYYyPsGc,707
|
|
20
20
|
megfile/stdio_path.py,sha256=eQulTXUwHvUKA-5PKCGfVNiEPkJhG9YtVhtU58OcmoM,2873
|
|
21
|
-
megfile/version.py,sha256=
|
|
21
|
+
megfile/version.py,sha256=kMj-Zcr5CPQqqnyAXYysUF5loOzPHPIw9kUQCBiOepA,25
|
|
22
22
|
megfile/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
megfile/lib/base_prefetch_reader.py,sha256=9HT0tcgXa95BdbyclpDEDw8WwKi6091GRQerS90-pjE,13191
|
|
24
24
|
megfile/lib/combine_reader.py,sha256=XFSqEY5A5X5Uf7eQ6AXAzrvNteESSXvKNVPktGjo3KY,4546
|
|
25
25
|
megfile/lib/compare.py,sha256=yG2fZve_gMg32rQVCdwixBdqgYRsjn-24TqhALQaOrA,2233
|
|
26
|
-
megfile/lib/compat.py,sha256=
|
|
26
|
+
megfile/lib/compat.py,sha256=0wt3_atcYhSLCxUj_WuDlQa3E1atjZfwJQ12thiFh5Q,234
|
|
27
27
|
megfile/lib/fnmatch.py,sha256=HgdlnEWBsdFUOZqnW_v1kj1jeH_9lMcCqW85pyMu4vM,4054
|
|
28
28
|
megfile/lib/glob.py,sha256=7i9dIput9rI9JIPyTZX-JDmFS7IP_THlX1k-35foAfw,9732
|
|
29
29
|
megfile/lib/hdfs_prefetch_reader.py,sha256=peLUau0xas33IWOoNTOJECud_r3oJYEHBXblUALO1lY,2040
|
|
@@ -43,10 +43,10 @@ megfile/lib/stdio_handler.py,sha256=QDWtcZxz-hzi-rqQUiSlR3NrihX1fjK_Rj9T2mdTFEg,
|
|
|
43
43
|
megfile/lib/url.py,sha256=VbQLjo0s4AaV0iSk66BcjI68aUTcN9zBZ5x6-cM4Qvs,103
|
|
44
44
|
megfile/utils/__init__.py,sha256=qdX8FF_dYFKwp1BIWx3JeSGd91s7AKUDSEpDv9tORcM,9162
|
|
45
45
|
megfile/utils/mutex.py,sha256=-2KH3bNovKRd9zvsXq9n3bWM7rQdoG9hO7tUPxVG_Po,2538
|
|
46
|
-
megfile-
|
|
47
|
-
megfile-
|
|
48
|
-
megfile-
|
|
49
|
-
megfile-
|
|
50
|
-
megfile-
|
|
51
|
-
megfile-
|
|
52
|
-
megfile-
|
|
46
|
+
megfile-3.0.0.post1.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
47
|
+
megfile-3.0.0.post1.dist-info/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
|
|
48
|
+
megfile-3.0.0.post1.dist-info/METADATA,sha256=8JE1q74gWq4onYy2ws28_CiXNsNHdRgS0_bf4TQvky8,8922
|
|
49
|
+
megfile-3.0.0.post1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
50
|
+
megfile-3.0.0.post1.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
|
|
51
|
+
megfile-3.0.0.post1.dist-info/top_level.txt,sha256=i3rMgdU1ZAJekAceojhA-bkm3749PzshtRmLTbeLUPQ,8
|
|
52
|
+
megfile-3.0.0.post1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|