rclone-api 1.5.21__py3-none-any.whl → 1.5.23__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.
- rclone_api/fs.py +24 -18
- {rclone_api-1.5.21.dist-info → rclone_api-1.5.23.dist-info}/METADATA +1 -1
- {rclone_api-1.5.21.dist-info → rclone_api-1.5.23.dist-info}/RECORD +7 -7
- {rclone_api-1.5.21.dist-info → rclone_api-1.5.23.dist-info}/WHEEL +0 -0
- {rclone_api-1.5.21.dist-info → rclone_api-1.5.23.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.5.21.dist-info → rclone_api-1.5.23.dist-info}/licenses/LICENSE +0 -0
- {rclone_api-1.5.21.dist-info → rclone_api-1.5.23.dist-info}/top_level.txt +0 -0
rclone_api/fs.py
CHANGED
@@ -14,7 +14,7 @@ class FS(abc.ABC):
|
|
14
14
|
pass
|
15
15
|
|
16
16
|
@abc.abstractmethod
|
17
|
-
def
|
17
|
+
def read_bytes(self, path: Path | str) -> bytes:
|
18
18
|
pass
|
19
19
|
|
20
20
|
@abc.abstractmethod
|
@@ -41,15 +41,6 @@ class FS(abc.ABC):
|
|
41
41
|
def get_path(self, path: str) -> "FSPath":
|
42
42
|
pass
|
43
43
|
|
44
|
-
def read_text(self, path: Path | str) -> str:
|
45
|
-
utf = self.read_binary(path)
|
46
|
-
return utf.decode("utf-8")
|
47
|
-
|
48
|
-
def write_text(self, path: Path | str, data: str, encoding: str | None) -> None:
|
49
|
-
encoding = encoding or "utf-8"
|
50
|
-
utf = data.encode(encoding)
|
51
|
-
self.write_binary(path, utf)
|
52
|
-
|
53
44
|
|
54
45
|
class RealFS(FS):
|
55
46
|
|
@@ -70,7 +61,7 @@ class RealFS(FS):
|
|
70
61
|
def copy(self, src: Path | str, dest: Path | str) -> None:
|
71
62
|
shutil.copy(str(src), str(dest))
|
72
63
|
|
73
|
-
def
|
64
|
+
def read_bytes(self, path: Path | str) -> bytes:
|
74
65
|
with open(path, "rb") as f:
|
75
66
|
return f.read()
|
76
67
|
|
@@ -115,7 +106,7 @@ class RemoteFS(FS):
|
|
115
106
|
self.shutdown = False
|
116
107
|
|
117
108
|
def root(self) -> "FSPath":
|
118
|
-
return FSPath(self,
|
109
|
+
return FSPath(self, "")
|
119
110
|
|
120
111
|
def cwd(self) -> "FSPath":
|
121
112
|
return self.root()
|
@@ -130,7 +121,7 @@ class RemoteFS(FS):
|
|
130
121
|
dest = self._to_str(dest)
|
131
122
|
self.rclone.copy(src, dest)
|
132
123
|
|
133
|
-
def
|
124
|
+
def read_bytes(self, path: Path | str) -> bytes:
|
134
125
|
path = self._to_str(path)
|
135
126
|
err = self.rclone.read_bytes(path)
|
136
127
|
if isinstance(err, Exception):
|
@@ -146,7 +137,11 @@ class RemoteFS(FS):
|
|
146
137
|
return self.server.exists(path)
|
147
138
|
|
148
139
|
def mkdir(self, path: str, parents=True, exist_ok=True) -> None:
|
149
|
-
|
140
|
+
# Ignore mkdir for remote backend, it will be made when file is written.
|
141
|
+
import warnings
|
142
|
+
|
143
|
+
warnings.warn("mkdir is not supported for remote backend", stacklevel=2)
|
144
|
+
return None
|
150
145
|
|
151
146
|
def is_dir(self, path: Path | str) -> bool:
|
152
147
|
path = self._to_str(path)
|
@@ -185,10 +180,16 @@ class FSPath:
|
|
185
180
|
self.path = path
|
186
181
|
|
187
182
|
def read_text(self) -> str:
|
188
|
-
|
183
|
+
data = self.read_bytes()
|
184
|
+
return data.decode("utf-8")
|
189
185
|
|
190
|
-
def
|
191
|
-
|
186
|
+
def read_bytes(self) -> bytes:
|
187
|
+
data: bytes | None = None
|
188
|
+
try:
|
189
|
+
data = self.fs.read_bytes(self.path)
|
190
|
+
return data
|
191
|
+
except Exception as e:
|
192
|
+
raise FileNotFoundError(f"File not found: {self.path}, because of {e}")
|
192
193
|
|
193
194
|
def exists(self) -> bool:
|
194
195
|
return self.fs.exists(self.path)
|
@@ -203,7 +204,12 @@ class FSPath:
|
|
203
204
|
self.fs.mkdir(self.path, parents=parents, exist_ok=exist_ok)
|
204
205
|
|
205
206
|
def write_text(self, data: str, encoding: str | None = None) -> None:
|
206
|
-
|
207
|
+
if encoding is None:
|
208
|
+
encoding = "utf-8"
|
209
|
+
self.write_bytes(data.encode(encoding))
|
210
|
+
|
211
|
+
def write_bytes(self, data: bytes) -> None:
|
212
|
+
self.fs.write_binary(self.path, data)
|
207
213
|
|
208
214
|
def rmtree(self, ignore_errors=False) -> None:
|
209
215
|
assert self.exists(), f"Path does not exist: {self.path}"
|
@@ -13,7 +13,7 @@ rclone_api/file_item.py,sha256=cH-AQYsxedhNPp4c8NHY1ad4Z7St4yf_VGbmiGD59no,1770
|
|
13
13
|
rclone_api/file_part.py,sha256=i6ByS5_sae8Eba-4imBVTxd-xKC8ExWy7NR8QGr0ors,6155
|
14
14
|
rclone_api/file_stream.py,sha256=_W3qnwCuigqA0hzXl2q5pAxSZDRaUSwet4BkT0lpnzs,1431
|
15
15
|
rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
|
16
|
-
rclone_api/fs.py,sha256=
|
16
|
+
rclone_api/fs.py,sha256=q0oOjhhAzC5ZmHk9TH6X0FpEL5SPP2Ow3hjHbuOpufs,6922
|
17
17
|
rclone_api/group_files.py,sha256=H92xPW9lQnbNw5KbtZCl00bD6iRh9yRbCuxku4j_3dg,8036
|
18
18
|
rclone_api/http_server.py,sha256=ZdL-rGaq0zIjcaIiRIbPBQ4OIWZ7dCu71aq0nRlKtY4,11686
|
19
19
|
rclone_api/install.py,sha256=Xb1BRn8rQcSpSd4dzmvIOELP2zM2DytUeIZ6jzv738A,2893
|
@@ -54,9 +54,9 @@ rclone_api/s3/multipart/upload_parts_inline.py,sha256=V7syKjFyVIe4U9Ahl5XgqVTzt9
|
|
54
54
|
rclone_api/s3/multipart/upload_parts_resumable.py,sha256=6-nlMclS8jyVvMvFbQDcZOX9MY1WbCcKA_s9bwuYxnk,9793
|
55
55
|
rclone_api/s3/multipart/upload_parts_server_side_merge.py,sha256=Fp2pdrs5dONQI9LkfNolgAGj1-Z2V1SsRd0r0sreuXI,18040
|
56
56
|
rclone_api/s3/multipart/upload_state.py,sha256=f-Aq2NqtAaMUMhYitlICSNIxCKurWAl2gDEUVizLIqw,6019
|
57
|
-
rclone_api-1.5.
|
58
|
-
rclone_api-1.5.
|
59
|
-
rclone_api-1.5.
|
60
|
-
rclone_api-1.5.
|
61
|
-
rclone_api-1.5.
|
62
|
-
rclone_api-1.5.
|
57
|
+
rclone_api-1.5.23.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
58
|
+
rclone_api-1.5.23.dist-info/METADATA,sha256=_9tLRiVqSoRBZJTrv3FWeNH3RvGclM232IrtUpAQf4w,37155
|
59
|
+
rclone_api-1.5.23.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
60
|
+
rclone_api-1.5.23.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
|
61
|
+
rclone_api-1.5.23.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
62
|
+
rclone_api-1.5.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|