rclone-api 1.0.22__py2.py3-none-any.whl → 1.0.24__py2.py3-none-any.whl

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.
@@ -0,0 +1,27 @@
1
+ import argparse
2
+ from pathlib import Path
3
+
4
+ from rclone_api import Rclone
5
+
6
+
7
+ def list_files(rclone: Rclone, path: str):
8
+ """List files in a remote path."""
9
+ for dirlisting in rclone.walk(path):
10
+ for file in dirlisting.files:
11
+ print(file.path)
12
+
13
+
14
+ def _parse_args() -> argparse.Namespace:
15
+ parser = argparse.ArgumentParser(description="List files in a remote path.")
16
+ parser.add_argument("--config", help="Path to rclone config file", required=True)
17
+ parser.add_argument("path", help="Remote path to list")
18
+ return parser.parse_args()
19
+
20
+
21
+ def main() -> int:
22
+ """Main entry point."""
23
+ args = _parse_args()
24
+ path = args.path
25
+ rclone = Rclone(Path(args.config))
26
+ list_files(rclone, path)
27
+ return 0
rclone_api/rclone.py CHANGED
@@ -6,6 +6,7 @@ import subprocess
6
6
  import time
7
7
  import warnings
8
8
  from concurrent.futures import ThreadPoolExecutor
9
+ from enum import Enum
9
10
  from fnmatch import fnmatch
10
11
  from pathlib import Path
11
12
  from typing import Generator
@@ -23,6 +24,11 @@ from rclone_api.util import get_rclone_exe, to_path, wait_for_mount
23
24
  from rclone_api.walk import walk
24
25
 
25
26
 
27
+ class ModTimeStrategy(Enum):
28
+ USE_SERVER_MODTIME = "use-server-modtime"
29
+ NO_MODTIME = "no-modtime"
30
+
31
+
26
32
  class Rclone:
27
33
  def __init__(
28
34
  self, rclone_conf: Path | Config, rclone_exe: Path | None = None
@@ -299,6 +305,7 @@ class Rclone:
299
305
  url: str,
300
306
  outdir: Path,
301
307
  vfs_cache_mode="full",
308
+ vfs_disk_space_total_size: str | None = "10G",
302
309
  other_cmds: list[str] | None = None,
303
310
  ) -> Process:
304
311
  """Mount a remote or directory to a local path.
@@ -327,10 +334,55 @@ class Rclone:
327
334
  cmd_list.append(vfs_cache_mode)
328
335
  if other_cmds:
329
336
  cmd_list += other_cmds
337
+ if vfs_disk_space_total_size is not None:
338
+ cmd_list.append("--vfs-cache-max-size")
339
+ cmd_list.append(vfs_disk_space_total_size)
330
340
  proc = self._launch_process(cmd_list)
331
341
  wait_for_mount(outdir, proc)
332
342
  return proc
333
343
 
344
+ def mount_s3(
345
+ self,
346
+ url: str,
347
+ outdir: Path,
348
+ vfs_cache_mode="full",
349
+ transfers: int | None = 16,
350
+ modtime_strategy: (
351
+ ModTimeStrategy | None
352
+ ) = ModTimeStrategy.USE_SERVER_MODTIME, # speeds up S3 operations
353
+ vfs_read_chunk_streams: int | None = 16,
354
+ vfs_read_chunk_size: str | None = "4M",
355
+ vfs_fast_fingerprint: bool = True,
356
+ other_cmds: list[str] | None = None,
357
+ ) -> Process:
358
+ """Mount a remote or directory to a local path.
359
+
360
+ Args:
361
+ src: Remote or directory to mount
362
+ outdir: Local path to mount to
363
+ """
364
+ other_cmds = other_cmds or []
365
+ if modtime_strategy is not None:
366
+ other_cmds.append(f"--{modtime_strategy.value}")
367
+ if (vfs_cache_mode == "full" or vfs_cache_mode == "writes") and (
368
+ transfers is not None
369
+ ):
370
+ other_cmds.append("--transfers")
371
+ other_cmds.append(str(transfers))
372
+ if vfs_read_chunk_streams:
373
+ other_cmds.append("--vfs-read-chunk-streams")
374
+ other_cmds.append(str(vfs_read_chunk_streams))
375
+ if vfs_read_chunk_size:
376
+ other_cmds.append("--vfs-read-chunk-size")
377
+ other_cmds.append(vfs_read_chunk_size)
378
+ if vfs_fast_fingerprint:
379
+ other_cmds.append("--vfs-fast-fingerprint")
380
+
381
+ other_cmds = other_cmds if other_cmds else None
382
+ return self.mount(
383
+ url, outdir, vfs_cache_mode=vfs_cache_mode, other_cmds=other_cmds
384
+ )
385
+
334
386
  def serve_webdav(
335
387
  self,
336
388
  src: Remote | Dir | str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.0.22
3
+ Version: 1.0.24
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  Maintainer: Zachary Vorhies
@@ -8,14 +8,16 @@ rclone_api/exec.py,sha256=9qSOpZo8YRYxv3hOvNr57ApnY2KbjxwT1QNr8OgcLM4,883
8
8
  rclone_api/file.py,sha256=D02iHJW1LhfOiM_R_yPHP8_ApnDiYrkuraVcrV8-qkw,1246
9
9
  rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
10
10
  rclone_api/process.py,sha256=iVA8_qtJFgHtg92Yb4W7xv9jnyds_7kAdKeSiGCBIZ0,3952
11
- rclone_api/rclone.py,sha256=RBlEi7M8Jpgt8oJcV-2VrhF-iVAtGlpfBJ7YXGjPS_s,12649
11
+ rclone_api/rclone.py,sha256=jNZVeTPyNH2BwGsA7OIs18PkMSBOmQLxS0yz6dHlkAU,14596
12
12
  rclone_api/remote.py,sha256=c9hlRKBCg1BFB9MCINaQIoCg10qyAkeqiS4brl8ce-8,343
13
13
  rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
14
14
  rclone_api/util.py,sha256=AWTImA1liCMw52wtS-Gs8Abz96diQ39x6Tx56mvbrEo,3860
15
15
  rclone_api/walk.py,sha256=kca0t1GAnF6FLclN01G8NG__Qe-ggodLtAbQSHyVPng,2968
16
16
  rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
17
- rclone_api-1.0.22.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
18
- rclone_api-1.0.22.dist-info/METADATA,sha256=dl2QJr1Q_oRiRNLB9gC-ZWAbCgHUxqUm-cdBVjPEFnI,4454
19
- rclone_api-1.0.22.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
20
- rclone_api-1.0.22.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
21
- rclone_api-1.0.22.dist-info/RECORD,,
17
+ rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
18
+ rclone_api-1.0.24.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
19
+ rclone_api-1.0.24.dist-info/METADATA,sha256=6Kv_3ixSg65E3cPLSATze1pRx_O2JMqcxbtDNDC7_cA,4454
20
+ rclone_api-1.0.24.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
21
+ rclone_api-1.0.24.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
22
+ rclone_api-1.0.24.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
23
+ rclone_api-1.0.24.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ rclone-api-listfiles = rclone_api.cmd.list_files:main