rclone-api 1.5.20__py3-none-any.whl → 1.5.22__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.
rclone_api/fs.py CHANGED
@@ -89,6 +89,21 @@ class RealFS(FS):
89
89
 
90
90
 
91
91
  class RemoteFS(FS):
92
+
93
+ @staticmethod
94
+ def from_rclone_config(
95
+ src: str, rclone_conf: Path | Config | str | None
96
+ ) -> "RemoteFS":
97
+ if isinstance(rclone_conf, str):
98
+ rclone_conf = Config(text=rclone_conf)
99
+ if rclone_conf is None:
100
+ curr_dir = Path.cwd() / "rclone.conf"
101
+ if curr_dir.exists():
102
+ rclone_conf = curr_dir
103
+ else:
104
+ raise ValueError("rclone_conf not found")
105
+ return RemoteFS(rclone_conf, src)
106
+
92
107
  def __init__(self, rclone_conf: Path | Config, src: str) -> None:
93
108
  from rclone_api import HttpServer, Rclone
94
109
 
@@ -131,7 +146,10 @@ class RemoteFS(FS):
131
146
  return self.server.exists(path)
132
147
 
133
148
  def mkdir(self, path: str, parents=True, exist_ok=True) -> None:
134
- raise NotImplementedError("RemoteFS does not support mkdir")
149
+ # Ignore mkdir for remote backend, it will be made when file is written.
150
+ import warnings
151
+ warnings.warn("mkdir is not supported for remote backend", stacklevel=2)
152
+ return None
135
153
 
136
154
  def is_dir(self, path: Path | str) -> bool:
