rclone-api 1.5.17__py3-none-any.whl → 1.5.19__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 +22 -0
- rclone_api/filesystem.py +24 -8
- rclone_api/rclone_impl.py +7 -0
- {rclone_api-1.5.17.dist-info → rclone_api-1.5.19.dist-info}/METADATA +1 -1
- {rclone_api-1.5.17.dist-info → rclone_api-1.5.19.dist-info}/RECORD +9 -9
- {rclone_api-1.5.17.dist-info → rclone_api-1.5.19.dist-info}/WHEEL +0 -0
- {rclone_api-1.5.17.dist-info → rclone_api-1.5.19.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.5.17.dist-info → rclone_api-1.5.19.dist-info}/licenses/LICENSE +0 -0
- {rclone_api-1.5.17.dist-info → rclone_api-1.5.19.dist-info}/top_level.txt +0 -0
rclone_api/__init__.py
CHANGED
@@ -24,6 +24,7 @@ from .dir_listing import DirListing # Directory contents representation
|
|
24
24
|
from .file import File, FileItem # File representation
|
25
25
|
from .file_stream import FilesStream # Streaming file listings
|
26
26
|
from .filelist import FileList # File list utilities
|
27
|
+
from .filesystem import FSPath, RemoteFS # Filesystem utilities
|
27
28
|
from .http_server import HttpFetcher, HttpServer, Range # HTTP serving capabilities
|
28
29
|
|
29
30
|
# Import logging configuration utilities
|
@@ -119,6 +120,27 @@ class Rclone:
|
|
119
120
|
"""
|
120
121
|
return self.impl.webgui(other_args=other_args)
|
121
122
|
|
123
|
+
def filesystem(self, src: str) -> RemoteFS:
|
124
|
+
"""
|
125
|
+
Get a RealFS object for interacting with the local filesystem.
|
126
|
+
|
127
|
+
Returns:
|
128
|
+
RealFS object for local filesystem operations
|
129
|
+
"""
|
130
|
+
return self.impl.filesystem(src=src)
|
131
|
+
|
132
|
+
def cwd(self, src: str) -> FSPath:
|
133
|
+
"""
|
134
|
+
Get the local root path for a filesystem.
|
135
|
+
|
136
|
+
Args:
|
137
|
+
src: Source path for the filesystem
|
138
|
+
|
139
|
+
Returns:
|
140
|
+
FSPath object representing the root of the filesystem
|
141
|
+
"""
|
142
|
+
return self.impl.cwd(src=src)
|
143
|
+
|
122
144
|
def launch_server(
|
123
145
|
self,
|
124
146
|
addr: str,
|
rclone_api/filesystem.py
CHANGED
@@ -2,6 +2,8 @@ import abc
|
|
2
2
|
import shutil
|
3
3
|
from pathlib import Path
|
4
4
|
|
5
|
+
from rclone_api.config import Config
|
6
|
+
|
5
7
|
|
6
8
|
class FileSystem(abc.ABC):
|
7
9
|
def __init__(self) -> None:
|
@@ -31,6 +33,10 @@ class FileSystem(abc.ABC):
|
|
31
33
|
def ls(self, path: Path | str) -> list[str]:
|
32
34
|
pass
|
33
35
|
|
36
|
+
@abc.abstractmethod
|
37
|
+
def cwd(self) -> "FSPath":
|
38
|
+
pass
|
39
|
+
|
34
40
|
@abc.abstractmethod
|
35
41
|
def get_path(self, path: str) -> "FSPath":
|
36
42
|
pass
|
@@ -45,12 +51,12 @@ class FileSystem(abc.ABC):
|
|
45
51
|
self.write_binary(path, utf)
|
46
52
|
|
47
53
|
|
48
|
-
class
|
54
|
+
class RealFS(FileSystem):
|
49
55
|
|
50
56
|
@staticmethod
|
51
|
-
def
|
57
|
+
def from_path(path: Path | str) -> "FSPath":
|
52
58
|
path_str = Path(path).as_posix()
|
53
|
-
return FSPath(
|
59
|
+
return FSPath(RealFS(), path_str)
|
54
60
|
|
55
61
|
def __init__(self) -> None:
|
56
62
|
super().__init__()
|
@@ -58,6 +64,9 @@ class RealFileSystem(FileSystem):
|
|
58
64
|
def ls(self, path: Path | str) -> list[str]:
|
59
65
|
return [str(p) for p in Path(path).iterdir()]
|
60
66
|
|
67
|
+
def cwd(self) -> "FSPath":
|
68
|
+
return RealFS.from_path(Path.cwd())
|
69
|
+
|
61
70
|
def copy(self, src: Path | str, dest: Path | str) -> None:
|
62
71
|
shutil.copy(str(src), str(dest))
|
63
72
|
|
@@ -79,16 +88,23 @@ class RealFileSystem(FileSystem):
|
|
79
88
|
return FSPath(self, path)
|
80
89
|
|
81
90
|
|
82
|
-
class
|
83
|
-
def __init__(self, rclone_conf: Path, src: str) -> None:
|
91
|
+
class RemoteFS(FileSystem):
|
92
|
+
def __init__(self, rclone_conf: Path | Config, src: str) -> None:
|
84
93
|
from rclone_api import HttpServer, Rclone
|
85
94
|
|
86
95
|
super().__init__()
|
96
|
+
self.src = src
|
87
97
|
self.rclone_conf = rclone_conf
|
88
98
|
self.rclone: Rclone = Rclone(rclone_conf)
|
89
99
|
self.server: HttpServer = self.rclone.serve_http(src=src)
|
90
100
|
self.shutdown = False
|
91
101
|
|
102
|
+
def root(self) -> "FSPath":
|
103
|
+
return FSPath(self, self.src)
|
104
|
+
|
105
|
+
def cwd(self) -> "FSPath":
|
106
|
+
return self.root()
|
107
|
+
|
92
108
|
def _to_str(self, path: Path | str) -> str:
|
93
109
|
if isinstance(path, Path):
|
94
110
|
return path.as_posix()
|
@@ -115,7 +131,7 @@ class RemoteFileSystem(FileSystem):
|
|
115
131
|
return self.server.exists(path)
|
116
132
|
|
117
133
|
def mkdir(self, path: str, parents=True, exist_ok=True) -> None:
|
118
|
-
raise NotImplementedError("
|
134
|
+
raise NotImplementedError("RemoteFS does not support mkdir")
|
119
135
|
|
120
136
|
def is_dir(self, path: Path | str) -> bool:
|
121
137
|
path = self._to_str(path)
|
@@ -176,8 +192,8 @@ class FSPath:
|
|
176
192
|
|
177
193
|
def rmtree(self, ignore_errors=False) -> None:
|
178
194
|
assert self.exists(), f"Path does not exist: {self.path}"
|
179
|
-
# check fs is
|
180
|
-
assert isinstance(self.fs,
|
195
|
+
# check fs is RealFS
|
196
|
+
assert isinstance(self.fs, RealFS)
|
181
197
|
shutil.rmtree(self.path, ignore_errors=ignore_errors)
|
182
198
|
|
183
199
|
def ls(self) -> "list[FSPath]":
|
rclone_api/rclone_impl.py
CHANGED
@@ -26,6 +26,7 @@ from rclone_api.dir_listing import DirListing
|
|
26
26
|
from rclone_api.exec import RcloneExec
|
27
27
|
from rclone_api.file import File
|
28
28
|
from rclone_api.file_stream import FilesStream
|
29
|
+
from rclone_api.filesystem import FSPath, RemoteFS
|
29
30
|
from rclone_api.group_files import group_files
|
30
31
|
from rclone_api.http_server import HttpServer
|
31
32
|
from rclone_api.mount import Mount
|
@@ -103,6 +104,12 @@ class RcloneImpl:
|
|
103
104
|
cmd += other_args
|
104
105
|
return self._launch_process(cmd, capture=False)
|
105
106
|
|
107
|
+
def filesystem(self, src: str) -> RemoteFS:
|
108
|
+
return RemoteFS(self.config, src)
|
109
|
+
|
110
|
+
def cwd(self, src: str) -> FSPath:
|
111
|
+
return self.filesystem(src).cwd()
|
112
|
+
|
106
113
|
def launch_server(
|
107
114
|
self,
|
108
115
|
addr: str,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
rclone_api/__init__.py,sha256=
|
1
|
+
rclone_api/__init__.py,sha256=KIIHPqHIg_wykYC7vyRgnq6QOGlA2RAfrdf4XwXJbZ4,33072
|
2
2
|
rclone_api/cli.py,sha256=dibfAZIh0kXWsBbfp3onKLjyZXo54mTzDjUdzJlDlWo,231
|
3
3
|
rclone_api/completed_process.py,sha256=_IZ8IWK7DM1_tsbDEkH6wPZ-bbcrgf7A7smls854pmg,1775
|
4
4
|
rclone_api/config.py,sha256=f6jEAxVorGFr31oHfcsu5AJTtOJj2wR5tTSsbGGZuIw,2558
|
@@ -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/filesystem.py,sha256=
|
16
|
+
rclone_api/filesystem.py,sha256=Hq8rwm7ogDW5Sst4xNKHr3WIwQpLa-jt2g9CYZnRLOU,6301
|
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=yMb-yS6zXVdcggsDQU1zfvcYzaSUUPW-3I8HbgxZruU,46755
|
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.19.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
58
|
+
rclone_api-1.5.19.dist-info/METADATA,sha256=IvGqWqAC_5vXWiQCAJKyXNlHcGQ58dIOd_v27U2H0l8,32696
|
59
|
+
rclone_api-1.5.19.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
60
|
+
rclone_api-1.5.19.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
|
61
|
+
rclone_api-1.5.19.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
62
|
+
rclone_api-1.5.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|