rclone-api 1.0.14__tar.gz → 1.0.15__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {rclone_api-1.0.14/src/rclone_api.egg-info → rclone_api-1.0.15}/PKG-INFO +1 -1
- {rclone_api-1.0.14 → rclone_api-1.0.15}/pyproject.toml +1 -1
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/__init__.py +11 -1
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/exec.py +2 -2
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/file.py +1 -1
- rclone_api-1.0.15/src/rclone_api/filelist.py +30 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/rclone.py +33 -13
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/util.py +2 -1
- {rclone_api-1.0.14 → rclone_api-1.0.15/src/rclone_api.egg-info}/PKG-INFO +1 -1
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api.egg-info/SOURCES.txt +1 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.aiderignore +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.github/workflows/lint.yml +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.github/workflows/push_macos.yml +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.github/workflows/push_ubuntu.yml +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.github/workflows/push_win.yml +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.gitignore +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.pylintrc +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.vscode/launch.json +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.vscode/settings.json +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/.vscode/tasks.json +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/LICENSE +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/MANIFEST.in +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/README.md +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/clean +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/install +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/lint +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/requirements.testing.txt +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/setup.cfg +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/setup.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/assets/example.txt +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/cli.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/config.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/convert.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/dir.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/dir_listing.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/remote.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/rpath.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api/walk.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api.egg-info/dependency_links.txt +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api.egg-info/requires.txt +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/src/rclone_api.egg-info/top_level.txt +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/test +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/tests/test_copy.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/tests/test_is_synced.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/tests/test_ls.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/tests/test_remotes.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/tests/test_walk.py +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/tox.ini +0 -0
- {rclone_api-1.0.14 → rclone_api-1.0.15}/upload_package.sh +0 -0
@@ -2,8 +2,18 @@ from .config import Config
|
|
2
2
|
from .dir import Dir
|
3
3
|
from .dir_listing import DirListing
|
4
4
|
from .file import File
|
5
|
+
from .filelist import FileList
|
5
6
|
from .rclone import Rclone
|
6
7
|
from .remote import Remote
|
7
8
|
from .rpath import RPath
|
8
9
|
|
9
|
-
__all__ = [
|
10
|
+
__all__ = [
|
11
|
+
"Rclone",
|
12
|
+
"File",
|
13
|
+
"Config",
|
14
|
+
"Remote",
|
15
|
+
"Dir",
|
16
|
+
"RPath",
|
17
|
+
"DirListing",
|
18
|
+
"FileList",
|
19
|
+
]
|
@@ -12,8 +12,8 @@ class RcloneExec:
|
|
12
12
|
rclone_config: Path | Config
|
13
13
|
rclone_exe: Path
|
14
14
|
|
15
|
-
def execute(self, cmd: list[str]) -> subprocess.CompletedProcess:
|
15
|
+
def execute(self, cmd: list[str], check: bool) -> subprocess.CompletedProcess:
|
16
16
|
"""Execute rclone command."""
|
17
17
|
from rclone_api.util import rclone_execute
|
18
18
|
|
19
|
-
return rclone_execute(cmd, self.rclone_config, self.rclone_exe)
|
19
|
+
return rclone_execute(cmd, self.rclone_config, self.rclone_exe, check=check)
|
@@ -31,7 +31,7 @@ class File:
|
|
31
31
|
if self.path.is_dir:
|
32
32
|
raise RuntimeError("Cannot read a directory as bytes")
|
33
33
|
|
34
|
-
result = self.path.rclone._run(["cat", self.path.path])
|
34
|
+
result = self.path.rclone._run(["cat", self.path.path], check=True)
|
35
35
|
return result.stdout
|
36
36
|
|
37
37
|
def to_json(self) -> dict:
|
@@ -0,0 +1,30 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
|
3
|
+
from rclone_api.dir import Dir
|
4
|
+
from rclone_api.dir_listing import DirListing
|
5
|
+
from rclone_api.file import File
|
6
|
+
from rclone_api.rpath import RPath
|
7
|
+
|
8
|
+
|
9
|
+
@dataclass
|
10
|
+
class FileList:
|
11
|
+
"""Remote file dataclass."""
|
12
|
+
|
13
|
+
dirs: list[Dir]
|
14
|
+
files: list[File]
|
15
|
+
|
16
|
+
def _to_dir_list(self) -> list[RPath]:
|
17
|
+
pathlist: list[RPath] = []
|
18
|
+
for d in self.dirs:
|
19
|
+
pathlist.append(d.path)
|
20
|
+
for f in self.files:
|
21
|
+
pathlist.append(f.path)
|
22
|
+
return pathlist
|
23
|
+
|
24
|
+
def __str__(self) -> str:
|
25
|
+
pathlist: list[RPath] = self._to_dir_list()
|
26
|
+
return str(DirListing(pathlist))
|
27
|
+
|
28
|
+
def __repr__(self) -> str:
|
29
|
+
pathlist: list[RPath] = self._to_dir_list()
|
30
|
+
return repr(DirListing(pathlist))
|
@@ -14,6 +14,7 @@ from rclone_api.convert import convert_to_filestr_list, convert_to_str
|
|
14
14
|
from rclone_api.dir_listing import DirListing
|
15
15
|
from rclone_api.exec import RcloneExec
|
16
16
|
from rclone_api.file import File
|
17
|
+
from rclone_api.filelist import FileList
|
17
18
|
from rclone_api.remote import Remote
|
18
19
|
from rclone_api.rpath import RPath
|
19
20
|
from rclone_api.util import get_rclone_exe, to_path
|
@@ -29,8 +30,8 @@ class Rclone:
|
|
29
30
|
raise ValueError(f"Rclone config file not found: {rclone_conf}")
|
30
31
|
self._exec = RcloneExec(rclone_conf, get_rclone_exe(rclone_exe))
|
31
32
|
|
32
|
-
def _run(self, cmd: list[str]) -> subprocess.CompletedProcess:
|
33
|
-
return self._exec.execute(cmd)
|
33
|
+
def _run(self, cmd: list[str], check: bool = True) -> subprocess.CompletedProcess:
|
34
|
+
return self._exec.execute(cmd, check=check)
|
34
35
|
|
35
36
|
def ls(
|
36
37
|
self,
|
@@ -63,7 +64,7 @@ class Rclone:
|
|
63
64
|
remote = path.remote if isinstance(path, Dir) else path
|
64
65
|
assert isinstance(remote, Remote)
|
65
66
|
|
66
|
-
cp = self._run(cmd)
|
67
|
+
cp = self._run(cmd, check=True)
|
67
68
|
text = cp.stdout
|
68
69
|
parent_path: str | None = None
|
69
70
|
if isinstance(path, Dir):
|
@@ -159,30 +160,36 @@ class Rclone:
|
|
159
160
|
# self._run(cmd_list)
|
160
161
|
executor.submit(self._run, cmd_list)
|
161
162
|
|
162
|
-
def copy(
|
163
|
+
def copy(
|
164
|
+
self, src: Dir | str, dst: Dir | str, filelist: FileList | None = None
|
165
|
+
) -> subprocess.CompletedProcess:
|
163
166
|
"""Copy files from source to destination.
|
164
167
|
|
165
168
|
Args:
|
166
169
|
src: Source directory
|
167
170
|
dst: Destination directory
|
168
171
|
"""
|
169
|
-
src_dir = src.path.path
|
170
|
-
dst_dir = dst.path.path
|
172
|
+
# src_dir = src.path.path
|
173
|
+
# dst_dir = dst.path.path
|
174
|
+
src_dir = convert_to_str(src)
|
175
|
+
dst_dir = convert_to_str(dst)
|
171
176
|
cmd_list: list[str] = ["copy", src_dir, dst_dir]
|
172
|
-
self._run(cmd_list)
|
177
|
+
return self._run(cmd_list)
|
173
178
|
|
174
|
-
def purge(self, path: Dir | str) ->
|
179
|
+
def purge(self, path: Dir | str) -> subprocess.CompletedProcess:
|
175
180
|
"""Purge a directory"""
|
176
181
|
# path should always be a string
|
177
182
|
path = path if isinstance(path, str) else str(path.path)
|
178
183
|
cmd_list: list[str] = ["purge", str(path)]
|
179
|
-
self._run(cmd_list)
|
184
|
+
return self._run(cmd_list)
|
180
185
|
|
181
|
-
def deletefiles(
|
186
|
+
def deletefiles(
|
187
|
+
self, files: str | File | list[str] | list[File]
|
188
|
+
) -> subprocess.CompletedProcess:
|
182
189
|
"""Delete a directory"""
|
183
190
|
payload: list[str] = convert_to_filestr_list(files)
|
184
191
|
cmd_list: list[str] = ["delete"] + payload
|
185
|
-
self._run(cmd_list)
|
192
|
+
return self._run(cmd_list)
|
186
193
|
|
187
194
|
def exists(self, path: Dir | Remote | str | File) -> bool:
|
188
195
|
"""Check if a file or directory exists."""
|
@@ -205,10 +212,23 @@ class Rclone:
|
|
205
212
|
except subprocess.CalledProcessError:
|
206
213
|
return False
|
207
214
|
|
208
|
-
def copy_dir(
|
215
|
+
def copy_dir(
|
216
|
+
self, src: str | Dir, dst: str | Dir, args: list[str] | None = None
|
217
|
+
) -> subprocess.CompletedProcess:
|
209
218
|
"""Copy a directory from source to destination."""
|
210
219
|
# convert src to str, also dst
|
211
220
|
src = convert_to_str(src)
|
212
221
|
dst = convert_to_str(dst)
|
213
222
|
cmd_list: list[str] = ["copy", src, dst]
|
214
|
-
|
223
|
+
if args is not None:
|
224
|
+
cmd_list += args
|
225
|
+
return self._run(cmd_list)
|
226
|
+
|
227
|
+
def copy_remote(
|
228
|
+
self, src: Remote, dst: Remote, args: list[str] | None = None
|
229
|
+
) -> subprocess.CompletedProcess:
|
230
|
+
"""Copy a remote to another remote."""
|
231
|
+
cmd_list: list[str] = ["copy", str(src), str(dst)]
|
232
|
+
if args is not None:
|
233
|
+
cmd_list += args
|
234
|
+
return self._run(cmd_list)
|
@@ -75,6 +75,7 @@ def rclone_execute(
|
|
75
75
|
cmd: list[str],
|
76
76
|
rclone_conf: Path | Config,
|
77
77
|
rclone_exe: Path,
|
78
|
+
check: bool,
|
78
79
|
verbose: bool | None = None,
|
79
80
|
) -> subprocess.CompletedProcess:
|
80
81
|
tempdir: TemporaryDirectory | None = None
|
@@ -94,7 +95,7 @@ def rclone_execute(
|
|
94
95
|
cmd_str = subprocess.list2cmdline(cmd)
|
95
96
|
print(f"Running: {cmd_str}")
|
96
97
|
cp = subprocess.run(
|
97
|
-
cmd, capture_output=True, encoding="utf-8", check=
|
98
|
+
cmd, capture_output=True, encoding="utf-8", check=check, shell=False
|
98
99
|
)
|
99
100
|
if cp.returncode != 0:
|
100
101
|
cmd_str = subprocess.list2cmdline(cmd)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|