megfile 5.0.4__py3-none-any.whl → 5.0.5__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 +13 -0
- megfile/lib/base_memory_handler.py +2 -2
- megfile/utils/atomic.py +5 -2
- megfile/version.py +1 -1
- {megfile-5.0.4.dist-info → megfile-5.0.5.dist-info}/METADATA +1 -1
- {megfile-5.0.4.dist-info → megfile-5.0.5.dist-info}/RECORD +11 -11
- {megfile-5.0.4.dist-info → megfile-5.0.5.dist-info}/WHEEL +0 -0
- {megfile-5.0.4.dist-info → megfile-5.0.5.dist-info}/entry_points.txt +0 -0
- {megfile-5.0.4.dist-info → megfile-5.0.5.dist-info}/licenses/LICENSE +0 -0
- {megfile-5.0.4.dist-info → megfile-5.0.5.dist-info}/licenses/LICENSE.pyre +0 -0
- {megfile-5.0.4.dist-info → megfile-5.0.5.dist-info}/top_level.txt +0 -0
megfile/cli.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import shlex
|
|
2
3
|
import shutil
|
|
3
4
|
import signal
|
|
5
|
+
import subprocess
|
|
4
6
|
import sys
|
|
5
7
|
import time
|
|
6
8
|
from concurrent.futures import ThreadPoolExecutor
|
|
@@ -27,6 +29,7 @@ from megfile.s3_path import get_s3_session
|
|
|
27
29
|
from megfile.sftp_path import sftp_add_host_key
|
|
28
30
|
from megfile.smart import (
|
|
29
31
|
_smart_sync_single_file,
|
|
32
|
+
smart_cache,
|
|
30
33
|
smart_copy,
|
|
31
34
|
smart_exists,
|
|
32
35
|
smart_getmd5,
|
|
@@ -719,6 +722,16 @@ def stat(path: str):
|
|
|
719
722
|
click.echo(smart_stat(path))
|
|
720
723
|
|
|
721
724
|
|
|
725
|
+
@cli.command(short_help="Edit the file.")
|
|
726
|
+
@click.argument("path", type=PathType())
|
|
727
|
+
@click.option("-e", "--editor", type=str, default="vim", help="Editor to use.")
|
|
728
|
+
def edit(path: str, editor: str):
|
|
729
|
+
with smart_cache(path, mode="a") as cache_path:
|
|
730
|
+
cmds = shlex.split(editor)
|
|
731
|
+
cmds.append(cache_path)
|
|
732
|
+
subprocess.check_call(cmds)
|
|
733
|
+
|
|
734
|
+
|
|
722
735
|
@cli.command(short_help="Return the megfile version.")
|
|
723
736
|
def version():
|
|
724
737
|
click.echo(VERSION)
|
|
@@ -40,7 +40,7 @@ class BaseMemoryHandler(Readable[bytes], Seekable, Writable[bytes], ABC):
|
|
|
40
40
|
return self._fileobj.seek(offset, whence)
|
|
41
41
|
|
|
42
42
|
def readable(self) -> bool:
|
|
43
|
-
return self._mode[0] == "r" or self._mode
|
|
43
|
+
return self._mode[0] == "r" or "+" in self._mode
|
|
44
44
|
|
|
45
45
|
def read(self, size: Optional[int] = None) -> bytes:
|
|
46
46
|
if not self.readable():
|
|
@@ -62,7 +62,7 @@ class BaseMemoryHandler(Readable[bytes], Seekable, Writable[bytes], ABC):
|
|
|
62
62
|
return self._fileobj.readlines(hint)
|
|
63
63
|
|
|
64
64
|
def writable(self) -> bool:
|
|
65
|
-
return self._mode[0] == "w" or self._mode[0] == "a" or self._mode
|
|
65
|
+
return self._mode[0] == "w" or self._mode[0] == "a" or "+" in self._mode
|
|
66
66
|
|
|
67
67
|
def flush(self):
|
|
68
68
|
self._fileobj.flush()
|
megfile/utils/atomic.py
CHANGED
|
@@ -116,7 +116,7 @@ class AtomicTextIOWrapper(TextIOWrapper):
|
|
|
116
116
|
bool: True if the abort was performed, False otherwise.
|
|
117
117
|
"""
|
|
118
118
|
if hasattr(self._raw, "abort"):
|
|
119
|
-
return self._raw.
|
|
119
|
+
return self._raw.abort()
|
|
120
120
|
return False
|
|
121
121
|
|
|
122
122
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
@@ -133,11 +133,14 @@ class AtomicTextIOWrapper(TextIOWrapper):
|
|
|
133
133
|
super().__exit__(exc_type, exc_val, exc_tb)
|
|
134
134
|
|
|
135
135
|
def __del__(self):
|
|
136
|
+
if self.closed:
|
|
137
|
+
return
|
|
138
|
+
|
|
136
139
|
if self.atomic:
|
|
137
140
|
if self.abort():
|
|
138
141
|
_logger.warning(
|
|
139
142
|
f"skip closing atomic file-like object before deletion: {self}"
|
|
140
143
|
)
|
|
141
144
|
return
|
|
142
|
-
|
|
145
|
+
|
|
143
146
|
self.close()
|
megfile/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "5.0.
|
|
1
|
+
VERSION = "5.0.5"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
megfile/__init__.py,sha256=4XbMsR-lM7MxbnPGBI16m2sq6ghuA2-zZj2XF4bbX2Y,3291
|
|
2
|
-
megfile/cli.py,sha256=
|
|
2
|
+
megfile/cli.py,sha256=Quj5uM7UUukiDGLiG6Z1BwtKrbaWw_dHHNiVD-l649E,31022
|
|
3
3
|
megfile/config.py,sha256=K3B_o2dnI7qGsGnK8Jg18-S5YYLYuzskfNJowlSMkQM,5065
|
|
4
4
|
megfile/errors.py,sha256=zKwM5r5j89mlbWZNeax26Hq63NmQhl9iGMfTtgyvYNA,16830
|
|
5
5
|
megfile/fs_path.py,sha256=RxdhMDoc1HRmQtyaCehEGk_UJtHGLrrwiUIHrS4LJiY,41027
|
|
@@ -13,10 +13,10 @@ megfile/sftp_path.py,sha256=zxuT1hk7sgoOUwq6KBXS__caX8Hk_LgPjINQheTZWAU,52063
|
|
|
13
13
|
megfile/smart.py,sha256=Lab2jxprj-zvPw5GqUWlWiEY8bcpRlviks_qp9r-km8,38224
|
|
14
14
|
megfile/smart_path.py,sha256=kGidkM5S58ChE3LVZMcUACs3IQgsqh9m04sp6-wxuhk,12615
|
|
15
15
|
megfile/stdio_path.py,sha256=cxaDr8rtisTPnN-rjtaEpqQnshwiqwXFUJBM9xWY7Cg,2711
|
|
16
|
-
megfile/version.py,sha256=
|
|
16
|
+
megfile/version.py,sha256=KZmXhcDHicScZCqwBzPprRNi1hfyVjIjbAsyTGuyt_g,19
|
|
17
17
|
megfile/webdav_path.py,sha256=QrRYKBGWXkUZXEeHxAfVJkxnCfnczocBSRkVgDC_qC4,31421
|
|
18
18
|
megfile/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
megfile/lib/base_memory_handler.py,sha256=
|
|
19
|
+
megfile/lib/base_memory_handler.py,sha256=VEfw2RuynHFPtQ6KZv8hv8rnUwsj566Omg4cHajhARk,2863
|
|
20
20
|
megfile/lib/base_prefetch_reader.py,sha256=MYaWOkXc3geZMYNPHlPZmmpOR6uSz-AMuCZwYdoz7t0,13296
|
|
21
21
|
megfile/lib/combine_reader.py,sha256=Kp2wEloOUpTlIU7dve87MBpSzmIM-F9OtpTawAjFkiU,4828
|
|
22
22
|
megfile/lib/compare.py,sha256=CPSbyqsQ396oSfxa7h0NdUUqBw5A3WOn6fHrNKkuinw,2188
|
|
@@ -41,12 +41,12 @@ megfile/lib/url.py,sha256=ER32pWy9Q2MAk3TraAaNEBWIqUeBmLuM57ol2cs7-Ks,103
|
|
|
41
41
|
megfile/lib/webdav_memory_handler.py,sha256=7nq4o69ck_7dFh6xlYTBG8-rj49Q7gxwa3V2bHXEQz4,2551
|
|
42
42
|
megfile/lib/webdav_prefetch_reader.py,sha256=M0X6E6t-DS5q9KiLvjVZx_AZuiW9SaIkBnIPLc774GQ,3941
|
|
43
43
|
megfile/utils/__init__.py,sha256=lfJze58nO18ug8EUfSJgTTxOwj1p7FQdsnO1keBeMSo,12740
|
|
44
|
-
megfile/utils/atomic.py,sha256=
|
|
44
|
+
megfile/utils/atomic.py,sha256=V3gqUQjHIx5j6LCrU2_0tLVlX1ossetxdJJK48g9-rc,4084
|
|
45
45
|
megfile/utils/mutex.py,sha256=asb8opGLgK22RiuBJUnfsvB8LnMmodP8KzCVHKmQBWA,2561
|
|
46
|
-
megfile-5.0.
|
|
47
|
-
megfile-5.0.
|
|
48
|
-
megfile-5.0.
|
|
49
|
-
megfile-5.0.
|
|
50
|
-
megfile-5.0.
|
|
51
|
-
megfile-5.0.
|
|
52
|
-
megfile-5.0.
|
|
46
|
+
megfile-5.0.5.dist-info/licenses/LICENSE,sha256=xuY_rHyygMLmf0LgkKj_-wb-BxveHp9rTN0VDE73PrE,11365
|
|
47
|
+
megfile-5.0.5.dist-info/licenses/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
|
|
48
|
+
megfile-5.0.5.dist-info/METADATA,sha256=A5wTdggi4xoo1jf9Jn9PzkOCglLOQ1TBPBBX07_yLtE,9226
|
|
49
|
+
megfile-5.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
50
|
+
megfile-5.0.5.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
|
|
51
|
+
megfile-5.0.5.dist-info/top_level.txt,sha256=i3rMgdU1ZAJekAceojhA-bkm3749PzshtRmLTbeLUPQ,8
|
|
52
|
+
megfile-5.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|