rclone-api 1.0.43__py2.py3-none-any.whl → 1.0.45__py2.py3-none-any.whl

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.

rclone_api/__init__.py CHANGED
@@ -5,7 +5,7 @@ from .dir_listing import DirListing
5
5
  from .file import File
6
6
  from .filelist import FileList
7
7
  from .process import Process
8
- from .rclone import Rclone
8
+ from .rclone import Rclone, rclone_verbose
9
9
  from .remote import Remote
10
10
  from .rpath import RPath
11
11
 
@@ -21,4 +21,5 @@ __all__ = [
21
21
  "Process",
22
22
  "DiffItem",
23
23
  "DiffType",
24
+ "rclone_verbose",
24
25
  ]
rclone_api/group_files.py CHANGED
@@ -39,10 +39,10 @@ class TreeNode:
39
39
  self.count = 0
40
40
  self.parent = parent
41
41
 
42
- def add_count(self):
42
+ def add_count_bubble_up(self):
43
43
  self.count += 1
44
44
  if self.parent:
45
- self.parent.add_count()
45
+ self.parent.add_count_bubble_up()
46
46
 
47
47
  def get_path(self) -> str:
48
48
  paths_reversed: list[str] = [self.name]
@@ -85,9 +85,6 @@ def _merge(node: TreeNode, parent_path: str, out: dict[str, list[str]]) -> None:
85
85
  if node.files:
86
86
  # we saw files, to don't try to go any deeper.
87
87
  filelist = out.setdefault(parent_path, [])
88
- # for file in node.files:
89
- # filelist.append(file)
90
- # out[parent_path] = filelist
91
88
  paths = node.get_child_subpaths()
92
89
  for path in paths:
93
90
  filelist.append(path)
@@ -96,18 +93,12 @@ def _merge(node: TreeNode, parent_path: str, out: dict[str, list[str]]) -> None:
96
93
 
97
94
  n_child_nodes = len(node.child_nodes)
98
95
 
99
- if n_child_nodes < 4:
100
- # child = list(node.child_nodes.values())[0]
101
- # _merge(child, parent_path, out)
102
- # return
96
+ if n_child_nodes <= 2:
103
97
  for child in node.child_nodes.values():
104
98
  _merge(child, parent_path, out)
105
99
  return
106
100
 
107
101
  filelist = out.setdefault(parent_path, [])
108
- # for file in node.files:
109
- # filelist.append(file)
110
- # out[parent_path] = filelist
111
102
  paths = node.get_child_subpaths()
112
103
  for path in paths:
113
104
  filelist.append(path)
@@ -126,16 +117,12 @@ def _make_tree(files: list[str]) -> dict[str, TreeNode]:
126
117
  node = node.child_nodes.setdefault(parent, TreeNode(parent, parent=node))
127
118
  if is_last:
128
119
  node.files.append(parts.name)
129
- node.add_count()
120
+ node.add_count_bubble_up()
130
121
  return tree
131
122
 
132
123
 
133
- def group_files(files: list[str]) -> dict[str, list[str]]:
134
- """split between filename and parent directory path"""
135
- tree: dict[str, TreeNode] = _make_tree(files)
136
- outpaths: dict[str, list[str]] = {}
137
- for _, node in tree.items():
138
- _merge(node, "", outpaths)
124
+ #
125
+ def _fixup_rclone_paths(outpaths: dict[str, list[str]]) -> dict[str, list[str]]:
139
126
  out: dict[str, list[str]] = {}
140
127
  for path, files in outpaths.items():
141
128
  # fixup path
@@ -145,3 +132,16 @@ def group_files(files: list[str]) -> dict[str, list[str]]:
145
132
  path = path.replace("/", ":", 1)
146
133
  out[path] = files
147
134
  return out
135
+
136
+
137
+ def group_files(files: list[str]) -> dict[str, list[str]]:
138
+ """split between filename and parent directory path"""
139
+ tree: dict[str, TreeNode] = _make_tree(files)
140
+ outpaths: dict[str, list[str]] = {}
141
+ for _, node in tree.items():
142
+ _merge(node, "", outpaths)
143
+ out: dict[str, list[str]] = _fixup_rclone_paths(outpaths=outpaths)
144
+ return out
145
+
146
+
147
+ __all__ = ["group_files"]
rclone_api/rclone.py CHANGED
@@ -2,6 +2,7 @@
2
2
  Unit test file.
