rclone-api 1.5.26__py3-none-any.whl → 1.5.29__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/__init__.py +1 -1
- rclone_api/config.py +16 -0
- rclone_api/fs.py +27 -2
- rclone_api/rclone_impl.py +8 -1
- {rclone_api-1.5.26.dist-info → rclone_api-1.5.29.dist-info}/METADATA +1 -1
- {rclone_api-1.5.26.dist-info → rclone_api-1.5.29.dist-info}/RECORD +10 -10
- {rclone_api-1.5.26.dist-info → rclone_api-1.5.29.dist-info}/WHEEL +0 -0
- {rclone_api-1.5.26.dist-info → rclone_api-1.5.29.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.5.26.dist-info → rclone_api-1.5.29.dist-info}/licenses/LICENSE +0 -0
- {rclone_api-1.5.26.dist-info → rclone_api-1.5.29.dist-info}/top_level.txt +0 -0
rclone_api/__init__.py
CHANGED
@@ -93,7 +93,7 @@ class Rclone:
|
|
93
93
|
return upgrade_rclone()
|
94
94
|
|
95
95
|
def __init__(
|
96
|
-
self, rclone_conf: Path | Config, rclone_exe: Path | None = None
|
96
|
+
self, rclone_conf: Path | Config | None, rclone_exe: Path | None = None
|
97
97
|
) -> None:
|
98
98
|
"""
|
99
99
|
Initialize the Rclone interface.
|
rclone_api/config.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from dataclasses import dataclass, field
|
2
|
+
from pathlib import Path
|
2
3
|
from typing import Dict, List
|
3
4
|
|
4
5
|
|
@@ -55,6 +56,21 @@ class Config:
|
|
55
56
|
return Parsed.parse(self.text)
|
56
57
|
|
57
58
|
|
59
|
+
def find_conf_file() -> Path | None:
|
60
|
+
import os
|
61
|
+
|
62
|
+
# if os.environ.get("RCLONE_CONFIG"):
|
63
|
+
# return Path(os.environ["RCLONE_CONFIG"])
|
64
|
+
# return None
|
65
|
+
# rclone_conf = rclone_conf or Path.cwd() / "rclone.conf"
|
66
|
+
|
67
|
+
if os.environ.get("RCLONE_CONFIG"):
|
68
|
+
return Path(os.environ["RCLONE_CONFIG"])
|
69
|
+
if (conf := Path.cwd() / "rclone.conf").exists():
|
70
|
+
return conf
|
71
|
+
return None
|
72
|
+
|
73
|
+
|
58
74
|
def parse_rclone_config(content: str) -> Parsed:
|
59
75
|
"""
|
60
76
|
Parses an rclone configuration file and returns a list of RcloneConfigSection objects.
|
rclone_api/fs.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import abc
|
2
2
|
import shutil
|
3
|
+
import warnings
|
3
4
|
from pathlib import Path
|
4
5
|
|
5
6
|
from rclone_api.config import Config
|
@@ -41,6 +42,10 @@ class FS(abc.ABC):
|
|
41
42
|
def get_path(self, path: str) -> "FSPath":
|
42
43
|
pass
|
43
44
|
|
45
|
+
@abc.abstractmethod
|
46
|
+
def dispose(self) -> None:
|
47
|
+
pass
|
48
|
+
|
44
49
|
|
45
50
|
class RealFS(FS):
|
46
51
|
|
@@ -78,6 +83,9 @@ class RealFS(FS):
|
|
78
83
|
def get_path(self, path: str) -> "FSPath":
|
79
84
|
return FSPath(self, path)
|
80
85
|
|
86
|
+
def dispose(self) -> None:
|
87
|
+
pass
|
88
|
+
|
81
89
|
|
82
90
|
class RemoteFS(FS):
|
83
91
|
|
@@ -180,8 +188,15 @@ class RemoteFS(FS):
|
|
180
188
|
|
181
189
|
class FSPath:
|
182
190
|
def __init__(self, fs: FS, path: str) -> None:
|
183
|
-
self.fs = fs
|
184
|
-
self.path = path
|
191
|
+
self.fs: FS = fs
|
192
|
+
self.path: str = path
|
193
|
+
self.fs_holder: FS | None = None
|
194
|
+
|
195
|
+
def set_owner(self) -> None:
|
196
|
+
self.fs_holder = self.fs
|
197
|
+
|
198
|
+
def is_real_fs(self) -> bool:
|
199
|
+
return isinstance(self.fs, RealFS)
|
185
200
|
|
186
201
|
def read_text(self) -> str:
|
187
202
|
data = self.read_bytes()
|
@@ -204,6 +219,16 @@ class FSPath:
|
|
204
219
|
def __repr__(self) -> str:
|
205
220
|
return f"FSPath({self.path})"
|
206
221
|
|
222
|
+
def __enter__(self) -> "FSPath":
|
223
|
+
if self.fs_holder is not None:
|
224
|
+
warnings.warn("This operation is reserved for the cwd returned by FS")
|
225
|
+
return self
|
226
|
+
|
227
|
+
def __exit__(self, exc_type, exc_value, traceback) -> None:
|
228
|
+
if self.fs_holder is not None:
|
229
|
+
self.fs_holder.dispose()
|
230
|
+
self.fs_holder = None
|
231
|
+
|
207
232
|
def mkdir(self, parents=True, exist_ok=True) -> None:
|
208
233
|
self.fs.mkdir(self.path, parents=parents, exist_ok=exist_ok)
|
209
234
|
|
rclone_api/rclone_impl.py
CHANGED
@@ -73,11 +73,18 @@ def _to_rclone_conf(config: Config | Path) -> Config:
|
|
73
73
|
|
74
74
|
class RcloneImpl:
|
75
75
|
def __init__(
|
76
|
-
self, rclone_conf: Path | Config, rclone_exe: Path | None = None
|
76
|
+
self, rclone_conf: Path | Config | None, rclone_exe: Path | None = None
|
77
77
|
) -> None:
|
78
78
|
if isinstance(rclone_conf, Path):
|
79
79
|
if not rclone_conf.exists():
|
80
80
|
raise ValueError(f"Rclone config file not found: {rclone_conf}")
|
81
|
+
if rclone_conf is None:
|
82
|
+
from rclone_api.config import find_conf_file
|
83
|
+
|
84
|
+
maybe_path = find_conf_file()
|
85
|
+
if not isinstance(maybe_path, Path):
|
86
|
+
raise ValueError("Rclone config file not found")
|
87
|
+
rclone_conf = _to_rclone_conf(maybe_path)
|
81
88
|
self._exec = RcloneExec(rclone_conf, get_rclone_exe(rclone_exe))
|
82
89
|
self.config: Config = _to_rclone_conf(rclone_conf)
|
83
90
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
rclone_api/__init__.py,sha256=
|
1
|
+
rclone_api/__init__.py,sha256=iCqbm7qr3mYASb3S9ezAidgnw3Am7Ok0cUqb5Hm8CZA,33239
|
2
2
|
rclone_api/cli.py,sha256=dibfAZIh0kXWsBbfp3onKLjyZXo54mTzDjUdzJlDlWo,231
|
3
3
|
rclone_api/completed_process.py,sha256=_IZ8IWK7DM1_tsbDEkH6wPZ-bbcrgf7A7smls854pmg,1775
|
4
|
-
rclone_api/config.py,sha256=
|
4
|
+
rclone_api/config.py,sha256=1O_AC3JYPcjdGYyl6OzummdXUK3m4ouhnNnjEOqdJ2Y,2990
|
5
5
|
rclone_api/convert.py,sha256=Mx9Qo7zhkOedJd8LdhPvNGHp8znJzOk4f_2KWnoGc78,1012
|
6
6
|
rclone_api/deprecated.py,sha256=qWKpnZdYcBK7YQZKuVoWWXDwi-uqiAtbjgPcci_efow,590
|
7
7
|
rclone_api/diff.py,sha256=tMoJMAGmLSE6Q_7QhPf6PnCzb840djxMZtDmhc2GlGQ,5227
|
@@ -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=T08YXyHgxyWbjK09hNAIhchLyWtA1LLU5o1rJe6zvcE,7899
|
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
|
@@ -21,7 +21,7 @@ rclone_api/log.py,sha256=VZHM7pNSXip2ZLBKMP7M1u-rp_F7zoafFDuR8CPUoKI,1271
|
|
21
21
|
rclone_api/mount.py,sha256=LZqEhuKZunbWVqmsOIqkkCotaxWJpdFRS1InXveoU5E,1428
|
22
22
|
rclone_api/mount_util.py,sha256=jqhJEVTHV6c6lOOzUYb4FLMbqDMHdz7-QRcdH-IobFc,10154
|
23
23
|
rclone_api/process.py,sha256=MeWiN-TrrN0HmtWexBPxGwf84z6f-_E5yaXE-YtLYpY,5879
|
24
|
-
rclone_api/rclone_impl.py,sha256=
|
24
|
+
rclone_api/rclone_impl.py,sha256=kZ6uE_Ati00MXN_D4gDEnaj9aZfjEfj4Ywvxy8hJ74w,47054
|
25
25
|
rclone_api/remote.py,sha256=mTgMTQTwxUmbLjTpr-AGTId2ycXKI9mLX5L7PPpDIoc,520
|
26
26
|
rclone_api/rpath.py,sha256=Y1JjQWcie39EgQrq-UtbfDz5yDLCwwfu27W7AQXllSE,2860
|
27
27
|
rclone_api/scan_missing_folders.py,sha256=-8NCwpCaHeHrX-IepCoAEsX1rl8S-GOCxcIhTr_w3gA,4747
|
@@ -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.29.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
58
|
+
rclone_api-1.5.29.dist-info/METADATA,sha256=PMoYV4s4X_tITt_cwdLldRrOr60n4iKnyQmwksJko44,37155
|
59
|
+
rclone_api-1.5.29.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
60
|
+
rclone_api-1.5.29.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
|
61
|
+
rclone_api-1.5.29.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
62
|
+
rclone_api-1.5.29.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|