rclone-api 1.0.49__tar.gz → 1.0.50__tar.gz

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rclone-api might be problematic. Click here for more details.

Files changed (67) hide show
  1. {rclone_api-1.0.49 → rclone_api-1.0.50}/PKG-INFO +1 -1
  2. {rclone_api-1.0.49 → rclone_api-1.0.50}/pyproject.toml +1 -1
  3. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/file.py +54 -47
  4. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/group_files.py +29 -8
  5. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/rclone.py +670 -677
  6. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api.egg-info/PKG-INFO +1 -1
  7. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api.egg-info/SOURCES.txt +1 -0
  8. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_copy.py +1 -1
  9. rclone_api-1.0.50/tests/test_copy_files.py +94 -0
  10. rclone_api-1.0.50/tests/test_group_files.py +144 -0
  11. rclone_api-1.0.49/tests/test_group_files.py +0 -101
  12. {rclone_api-1.0.49 → rclone_api-1.0.50}/.aiderignore +0 -0
  13. {rclone_api-1.0.49 → rclone_api-1.0.50}/.github/workflows/lint.yml +0 -0
  14. {rclone_api-1.0.49 → rclone_api-1.0.50}/.github/workflows/push_macos.yml +0 -0
  15. {rclone_api-1.0.49 → rclone_api-1.0.50}/.github/workflows/push_ubuntu.yml +0 -0
  16. {rclone_api-1.0.49 → rclone_api-1.0.50}/.github/workflows/push_win.yml +0 -0
  17. {rclone_api-1.0.49 → rclone_api-1.0.50}/.gitignore +0 -0
  18. {rclone_api-1.0.49 → rclone_api-1.0.50}/.pylintrc +0 -0
  19. {rclone_api-1.0.49 → rclone_api-1.0.50}/.vscode/launch.json +0 -0
  20. {rclone_api-1.0.49 → rclone_api-1.0.50}/.vscode/settings.json +0 -0
  21. {rclone_api-1.0.49 → rclone_api-1.0.50}/.vscode/tasks.json +0 -0
  22. {rclone_api-1.0.49 → rclone_api-1.0.50}/LICENSE +0 -0
  23. {rclone_api-1.0.49 → rclone_api-1.0.50}/MANIFEST.in +0 -0
  24. {rclone_api-1.0.49 → rclone_api-1.0.50}/README.md +0 -0
  25. {rclone_api-1.0.49 → rclone_api-1.0.50}/clean +0 -0
  26. {rclone_api-1.0.49 → rclone_api-1.0.50}/install +0 -0
  27. {rclone_api-1.0.49 → rclone_api-1.0.50}/lint +0 -0
  28. {rclone_api-1.0.49 → rclone_api-1.0.50}/requirements.testing.txt +0 -0
  29. {rclone_api-1.0.49 → rclone_api-1.0.50}/setup.cfg +0 -0
  30. {rclone_api-1.0.49 → rclone_api-1.0.50}/setup.py +0 -0
  31. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/__init__.py +0 -0
  32. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/assets/example.txt +0 -0
  33. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/cli.py +0 -0
  34. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/cmd/list_files.py +0 -0
  35. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/completed_process.py +0 -0
  36. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/config.py +0 -0
  37. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/convert.py +0 -0
  38. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/deprecated.py +0 -0
  39. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/diff.py +0 -0
  40. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/dir.py +0 -0
  41. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/dir_listing.py +0 -0
  42. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/exec.py +0 -0
  43. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/filelist.py +0 -0
  44. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/process.py +0 -0
  45. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/remote.py +0 -0
  46. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/rpath.py +0 -0
  47. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/util.py +0 -0
  48. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api/walk.py +0 -0
  49. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api.egg-info/dependency_links.txt +0 -0
  50. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api.egg-info/entry_points.txt +0 -0
  51. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api.egg-info/requires.txt +0 -0
  52. {rclone_api-1.0.49 → rclone_api-1.0.50}/src/rclone_api.egg-info/top_level.txt +0 -0
  53. {rclone_api-1.0.49 → rclone_api-1.0.50}/test +0 -0
  54. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_cmd_list_files.py +0 -0
  55. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_diff.py +0 -0
  56. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_is_synced.py +0 -0
  57. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_ls.py +0 -0
  58. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_mount.py +0 -0
  59. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_mount_s3.py +0 -0
  60. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_mount_webdav.py +0 -0
  61. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_obscure.py +0 -0
  62. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_remote_control.py +0 -0
  63. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_remotes.py +0 -0
  64. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_serve_webdav.py +0 -0
  65. {rclone_api-1.0.49 → rclone_api-1.0.50}/tests/test_walk.py +0 -0
  66. {rclone_api-1.0.49 → rclone_api-1.0.50}/tox.ini +0 -0
  67. {rclone_api-1.0.49 → rclone_api-1.0.50}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.0.49
3
+ Version: 1.0.50
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  Maintainer: Zachary Vorhies
@@ -15,7 +15,7 @@ dependencies = [
15
15
  "python-dotenv>=1.0.0",
16
16
  ]
17
17
  # Change this with the version number bump.
18
- version = "1.0.49"
18
+ version = "1.0.50"
19
19
 
20
20
  [tool.setuptools]
21
21
  package-dir = {"" = "src"}
