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.
Files changed (36) hide show
  1. {rclone_api-1.0.4/src/rclone_api.egg-info → rclone_api-1.0.5}/PKG-INFO +1 -1
  2. {rclone_api-1.0.4 → rclone_api-1.0.5}/pyproject.toml +1 -1
  3. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/__init__.py +2 -1
  4. rclone_api-1.0.5/src/rclone_api/dir_listing.py +12 -0
  5. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/rclone.py +9 -4
  6. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/rpath.py +0 -36
  7. {rclone_api-1.0.4 → rclone_api-1.0.5/src/rclone_api.egg-info}/PKG-INFO +1 -1
  8. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api.egg-info/SOURCES.txt +1 -0
  9. {rclone_api-1.0.4 → rclone_api-1.0.5}/.gitignore +0 -0
  10. {rclone_api-1.0.4 → rclone_api-1.0.5}/.pylintrc +0 -0
  11. {rclone_api-1.0.4 → rclone_api-1.0.5}/.vscode/launch.json +0 -0
  12. {rclone_api-1.0.4 → rclone_api-1.0.5}/.vscode/settings.json +0 -0
  13. {rclone_api-1.0.4 → rclone_api-1.0.5}/.vscode/tasks.json +0 -0
  14. {rclone_api-1.0.4 → rclone_api-1.0.5}/LICENSE +0 -0
  15. {rclone_api-1.0.4 → rclone_api-1.0.5}/MANIFEST.in +0 -0
  16. {rclone_api-1.0.4 → rclone_api-1.0.5}/README.md +0 -0
  17. {rclone_api-1.0.4 → rclone_api-1.0.5}/clean +0 -0
  18. {rclone_api-1.0.4 → rclone_api-1.0.5}/install +0 -0
  19. {rclone_api-1.0.4 → rclone_api-1.0.5}/lint +0 -0
  20. {rclone_api-1.0.4 → rclone_api-1.0.5}/requirements.testing.txt +0 -0
  21. {rclone_api-1.0.4 → rclone_api-1.0.5}/setup.cfg +0 -0
  22. {rclone_api-1.0.4 → rclone_api-1.0.5}/setup.py +0 -0
  23. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/assets/example.txt +0 -0
  24. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/cli.py +0 -0
  25. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/config.py +0 -0
  26. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/dir.py +0 -0
  27. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/file.py +0 -0
  28. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/remote.py +0 -0
  29. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/types.py +0 -0
  30. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api/util.py +0 -0
  31. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api.egg-info/dependency_links.txt +0 -0
  32. {rclone_api-1.0.4 → rclone_api-1.0.5}/src/rclone_api.egg-info/top_level.txt +0 -0
  33. {rclone_api-1.0.4 → rclone_api-1.0.5}/test +0 -0
  34. {rclone_api-1.0.4 → rclone_api-1.0.5}/tests/test_simple.py +0 -0
  35. {rclone_api-1.0.4 → rclone_api-1.0.5}/tox.ini +0 -0
  36. {rclone_api-1.0.4 → rclone_api-1.0.5}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  Maintainer: Zachary Vorhies
@@ -14,7 +14,7 @@ dependencies = [
14
14
 
15
15
  ]
16
16
  # Change this with the version number bump.
17
- version = "1.0.4"
17
+ version = "1.0.5"
18
18
 
19
19
  [tool.setuptools]
20
20
  package-dir = {"" = "src"}
@@ -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"]
@@ -0,0 +1,12 @@
1
+ from dataclasses import dataclass
2
+
3
+ from rclone_api.dir import Dir
4
+ from rclone_api.file import File
5
+
6
+
7
+ @dataclass
8
+ class DirListing:
9
+ """Remote file dataclass."""
10
+
11
+ dirs: list[Dir]
12
+ files: list[File]
@@ -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) -> list[RPath]:
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
- out: list[RPath] = RPath.from_json_str(text)
44
- for o in out:
46
+ paths: list[RPath] = RPath.from_json_str(text)
47
+ for o in paths:
45
48
  o.set_rclone(self)
46
- return out
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  Maintainer: Zachary Vorhies
@@ -19,6 +19,7 @@ src/rclone_api/__init__.py
19
19
  src/rclone_api/cli.py
20
20
  src/rclone_api/config.py
21
21
  src/rclone_api/dir.py
22
+ src/rclone_api/dir_listing.py
22
23
  src/rclone_api/file.py
23
24
  src/rclone_api/rclone.py
24
25
  src/rclone_api/remote.py
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