3
3
  """
4
4
 
5
+ import os
5
6
  import subprocess
6
7
  import time
7
8
  import warnings
@@ -36,6 +37,12 @@ from rclone_api.walk import walk
36
37
  EXECUTOR = ThreadPoolExecutor(16)
37
38
 
38
39
 
40
+ def rclone_verbose(verbose: bool | None) -> bool:
41
+ if verbose is not None:
42
+ os.environ["RCLONE_API_VERBOSE"] = "1" if verbose else "0"
43
+ return bool(int(os.getenv("RCLONE_API_VERBOSE", "0")))
44
+
45
+
39
46
  class ModTimeStrategy(Enum):
40
47
  USE_SERVER_MODTIME = "use-server-modtime"
41
48
  NO_MODTIME = "no-modtime"
@@ -178,6 +185,13 @@ class Rclone:
178
185
 
179
186
  yield from walk(dir_obj, max_depth=max_depth, breadth_first=breadth_first)
180
187
 
188
+ def cleanup(self, path: str) -> CompletedProcess:
189
+ """Cleanup any resources used by the Rclone instance."""
190
+ # rclone cleanup remote:path [flags]
191
+ cmd = ["cleanup", path]
192
+ out = self._run(cmd)
193
+ return CompletedProcess.from_subprocess(out)
194
+
181
195
  def copyfile(self, src: File | str, dst: File | str) -> None:
182
196
  """Copy a single file from source to destination.
183
197
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.0.43
3
+ Version: 1.0.45
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  Maintainer: Zachary Vorhies
@@ -1,4 +1,4 @@
1
- rclone_api/__init__.py,sha256=L_ulzYG9WmQqmrVANt-Omi1FJUQVTkXA7SVZx9QH_9M,457
1
+ rclone_api/__init__.py,sha256=fvWhio7i71rS5JtIr3l-36F6LRHo0ddpq0VX-6P5ldY,495
2
2
  rclone_api/cli.py,sha256=dibfAZIh0kXWsBbfp3onKLjyZXo54mTzDjUdzJlDlWo,231
3
3
  rclone_api/completed_process.py,sha256=s0flUibhTWU2d-KgVnZ62VGFS3HlICJrtPr8YJCdk3A,651
4
4
  rclone_api/config.py,sha256=tP6cU9DnCCEIRc_KP9HPur1jFLLg2QGFSxNwFm6_MVw,118
@@ -10,18 +10,18 @@ rclone_api/dir_listing.py,sha256=9Qqf2SUswrOEkyqmaH23V51I18X6ePiXb9B1vUwRF5o,157
10
10
  rclone_api/exec.py,sha256=HWmnU2Jwb-3EttSbAJSaLloYA7YI2mHTzRJ5VEri9aM,941
11
11
  rclone_api/file.py,sha256=D02iHJW1LhfOiM_R_yPHP8_ApnDiYrkuraVcrV8-qkw,1246
12
12
  rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
13
- rclone_api/group_files.py,sha256=FK9-DQV2rpl_EQSI6Y1NqcEA2WVkhBwLY5oP43bnp3k,4690
13
+ rclone_api/group_files.py,sha256=HxrRUi_kFlMblrCMFyv6rO56tVMEzgU4-vVeB_2-lbc,4606
14
14
  rclone_api/process.py,sha256=RrMfTe0bndmJ6gBK67ioqNvCstJ8aTC8RlGX1XBLlcw,4191
15
- rclone_api/rclone.py,sha256=zKLlHykEs43kt-FB3_YFvwPmRcHY2a3-fShMfGEjYH0,21004
15
+ rclone_api/rclone.py,sha256=D6621GGXotWym2lhpHIYzeQTnjC7j7wb4G-Mo7wbc6o,21513
16
16
  rclone_api/remote.py,sha256=c9hlRKBCg1BFB9MCINaQIoCg10qyAkeqiS4brl8ce-8,343
17
17
  rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
18
18
  rclone_api/util.py,sha256=sUjH5NmsawmNbPMY7V6hD8vFJXCwbl44XM1kuij3tA0,3918
19
19
  rclone_api/walk.py,sha256=kca0t1GAnF6FLclN01G8NG__Qe-ggodLtAbQSHyVPng,2968
20
20
  rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
21
21
  rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
22
- rclone_api-1.0.43.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
23
- rclone_api-1.0.43.dist-info/METADATA,sha256=De892IJwCIjjb710T9a4SvaBBYIjaf20D1JU_0cUwfM,4489
24
- rclone_api-1.0.43.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
25
- rclone_api-1.0.43.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
26
- rclone_api-1.0.43.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
27
- rclone_api-1.0.43.dist-info/RECORD,,
22
+ rclone_api-1.0.45.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
23
+ rclone_api-1.0.45.dist-info/METADATA,sha256=iikXSVPLGhKBfcKk5T63xDM6y4Fz0-EP98MiLOxVR10,4489
24
+ rclone_api-1.0.45.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
25
+ rclone_api-1.0.45.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
26
+ rclone_api-1.0.45.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
27
+ rclone_api-1.0.45.dist-info/RECORD,,