137
155
  path = self._to_str(path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rclone_api
3
- Version: 1.5.20
3
+ Version: 1.5.22
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -43,6 +43,10 @@ This library was built out of necessity to transfer large amounts of AI training
43
43
 
44
44
  You can have [rclone](https://rclone.org/) in your path or else the api will download it.
45
45
 
46
+ ## VFS
47
+
48
+ There is a virtual file system called `FSPath` which emulates common operators for `pathlib.Path`. You can get an instance of an `FSPath` from an `Rclone` instance using the `rclone.cwd("src:path/to")` function.
49
+
46
50
  # Install
47
51
 
48
52
  `pip install rclone-api`
@@ -103,6 +107,71 @@ def test_ls_glob_png(self) -> None:
103
107
  ```python
104
108
 
105
109
  from rclone_api import Rclone
110
+ """
111
+ Rclone API - Python interface for the Rclone command-line tool.
112
+
113
+ This package provides a high-level API for interacting with Rclone,
114
+ allowing file operations across various cloud storage providers.
115
+ The API wraps the rclone command-line tool, providing a Pythonic interface
116
+ for common operations like copying, listing, and managing remote storage.
117
+ """
118
+
119
+ # Import core components and utilities
120
+ from datetime import datetime
121
+ from pathlib import Path
122
+ from typing import Generator
123
+
124
+ # Import logging utilities
125
+ from rclone_api import log
126
+
127
+ # Import data structures and models
128
+ from .completed_process import CompletedProcess
129
+ from .config import Config, Parsed, Section # Configuration handling
130
+ from .diff import DiffItem, DiffOption, DiffType # File comparison utilities
131
+ from .dir import Dir # Directory representation
132
+ from .dir_listing import DirListing # Directory contents representation
133
+ from .file import File, FileItem # File representation
134
+ from .file_stream import FilesStream # Streaming file listings
135
+ from .filelist import FileList # File list utilities
136
+ from .fs import FSPath, RemoteFS # Filesystem utilities
137
+ from .http_server import HttpFetcher, HttpServer, Range # HTTP serving capabilities
138
+
139
+ # Import logging configuration utilities
140
+ from .log import configure_logging, setup_default_logging
141
+ from .mount import Mount # Mount remote filesystems
142
+ from .process import Process # Process management
143
+ from .remote import Remote # Remote storage representation
144
+ from .rpath import RPath # Remote path utilities
145
+ from .s3.types import MultiUploadResult # S3-specific types
146
+ from .types import ( # Common types
147
+ ListingOption,
148
+ Order,
149
+ PartInfo,
150
+ SizeResult,
151
+ SizeSuffix,
152
+ )
153
+
154
+ # Set up default logging configuration when the package is imported
155
+ setup_default_logging()
156
+
157
+
158
+ def rclone_verbose(val: bool | None) -> bool:
159
+ """
160
+ Get or set the global verbosity setting for rclone operations.
161
+
162
+ Controls whether rclone commands will produce detailed output.
163
+ When enabled, commands will show more information about their operation.
164
+
165
+ Args:
166
+ val: If provided, sets the verbosity level. If None, returns the current setting.
167
+
168
+ Returns:
169
+ The current verbosity setting after any change.
170
+ """
171
+ from rclone_api.rclone_impl import rclone_verbose as _rclone_verbose
172
+
173
+ return _rclone_verbose(val)
174
+
106
175
 
107
176
  class Rclone:
108
177
  """
@@ -160,6 +229,27 @@ class Rclone:
160
229
  """
161
230
  return self.impl.webgui(other_args=other_args)
162
231
 
232
+ def filesystem(self, src: str) -> RemoteFS:
233
+ """
234
+ Get a RealFS object for interacting with the local filesystem.
235
+
236
+ Returns:
237
+ RealFS object for local filesystem operations
238
+ """
239
+ return self.impl.filesystem(src=src)
240
+
241
+ def cwd(self, src: str) -> FSPath:
242
+ """
243
+ Get the local root path for a filesystem.
244
+
245
+ Args:
246
+ src: Source path for the filesystem
247
+
248
+ Returns:
249
+ FSPath object representing the root of the filesystem
250
+ """
251
+ return self.impl.cwd(src=src)
252
+
163
253
  def launch_server(
164
254
  self,
165
255
  addr: str,
@@ -882,7 +972,7 @@ class Rclone:
882
972
  def serve_http(
883
973
  self,
884
974
  src: str,
885
- addr: str = "localhost:8080",
975
+ addr: str | None = None,
886
976
  other_args: list[str] | None = None,
887
977
  ) -> HttpServer:
888
978
  """
@@ -903,7 +993,9 @@ class Rclone:
903
993
  Returns:
904
994
  HttpServer object with methods for accessing the served content
905
995
  """
906
- return self.impl.serve_http(src=src, addr=addr, other_args=other_args)
996
+ return self.impl.serve_http(
997
+ src=src, cache_mode="minimal", addr=addr, other_args=other_args
998
+ )
907
999
 
908
1000
  def size_files(
909
1001
  self,
@@ -953,6 +1045,43 @@ class Rclone:
953
1045
  SizeSuffix object representing the file size, or Exception if an error occurred
954
1046
  """
955
1047
  return self.impl.size_file(src=src)
1048
+
1049
+
1050
+ # Export public API components
1051
+ __all__ = [
1052
+ # Main classes
1053
+ "Rclone", # Primary interface
1054
+ "File", # File representation
1055
+ "Config", # Configuration handling
1056
+ "Remote", # Remote storage
1057
+ "Dir", # Directory representation
1058
+ "RPath", # Remote path utilities
1059
+ "DirListing", # Directory listing
1060
+ "FileList", # File list
1061
+ "FileItem", # File item
1062
+ "Process", # Process management
1063
+ "DiffItem", # Difference item
1064
+ "DiffType", # Difference type
1065
+ # Functions
1066
+ "rclone_verbose", # Verbosity control
1067
+ # Data classes and enums
1068
+ "CompletedProcess", # Process result
1069
+ "DiffOption", # Difference options
1070
+ "ListingOption", # Listing options
1071
+ "Order", # Sorting order
1072
+ "SizeResult", # Size result
1073
+ "Parsed", # Parsed configuration
1074
+ "Section", # Configuration section
1075
+ "MultiUploadResult", # S3 upload result
1076
+ "SizeSuffix", # Size with suffix
1077
+ # Utilities
1078
+ "configure_logging", # Logging configuration
1079
+ "log", # Logging utilities
1080
+ "HttpServer", # HTTP server
1081
+ "Range", # HTTP range
1082
+ "HttpFetcher", # HTTP fetcher
1083
+ "PartInfo", # Part information for uploads
1084
+ ]
956
1085
  ```
957
1086
 
958
1087
 
@@ -13,7 +13,7 @@ rclone_api/file_item.py,sha256=cH-AQYsxedhNPp4c8NHY1ad4Z7St4yf_VGbmiGD59no,1770
13
13
  rclone_api/file_part.py,sha256=i6ByS5_sae8Eba-4imBVTxd-xKC8ExWy7NR8QGr0ors,6155
14
14
  rclone_api/file_stream.py,sha256=_W3qnwCuigqA0hzXl2q5pAxSZDRaUSwet4BkT0lpnzs,1431
15
15
  rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
16
- rclone_api/fs.py,sha256=17sBC6WMBrZ-daoVs-9fZMr7xjnw3TnyjXTxS5SPBv8,6269
16
+ rclone_api/fs.py,sha256=1hdRw-7NQnWJSmq6U2d9p2S9UNcND3cJIlDIFfyhQ1o,6898
17
17
  rclone_api/group_files.py,sha256=H92xPW9lQnbNw5KbtZCl00bD6iRh9yRbCuxku4j_3dg,8036
18
18
  rclone_api/http_server.py,sha256=ZdL-rGaq0zIjcaIiRIbPBQ4OIWZ7dCu71aq0nRlKtY4,11686
19
19
  rclone_api/install.py,sha256=Xb1BRn8rQcSpSd4dzmvIOELP2zM2DytUeIZ6jzv738A,2893
@@ -54,9 +54,9 @@ rclone_api/s3/multipart/upload_parts_inline.py,sha256=V7syKjFyVIe4U9Ahl5XgqVTzt9
54
54
  rclone_api/s3/multipart/upload_parts_resumable.py,sha256=6-nlMclS8jyVvMvFbQDcZOX9MY1WbCcKA_s9bwuYxnk,9793
55
55
  rclone_api/s3/multipart/upload_parts_server_side_merge.py,sha256=Fp2pdrs5dONQI9LkfNolgAGj1-Z2V1SsRd0r0sreuXI,18040
56
56
  rclone_api/s3/multipart/upload_state.py,sha256=f-Aq2NqtAaMUMhYitlICSNIxCKurWAl2gDEUVizLIqw,6019
57
- rclone_api-1.5.20.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
58
- rclone_api-1.5.20.dist-info/METADATA,sha256=Y9h8Sh3rUSD4vDUIFG_itPAM7hw6SPfKhug8loC0D98,32696
59
- rclone_api-1.5.20.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
60
- rclone_api-1.5.20.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
61
- rclone_api-1.5.20.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
62
- rclone_api-1.5.20.dist-info/RECORD,,
57
+ rclone_api-1.5.22.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
58
+ rclone_api-1.5.22.dist-info/METADATA,sha256=9bBj235dgclFZikP1fwFFsVKrKz2yYqczJlBJoA4H-o,37155
59
+ rclone_api-1.5.22.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
60
+ rclone_api-1.5.22.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
61
+ rclone_api-1.5.22.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
62
+ rclone_api-1.5.22.dist-info/RECORD,,