rclone-api 1.0.4__tar.gz → 1.0.5__tar.gz
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-1.0.4/src/rclone_api.egg-info → rclone_api-1.0.5}/PKG-INFO +1 -1
- {rclone_api-1.0.4 → rclone_api-1.0.5}/pyproject.toml +1 -1
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/__init__.py +2 -1
- rclone_api-1.0.5/src/rclone_api/dir_listing.py +12 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/rclone.py +9 -4
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/rpath.py +0 -36
- {rclone_api-1.0.4 → rclone_api-1.0.5/src/rclone_api.egg-info}/PKG-INFO +1 -1
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api.egg-info/SOURCES.txt +1 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/.gitignore +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/.pylintrc +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/.vscode/launch.json +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/.vscode/settings.json +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/.vscode/tasks.json +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/LICENSE +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/MANIFEST.in +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/README.md +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/clean +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/install +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/lint +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/requirements.testing.txt +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/setup.cfg +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/setup.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/assets/example.txt +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/cli.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/config.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/dir.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/file.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/remote.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/types.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/util.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api.egg-info/dependency_links.txt +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api.egg-info/top_level.txt +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/test +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/tests/test_simple.py +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/tox.ini +0 -0
- {rclone_api-1.0.4 → rclone_api-1.0.5}/upload_package.sh +0 -0
@@ -1,8 +1,9 @@
|
|
1
1
|
from .dir import Dir
|
2
|
+
from .dir_listing import DirListing
|
2
3
|
from .file import File
|
3
4
|
from .rclone import Rclone
|
4
5
|
from .remote import Remote
|
5
6
|
from .rpath import RPath
|
6
7
|
from .types import Config
|
7
8
|
|
8
|
-
__all__ = ["Rclone", "File", "Config", "Remote", "Dir", "RPath"]
|
9
|
+
__all__ = ["Rclone", "File", "Config", "Remote", "Dir", "RPath", "DirListing"]
|
@@ -5,6 +5,9 @@ Unit test file.
|
|
5
5
|
import subprocess
|
6
6
|
from pathlib import Path
|
7
7
|
|
8
|
+
from rclone_api.dir import Dir
|
9
|
+
from rclone_api.dir_listing import DirListing
|
10
|
+
from rclone_api.file import File
|
8
11
|
from rclone_api.remote import Remote
|
9
12
|
from rclone_api.rpath import RPath
|
10
13
|
from rclone_api.types import Config, RcloneExec
|
@@ -23,7 +26,7 @@ class Rclone:
|
|
23
26
|
def _run(self, cmd: list[str]) -> subprocess.CompletedProcess:
|
24
27
|
return self._exec.execute(cmd)
|
25
28
|
|
26
|
-
def ls(self, path: str | Remote, max_depth: int = 0) ->
|
29
|
+
def ls(self, path: str | Remote, max_depth: int = 0) -> DirListing:
|
27
30
|
"""List files in the given path.
|
28
31
|
|
29
32
|
Args:
|
@@ -40,10 +43,12 @@ class Rclone:
|
|
40
43
|
|
41
44
|
cp = self._run(cmd)
|
42
45
|
text = cp.stdout
|
43
|
-
|
44
|
-
for o in
|
46
|
+
paths: list[RPath] = RPath.from_json_str(text)
|
47
|
+
for o in paths:
|
45
48
|
o.set_rclone(self)
|
46
|
-
|
49
|
+
dirs: list[Dir] = [Dir(o) for o in paths if o.is_dir]
|
50
|
+
files: list[File] = [File(o) for o in paths if not o.is_dir]
|
51
|
+
return DirListing(dirs=dirs, files=files)
|
47
52
|
|
48
53
|
def listremotes(self) -> list[Remote]:
|
49
54
|
cmd = ["listremotes"]
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import json
|
2
|
-
from pathlib import Path
|
3
2
|
from typing import Any
|
4
3
|
|
5
4
|
|
@@ -73,41 +72,6 @@ class RPath:
|
|
73
72
|
# "IsBucket": self.is_bucket,
|
74
73
|
}
|
75
74
|
|
76
|
-
def read_text(self) -> str:
|
77
|
-
"""Read the file contents as bytes.
|
78
|
-
|
79
|
-
Returns:
|
80
|
-
bytes: The file contents
|
81
|
-
|
82
|
-
Raises:
|
83
|
-
RuntimeError: If no rclone instance is associated with this file
|
84
|
-
RuntimeError: If the path represents a directory
|
85
|
-
"""
|
86
|
-
if self.rclone is None:
|
87
|
-
raise RuntimeError("No rclone instance associated with this file")
|
88
|
-
if self.is_dir:
|
89
|
-
raise RuntimeError("Cannot read a directory as bytes")
|
90
|
-
|
91
|
-
result = self.rclone._run(["cat", self.path])
|
92
|
-
return result.stdout
|
93
|
-
|
94
|
-
def read(self, dest: Path) -> None:
|
95
|
-
"""Copy the remote file to a local destination path.
|
96
|
-
|
97
|
-
Args:
|
98
|
-
dest: Local destination path where the file will be copied
|
99
|
-
|
100
|
-
Raises:
|
101
|
-
RuntimeError: If no rclone instance is associated with this file
|
102
|
-
RuntimeError: If the path represents a directory
|
103
|
-
"""
|
104
|
-
if self.rclone is None:
|
105
|
-
raise RuntimeError("No rclone instance associated with this file")
|
106
|
-
if self.is_dir:
|
107
|
-
raise RuntimeError("Cannot read a directory as a file")
|
108
|
-
|
109
|
-
self.rclone._run(["copyto", self.path, str(dest)])
|
110
|
-
|
111
75
|
def __str__(self) -> str:
|
112
76
|
out = self.to_json()
|
113
77
|
return json.dumps(out)
|
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
|