@@ -1,47 +1,54 @@
1
- import json
2
-
3
- from rclone_api.rpath import RPath
4
-
5
-
6
- class File:
7
- """Remote file dataclass."""
8
-
9
- def __init__(
10
- self,
11
- path: RPath,
12
- ) -> None:
13
- self.path = path
14
-
15
- @property
16
- def name(self) -> str:
17
- return self.path.name
18
-
19
- def read_text(self) -> str:
20
- """Read the file contents as bytes.
21
-
22
- Returns:
23
- bytes: The file contents
24
-
25
- Raises:
26
- RuntimeError: If no rclone instance is associated with this file
27
- RuntimeError: If the path represents a directory
28
- """
29
- if self.path.rclone is None:
30
- raise RuntimeError("No rclone instance associated with this file")
31
- if self.path.is_dir:
32
- raise RuntimeError("Cannot read a directory as bytes")
33
-
34
- result = self.path.rclone._run(["cat", self.path.path], check=True)
35
- return result.stdout
36
-
37
- def to_json(self) -> dict:
38
- """Convert the File to a JSON serializable dictionary."""
39
- return self.path.to_json()
40
-
41
- def __str__(self) -> str:
42
- return str(self.path)
43
-
44
- def __repr__(self) -> str:
45
- data = self.path.to_json()
46
- data_str = json.dumps(data)
47
- return data_str
1
+ import json
2
+
3
+ from rclone_api.rpath import RPath
4
+
5
+
6
+ class File:
7
+ """Remote file dataclass."""
8
+
9
+ def __init__(
10
+ self,
11
+ path: RPath,
12
+ ) -> None:
13
+ self.path = path
14
+
15
+ @property
16
+ def name(self) -> str:
17
+ return self.path.name
18
+
19
+ def read_text(self) -> str:
20
+ """Read the file contents as bytes.
21
+
22
+ Returns:
23
+ bytes: The file contents
24
+
25
+ Raises:
26
+ RuntimeError: If no rclone instance is associated with this file
27
+ RuntimeError: If the path represents a directory
28
+ """
29
+ if self.path.rclone is None:
30
+ raise RuntimeError("No rclone instance associated with this file")
31
+ if self.path.is_dir:
32
+ raise RuntimeError("Cannot read a directory as bytes")
33
+
34
+ result = self.path.rclone._run(["cat", self.path.path], check=True)
35
+ return result.stdout
36
+
37
+ def to_json(self) -> dict:
38
+ """Convert the File to a JSON serializable dictionary."""
39
+ return self.path.to_json()
40
+
41
+ def to_string(self, include_remote: bool = True) -> str:
42
+ """Convert the File to a string."""
43
+ out = str(self.path)
44
+ if not include_remote:
45
+ _, out = out.split(":", 1)
46
+ return out
47
+
48
+ def __str__(self) -> str:
49
+ return str(self.path)
50
+
51
+ def __repr__(self) -> str:
52
+ data = self.path.to_json()
53
+ data_str = json.dumps(data)
54
+ return data_str
@@ -112,12 +112,19 @@ def _make_tree(files: list[str]) -> dict[str, TreeNode]:
112
112
  parts = parse_file(file)
113
113
  remote = parts.remote
114
114
  node: TreeNode = tree.setdefault(remote, TreeNode(remote))
115
- for parent in parts.parents:
116
- is_last = parent == parts.parents[-1]
117
- node = node.child_nodes.setdefault(parent, TreeNode(parent, parent=node))
118
- if is_last:
119
- node.files.append(parts.name)
120
- node.add_count_bubble_up()
115
+ if parts.parents:
116
+ for parent in parts.parents:
117
+ is_last = parent == parts.parents[-1]
118
+ node = node.child_nodes.setdefault(
119
+ parent, TreeNode(parent, parent=node)
120
+ )
121
+ if is_last:
122
+ node.files.append(parts.name)
123
+ node.add_count_bubble_up()
124
+ else:
125
+ node.files.append(parts.name)
126
+ node.add_count_bubble_up()
127
+
121
128
  return tree
122
129
 
123
130
 
@@ -134,13 +141,27 @@ def _fixup_rclone_paths(outpaths: dict[str, list[str]]) -> dict[str, list[str]]:
134
141
  return out
135
142
 
136
143
 
137
- def group_files(files: list[str]) -> dict[str, list[str]]:
144
+ def group_files(files: list[str], fully_qualified: bool = True) -> dict[str, list[str]]:
138
145
  """split between filename and parent directory path"""
146
+ if fully_qualified is False:
147
+ for i, file in enumerate(files):
148
+ file = "root:" + file
149
+ files[i] = file
139
150
  tree: dict[str, TreeNode] = _make_tree(files)
140
151
  outpaths: dict[str, list[str]] = {}
141
152
  for _, node in tree.items():
142
153
  _merge(node, "", outpaths)
143
- out: dict[str, list[str]] = _fixup_rclone_paths(outpaths=outpaths)
154
+ tmp: dict[str, list[str]] = _fixup_rclone_paths(outpaths=outpaths)
155
+ out: dict[str, list[str]] = {}
156
+ if fully_qualified is False:
157
+ for path, files in tmp.items():
158
+ if path.startswith("root"):
159
+ path = path.replace("root", "")
160
+ if path.startswith(":"):
161
+ path = path[1:]
162
+ out[path] = [file.replace("/root/", "") for file in files]
163
+ else:
164
+ out = tmp
144
165
  return out
145
166
 
146
167