rclone-api 1.0.9__py2.py3-none-any.whl → 1.0.10__py2.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/dir.py +44 -25
- rclone_api/rclone.py +33 -1
- rclone_api/remote.py +6 -2
- rclone_api/walk.py +7 -2
- {rclone_api-1.0.9.dist-info → rclone_api-1.0.10.dist-info}/METADATA +1 -1
- rclone_api-1.0.10.dist-info/RECORD +18 -0
- rclone_api-1.0.9.dist-info/RECORD +0 -18
- {rclone_api-1.0.9.dist-info → rclone_api-1.0.10.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.9.dist-info → rclone_api-1.0.10.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.9.dist-info → rclone_api-1.0.10.dist-info}/top_level.txt +0 -0
rclone_api/dir.py
CHANGED
@@ -1,25 +1,44 @@
|
|
1
|
-
from typing import Generator
|
2
|
-
|
3
|
-
from rclone_api.dir_listing import DirListing
|
4
|
-
from rclone_api.
|
5
|
-
from rclone_api.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
from typing import Generator
|
2
|
+
|
3
|
+
from rclone_api.dir_listing import DirListing
|
4
|
+
from rclone_api.remote import Remote
|
5
|
+
from rclone_api.rpath import RPath
|
6
|
+
from rclone_api.walk import walk
|
7
|
+
|
8
|
+
|
9
|
+
class Dir:
|
10
|
+
"""Remote file dataclass."""
|
11
|
+
|
12
|
+
def __init__(self, path: RPath | Remote) -> None:
|
13
|
+
"""Initialize Dir with either an RPath or Remote.
|
14
|
+
|
15
|
+
Args:
|
16
|
+
path: Either an RPath object or a Remote object
|
17
|
+
"""
|
18
|
+
if isinstance(path, Remote):
|
19
|
+
# Need to create an RPath for the Remote's root
|
20
|
+
self.path = RPath(
|
21
|
+
path=str(path),
|
22
|
+
name=str(path),
|
23
|
+
size=0,
|
24
|
+
mime_type="inode/directory",
|
25
|
+
mod_time="",
|
26
|
+
is_dir=True,
|
27
|
+
)
|
28
|
+
# Ensure the RPath has the same rclone instance as the Remote
|
29
|
+
self.path.set_rclone(path.rclone)
|
30
|
+
else:
|
31
|
+
self.path = path
|
32
|
+
|
33
|
+
def ls(self, max_depth: int = 0) -> DirListing:
|
34
|
+
"""List files and directories in the given path."""
|
35
|
+
assert self.path.rclone is not None
|
36
|
+
return self.path.rclone.ls(self.path.path, max_depth=max_depth)
|
37
|
+
|
38
|
+
def walk(self, max_depth: int = -1) -> Generator[DirListing, None, None]:
|
39
|
+
"""List files and directories in the given path."""
|
40
|
+
assert self.path.rclone is not None
|
41
|
+
return walk(self, max_depth=max_depth)
|
42
|
+
|
43
|
+
def __str__(self) -> str:
|
44
|
+
return str(self.path)
|
rclone_api/rclone.py
CHANGED
@@ -4,12 +4,15 @@ Unit test file.
|
|
4
4
|
|
5
5
|
import subprocess
|
6
6
|
from pathlib import Path
|
7
|
+
from typing import Generator
|
7
8
|
|
9
|
+
from rclone_api import Dir
|
8
10
|
from rclone_api.dir_listing import DirListing
|
9
11
|
from rclone_api.remote import Remote
|
10
12
|
from rclone_api.rpath import RPath
|
11
13
|
from rclone_api.types import Config, RcloneExec
|
12
14
|
from rclone_api.util import get_rclone_exe
|
15
|
+
from rclone_api.walk import walk
|
13
16
|
|
14
17
|
|
15
18
|
class Rclone:
|
@@ -54,5 +57,34 @@ class Rclone:
|
|
54
57
|
tmp = [t.strip() for t in tmp]
|
55
58
|
# strip out ":" from the end
|
56
59
|
tmp = [t.replace(":", "") for t in tmp]
|
57
|
-
out = [Remote(name=t) for t in tmp]
|
60
|
+
out = [Remote(name=t, rclone=self) for t in tmp]
|
58
61
|
return out
|
62
|
+
|
63
|
+
def walk(
|
64
|
+
self, path: str | Remote, max_depth: int = -1
|
65
|
+
) -> Generator[DirListing, None, None]:
|
66
|
+
"""Walk through the given path recursively.
|
67
|
+
|
68
|
+
Args:
|
69
|
+
path: Remote path or Remote object to walk through
|
70
|
+
max_depth: Maximum depth to traverse (-1 for unlimited)
|
71
|
+
|
72
|
+
Yields:
|
73
|
+
DirListing: Directory listing for each directory encountered
|
74
|
+
"""
|
75
|
+
if isinstance(path, str):
|
76
|
+
# Create a Remote object for the path
|
77
|
+
rpath = RPath(
|
78
|
+
path=path,
|
79
|
+
name=path,
|
80
|
+
size=0,
|
81
|
+
mime_type="inode/directory",
|
82
|
+
mod_time="",
|
83
|
+
is_dir=True,
|
84
|
+
)
|
85
|
+
rpath.set_rclone(self)
|
86
|
+
dir_obj = Dir(rpath)
|
87
|
+
else:
|
88
|
+
dir_obj = Dir(path)
|
89
|
+
|
90
|
+
yield from walk(dir_obj, max_depth=max_depth)
|
rclone_api/remote.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
from rclone_api.rclone import Rclone
|
2
|
+
|
3
|
+
|
1
4
|
class Remote:
|
2
|
-
"""Remote
|
5
|
+
"""Remote (root) directory."""
|
3
6
|
|
4
|
-
def __init__(self, name: str) -> None:
|
7
|
+
def __init__(self, name: str, rclone: Rclone) -> None:
|
5
8
|
self.name = name
|
9
|
+
self.rclone = rclone
|
6
10
|
|
7
11
|
def __str__(self) -> str:
|
8
12
|
return f"{self.name}:"
|
rclone_api/walk.py
CHANGED
@@ -4,20 +4,25 @@ from typing import Generator
|
|
4
4
|
|
5
5
|
from rclone_api import Dir
|
6
6
|
from rclone_api.dir_listing import DirListing
|
7
|
+
from rclone_api.remote import Remote
|
7
8
|
|
8
9
|
|
9
10
|
def walk(
|
10
|
-
dir: Dir, max_depth: int = -1, max_workers: int = 4
|
11
|
+
dir: Dir | Remote, max_depth: int = -1, max_workers: int = 4
|
11
12
|
) -> Generator[DirListing, None, None]:
|
12
13
|
"""Walk through the given directory recursively.
|
13
14
|
|
14
15
|
Args:
|
15
|
-
dir: Directory to walk through
|
16
|
+
dir: Directory or Remote to walk through
|
16
17
|
max_depth: Maximum depth to traverse (-1 for unlimited)
|
18
|
+
max_workers: Maximum number of concurrent workers
|
17
19
|
|
18
20
|
Yields:
|
19
21
|
DirListing: Directory listing for each directory encountered
|
20
22
|
"""
|
23
|
+
# Convert Remote to Dir if needed
|
24
|
+
if isinstance(dir, Remote):
|
25
|
+
dir = Dir(dir)
|
21
26
|
pending: Queue[tuple[Dir | None, int]] = Queue()
|
22
27
|
results: Queue[DirListing | Exception] = Queue()
|
23
28
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
rclone_api/__init__.py,sha256=YH7KQaPwUiJWJiRf0NRKD7XHhMXsxWdXDjt9WLSwdjA,265
|
2
|
+
rclone_api/cli.py,sha256=dibfAZIh0kXWsBbfp3onKLjyZXo54mTzDjUdzJlDlWo,231
|
3
|
+
rclone_api/config.py,sha256=UujjDNcpwgipgdyFPMhC3zikvlsrurUvvZiwXm5NlPg,471
|
4
|
+
rclone_api/dir.py,sha256=6rOjqBkITzA0nZE9aIZ15HbCbVDgxluM-LxhSrYrNXU,1487
|
5
|
+
rclone_api/dir_listing.py,sha256=NWleKHCCRW7_eh9JfRwE6r3QbjmiHD5ZEGQcd2vm4uY,458
|
6
|
+
rclone_api/file.py,sha256=409neYPfCUKQX2w7Uw7_D0wR2PtH42srNe9u_nnOLxM,925
|
7
|
+
rclone_api/rclone.py,sha256=EUsLW5qcipI5RzhpHUd0PQqQow43m2uKJmNgVR8ZBuU,2859
|
8
|
+
rclone_api/remote.py,sha256=AL5X89PB2RICVf84S_Oz8HqA3c7O_2LmsqJ_ArFVwhA,264
|
9
|
+
rclone_api/rpath.py,sha256=_k59z-O75hAhpPyUSH4glPEoiYtIS3RUQb7ltU9Ianw,2009
|
10
|
+
rclone_api/types.py,sha256=Yp15HrjwZonSQhE323R0WP7fA4NWqKjAfM7z3OwHpWI,518
|
11
|
+
rclone_api/util.py,sha256=EXnijLLdFHqwoZvHrZdqeM8r6T7ad9-pN7qBN1b0I_g,1465
|
12
|
+
rclone_api/walk.py,sha256=3GKnu9P5aPNiftfoi52U7wo1wixZxwxdqqS0_IlMGCE,2816
|
13
|
+
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
14
|
+
rclone_api-1.0.10.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
15
|
+
rclone_api-1.0.10.dist-info/METADATA,sha256=vqHNP5HxEgSOP30QRQYYXnIGxOBCC898DrBaraA8TjI,1245
|
16
|
+
rclone_api-1.0.10.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
17
|
+
rclone_api-1.0.10.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
18
|
+
rclone_api-1.0.10.dist-info/RECORD,,
|
@@ -1,18 +0,0 @@
|
|
1
|
-
rclone_api/__init__.py,sha256=YH7KQaPwUiJWJiRf0NRKD7XHhMXsxWdXDjt9WLSwdjA,265
|
2
|
-
rclone_api/cli.py,sha256=dibfAZIh0kXWsBbfp3onKLjyZXo54mTzDjUdzJlDlWo,231
|
3
|
-
rclone_api/config.py,sha256=UujjDNcpwgipgdyFPMhC3zikvlsrurUvvZiwXm5NlPg,471
|
4
|
-
rclone_api/dir.py,sha256=uHe3PyuPc1kDxkvWTCuatjoArPUt9BwS8tNx9Uajx70,781
|
5
|
-
rclone_api/dir_listing.py,sha256=NWleKHCCRW7_eh9JfRwE6r3QbjmiHD5ZEGQcd2vm4uY,458
|
6
|
-
rclone_api/file.py,sha256=409neYPfCUKQX2w7Uw7_D0wR2PtH42srNe9u_nnOLxM,925
|
7
|
-
rclone_api/rclone.py,sha256=Q3xwC8m47gBVULWSn2XttIBDl33DtCBopvxcOG5LeEA,1837
|
8
|
-
rclone_api/remote.py,sha256=RSD-X2jCnm_hq7K6ovJ_0ugM1OpI0vpECIHHEz16-Fs,173
|
9
|
-
rclone_api/rpath.py,sha256=_k59z-O75hAhpPyUSH4glPEoiYtIS3RUQb7ltU9Ianw,2009
|
10
|
-
rclone_api/types.py,sha256=Yp15HrjwZonSQhE323R0WP7fA4NWqKjAfM7z3OwHpWI,518
|
11
|
-
rclone_api/util.py,sha256=EXnijLLdFHqwoZvHrZdqeM8r6T7ad9-pN7qBN1b0I_g,1465
|
12
|
-
rclone_api/walk.py,sha256=I-i010WNjGauQTCeH9EZByh9NNi53vw_OS3NvY0B9z8,2604
|
13
|
-
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
14
|
-
rclone_api-1.0.9.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
15
|
-
rclone_api-1.0.9.dist-info/METADATA,sha256=5bs99jY-sPmJGxdereaHm_c3xKbysnKoRwjlFp9CLSc,1244
|
16
|
-
rclone_api-1.0.9.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
17
|
-
rclone_api-1.0.9.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
18
|
-
rclone_api-1.0.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|