rclone-api 1.0.58__py2.py3-none-any.whl → 1.0.59__py2.py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
rclone_api/dir.py CHANGED
@@ -41,11 +41,11 @@ class Dir:
41
41
  # self.path.set_rclone(self.path.remote.rclone)
42
42
  assert self.path.rclone is not None
43
43
 
44
- def ls(self, max_depth: int = 0) -> DirListing:
44
+ def ls(self, max_depth: int = 0, reverse: bool = False) -> DirListing:
45
45
  """List files and directories in the given path."""
46
46
  assert self.path.rclone is not None
47
47
  dir = Dir(self.path)
48
- return self.path.rclone.ls(dir, max_depth=max_depth)
48
+ return self.path.rclone.ls(dir, max_depth=max_depth, reverse=reverse)
49
49
 
50
50
  def walk(
51
51
  self, breadth_first: bool, max_depth: int = -1
rclone_api/rclone.py CHANGED
@@ -72,7 +72,7 @@ class Rclone:
72
72
 
73
73
  def launch_server(
74
74
  self,
75
- addr: str | None = None,
75
+ addr: str,
76
76
  user: str | None = None,
77
77
  password: str | None = None,
78
78
  other_args: list[str] | None = None,
@@ -122,6 +122,7 @@ class Rclone:
122
122
  path: Dir | Remote | str,
123
123
  max_depth: int | None = None,
124
124
  glob: str | None = None,
125
+ reverse: bool = False,
125
126
  ) -> DirListing:
126
127
  """List files in the given path.
127
128
 
@@ -162,6 +163,9 @@ class Rclone:
162
163
  # do we have a glob pattern?
163
164
  if glob is not None:
164
165
  paths = [p for p in paths if fnmatch(p.path, glob)]
166
+
167
+ if reverse:
168
+ paths.reverse()
165
169
  return DirListing(paths)
166
170
 
167
171
  def listremotes(self) -> list[Remote]:
@@ -175,9 +179,21 @@ class Rclone:
175
179
  out = [Remote(name=t, rclone=self) for t in tmp]
176
180
  return out
177
181
 
178
- def diff(self, src: str, dst: str) -> Generator[DiffItem, None, None]:
182
+ def diff(
183
+ self,
184
+ src: str,
185
+ dst: str,
186
+ min_size: (
187
+ str | None
188
+ ) = None, # e. g. "1MB" - see rclone documentation: https://rclone.org/commands/rclone_check/
189
+ max_size: (
190
+ str | None
191
+ ) = None, # e. g. "1GB" - see rclone documentation: https://rclone.org/commands/rclone_check/
192
+ other_args: list[str] | None = None,
193
+ ) -> Generator[DiffItem, None, None]:
179
194
  """Be extra careful with the src and dst values. If you are off by one
180
195
  parent directory, you will get a huge amount of false diffs."""
196
+ other_args = other_args or []
181
197
  cmd = [
182
198
  "check",
183
199
  src,
@@ -189,6 +205,12 @@ class Rclone:
189
205
  "--combined",
190
206
  "-",
191
207
  ]
208
+ if min_size:
209
+ cmd += ["--min-size", min_size]
210
+ if max_size:
211
+ cmd += ["--max-size", max_size]
212
+ if other_args:
213
+ cmd += other_args
192
214
  proc = self._launch_process(cmd, capture=True)
193
215
  item: DiffItem
194
216
  for item in diff_stream_from_running_process(proc, src_slug=src, dst_slug=dst):
@@ -197,7 +219,11 @@ class Rclone:
197
219
  yield item
198
220
 
199
221
  def walk(
200
- self, path: Dir | Remote | str, max_depth: int = -1, breadth_first: bool = True
222
+ self,
223
+ path: Dir | Remote | str,
224
+ max_depth: int = -1,
225
+ breadth_first: bool = True,
226
+ reverse: bool = False,
201
227
  ) -> Generator[DirListing, None, None]:
202
228
  """Walk through the given path recursively.
203
229
 
@@ -231,7 +257,9 @@ class Rclone:
231
257
  dir_obj = Dir(path) # shut up pyright
232
258
  assert f"Invalid type for path: {type(path)}"
233
259
 
234
- yield from walk(dir_obj, max_depth=max_depth, breadth_first=breadth_first)
260
+ yield from walk(
261
+ dir_obj, max_depth=max_depth, breadth_first=breadth_first, reverse=reverse
262
+ )
235
263
 
236
264
  def cleanup(
237
265
  self, path: str, other_args: list[str] | None = None
rclone_api/walk.py CHANGED
@@ -10,14 +10,17 @@ _MAX_OUT_QUEUE_SIZE = 50
10
10
 
11
11
 
12
12
  def _walk_runner_breadth_first(
13
- dir: Dir, max_depth: int, out_queue: Queue[DirListing | None]
13
+ dir: Dir,
14
+ max_depth: int,
15
+ out_queue: Queue[DirListing | None],
16
+ reverse: bool = False,
14
17
  ) -> None:
15
18
  queue: Queue[Dir] = Queue()
16
19
  queue.put(dir)
17
20
  try:
18
21
  while not queue.empty():
19
22
  current_dir = queue.get()
20
- dirlisting = current_dir.ls()
23
+ dirlisting = current_dir.ls(max_depth=0, reverse=reverse)
21
24
  out_queue.put(dirlisting)
22
25
  dirs = dirlisting.dirs
23
26
 
@@ -38,20 +41,22 @@ def _walk_runner_breadth_first(
38
41
 
39
42
 
40
43
  def _walk_runner_depth_first(
41
- dir: Dir, max_depth: int, out_queue: Queue[DirListing | None]
44
+ dir: Dir, max_depth: int, out_queue: Queue[DirListing | None], reverse=False
42
45
  ) -> None:
43
46
  try:
44
47
  stack = [(dir, max_depth)]
45
48
  while stack:
46
49
  current_dir, depth = stack.pop()
47
50
  dirlisting = current_dir.ls()
51
+ if reverse:
52
+ dirlisting.dirs.reverse()
48
53
  if depth != 0:
49
- for subdir in reversed(
50
- dirlisting.dirs
51
- ): # Process deeper directories first
54
+ for subdir in dirlisting.dirs: # Process deeper directories first
52
55
  # stack.append((child, depth - 1 if depth > 0 else depth))
53
56
  next_depth = depth - 1 if depth > 0 else depth
54
- _walk_runner_depth_first(subdir, next_depth, out_queue)
57
+ _walk_runner_depth_first(
58
+ subdir, next_depth, out_queue, reverse=reverse
59
+ )
55
60
  out_queue.put(dirlisting)
56
61
  out_queue.put(None)
57
62
  except KeyboardInterrupt:
@@ -65,6 +70,7 @@ def walk(
65
70
  dir: Dir | Remote,
66
71
  breadth_first: bool,
67
72
  max_depth: int = -1,
73
+ reverse: bool = False,
68
74
  ) -> Generator[DirListing, None, None]:
69
75
  """Walk through the given directory recursively.
70
76
 
@@ -88,7 +94,7 @@ def walk(
88
94
  # Start worker thread
89
95
  worker = Thread(
90
96
  target=strategy,
91
- args=(dir, max_depth, out_queue),
97
+ args=(dir, max_depth, out_queue, reverse),
92
98
  daemon=True,
93
99
  )
94
100
  worker.start()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.0.58
3
+ Version: 1.0.59
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  Maintainer: Zachary Vorhies
@@ -5,23 +5,23 @@ rclone_api/config.py,sha256=tP6cU9DnCCEIRc_KP9HPur1jFLLg2QGFSxNwFm6_MVw,118
5
5
  rclone_api/convert.py,sha256=Mx9Qo7zhkOedJd8LdhPvNGHp8znJzOk4f_2KWnoGc78,1012
6
6
  rclone_api/deprecated.py,sha256=qWKpnZdYcBK7YQZKuVoWWXDwi-uqiAtbjgPcci_efow,590
7
7
  rclone_api/diff.py,sha256=ELUQD1Mv8qaoAav13sEE-iKynFph70rQHj7-a4Z1pyo,4137
8
- rclone_api/dir.py,sha256=vV-bcI2ESijmwF5rPID5WO2K7soAfZa35wv4KRh_GIo,2154
8
+ rclone_api/dir.py,sha256=2-PFaDpjEs28z82DQ-TyaCgrm_OgpwlkwfTnx1-Wwpk,2194
9
9
  rclone_api/dir_listing.py,sha256=9Qqf2SUswrOEkyqmaH23V51I18X6ePiXb9B1vUwRF5o,1571
10
10
  rclone_api/exec.py,sha256=1ovvaMXDEfLiT7BrYZyE85u_yFhEUwUNW3jPOzqknR8,1023
11
11
  rclone_api/file.py,sha256=YtR5Y6c0YfXTS-sReOy2UgiSnafcAeO6b2hnbojBQD4,1423
12
12
  rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
13
13
  rclone_api/group_files.py,sha256=kOHh6ysFDkxjldSwvW6KqmiADUC1yFCdrZRY57TvbGY,5328
14
14
  rclone_api/process.py,sha256=RrMfTe0bndmJ6gBK67ioqNvCstJ8aTC8RlGX1XBLlcw,4191
15
- rclone_api/rclone.py,sha256=D9Qdibcqff0Vry7hk4f_-xxrB8JoZHJq-XYS1NITDzM,25466
15
+ rclone_api/rclone.py,sha256=AvYskCZIQWRYRKC6L0cklqmCv2BDOJaiBDD24o_TALo,26216
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=IWNOOcPE0xdKvehzXQ9okIppGDBYWJPIfdbUME8BFVM,4015
19
- rclone_api/walk.py,sha256=kca0t1GAnF6FLclN01G8NG__Qe-ggodLtAbQSHyVPng,2968
19
+ rclone_api/walk.py,sha256=UaNOE3ICd8k5ouSFZvkVEH4r2GnnrD9TxfwkFcQnayo,3170
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.58.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
23
- rclone_api-1.0.58.dist-info/METADATA,sha256=UdbK32ilHGvATZ5ssYirx7I_2B0q19rJKQhEZnDC3yk,4489
24
- rclone_api-1.0.58.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
25
- rclone_api-1.0.58.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
26
- rclone_api-1.0.58.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
27
- rclone_api-1.0.58.dist-info/RECORD,,
22
+ rclone_api-1.0.59.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
23
+ rclone_api-1.0.59.dist-info/METADATA,sha256=m9Ti9AUHak_EQ_iWFIM8ZduiWKH5Cjy-L5yr6OFq50A,4489
24
+ rclone_api-1.0.59.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
25
+ rclone_api-1.0.59.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
26
+ rclone_api-1.0.59.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
27
+ rclone_api-1.0.59.dist-info/RECORD,,