rclone-api 1.5.17__py3-none-any.whl → 1.5.18__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/filesystem.py CHANGED
@@ -2,6 +2,8 @@ import abc
2
2
  import shutil
3
3
  from pathlib import Path
4
4
 
5
+ from rclone_api.config import Config
6
+
5
7
 
6
8
  class FileSystem(abc.ABC):
7
9
  def __init__(self) -> None:
@@ -31,6 +33,10 @@ class FileSystem(abc.ABC):
31
33
  def ls(self, path: Path | str) -> list[str]:
32
34
  pass
33
35
 
36
+ @abc.abstractmethod
37
+ def cwd(self) -> "FSPath":
38
+ pass
39
+
34
40
  @abc.abstractmethod
35
41
  def get_path(self, path: str) -> "FSPath":
36
42
  pass
@@ -45,12 +51,12 @@ class FileSystem(abc.ABC):
45
51
  self.write_binary(path, utf)
46
52
 
47
53
 
48
- class RealFileSystem(FileSystem):
54
+ class RealFS(FileSystem):
49
55
 
50
56
  @staticmethod
51
- def get_real_path(path: Path | str) -> "FSPath":
57
+ def from_path(path: Path | str) -> "FSPath":
52
58
  path_str = Path(path).as_posix()
53
- return FSPath(RealFileSystem(), path_str)
59
+ return FSPath(RealFS(), path_str)
54
60
 
55
61
  def __init__(self) -> None:
56
62
  super().__init__()
@@ -58,6 +64,9 @@ class RealFileSystem(FileSystem):
58
64
  def ls(self, path: Path | str) -> list[str]:
59
65
  return [str(p) for p in Path(path).iterdir()]
60
66
 
67
+ def cwd(self) -> "FSPath":
68
+ return RealFS.from_path(Path.cwd())
69
+
61
70
  def copy(self, src: Path | str, dest: Path | str) -> None:
62
71
  shutil.copy(str(src), str(dest))
63
72
 
@@ -79,8 +88,8 @@ class RealFileSystem(FileSystem):
79
88
  return FSPath(self, path)
80
89
 
81
90
 
82
- class RemoteFileSystem(FileSystem):
83
- def __init__(self, rclone_conf: Path, src: str) -> None:
91
+ class RemoteFS(FileSystem):
92
+ def __init__(self, rclone_conf: Path | Config, src: str) -> None:
84
93
  from rclone_api import HttpServer, Rclone
85
94
 
86
95
  super().__init__()
@@ -89,6 +98,12 @@ class RemoteFileSystem(FileSystem):
89
98
  self.server: HttpServer = self.rclone.serve_http(src=src)
90
99
  self.shutdown = False
91
100
 
101
+ def root(self) -> "FSPath":
102
+ return FSPath(self, "")
103
+
104
+ def cwd(self) -> "FSPath":
105
+ return self.root()
106
+
92
107
  def _to_str(self, path: Path | str) -> str:
93
108
  if isinstance(path, Path):
94
109
  return path.as_posix()
@@ -115,7 +130,7 @@ class RemoteFileSystem(FileSystem):
115
130
  return self.server.exists(path)
116
131
 
117
132
  def mkdir(self, path: str, parents=True, exist_ok=True) -> None:
118
- raise NotImplementedError("RemoteFileSystem does not support mkdir")
133
+ raise NotImplementedError("RemoteFS does not support mkdir")
119
134
 
120
135
  def is_dir(self, path: Path | str) -> bool:
121
136
  path = self._to_str(path)
@@ -176,8 +191,8 @@ class FSPath:
176
191
 
177
192
  def rmtree(self, ignore_errors=False) -> None:
178
193
  assert self.exists(), f"Path does not exist: {self.path}"
179
- # check fs is RealFileSystem
180
- assert isinstance(self.fs, RealFileSystem)
194
+ # check fs is RealFS
195
+ assert isinstance(self.fs, RealFS)
181
196
  shutil.rmtree(self.path, ignore_errors=ignore_errors)
182
197
 
183
198
  def ls(self) -> "list[FSPath]":
rclone_api/rclone_impl.py CHANGED
@@ -26,6 +26,7 @@ from rclone_api.dir_listing import DirListing
26
26
  from rclone_api.exec import RcloneExec
27
27
  from rclone_api.file import File
28
28
  from rclone_api.file_stream import FilesStream
29
+ from rclone_api.filesystem import RemoteFS
29
30
  from rclone_api.group_files import group_files
30
31
  from rclone_api.http_server import HttpServer
31
32
  from rclone_api.mount import Mount
@@ -103,6 +104,9 @@ class RcloneImpl:
103
104
  cmd += other_args
104
105
  return self._launch_process(cmd, capture=False)
105
106
 
107
+ def filesystem(self, src: str) -> RemoteFS:
108
+ return RemoteFS(self.config, src)
109
+
106
110
  def launch_server(
107
111
  self,
108
112
  addr: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rclone_api
3
- Version: 1.5.17
3
+ Version: 1.5.18
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -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/filesystem.py,sha256=QPERBMxrTWNaWMxuHu5QnbRLF5eoSYDODNpjhD8K694,6008
16
+ rclone_api/filesystem.py,sha256=htF2dF6v-tkiqyTj4BnDm3Ctn5seXZ2tiUFjSrMLOq8,6272
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
@@ -21,7 +21,7 @@ rclone_api/log.py,sha256=VZHM7pNSXip2ZLBKMP7M1u-rp_F7zoafFDuR8CPUoKI,1271
21
21
  rclone_api/mount.py,sha256=LZqEhuKZunbWVqmsOIqkkCotaxWJpdFRS1InXveoU5E,1428
22
22
  rclone_api/mount_util.py,sha256=jqhJEVTHV6c6lOOzUYb4FLMbqDMHdz7-QRcdH-IobFc,10154
23
23
  rclone_api/process.py,sha256=MeWiN-TrrN0HmtWexBPxGwf84z6f-_E5yaXE-YtLYpY,5879
24
- rclone_api/rclone_impl.py,sha256=STHQ_hT0chyp2yj3Cp-Vd0xXc1Pdpo3p9J3bTQEm0XE,46531
24
+ rclone_api/rclone_impl.py,sha256=qIvd9qcKsdD7l9_d3Thy5nJUD9xX4MAlOMekWb1NPhg,46665
25
25
  rclone_api/remote.py,sha256=mTgMTQTwxUmbLjTpr-AGTId2ycXKI9mLX5L7PPpDIoc,520
26
26
  rclone_api/rpath.py,sha256=Y1JjQWcie39EgQrq-UtbfDz5yDLCwwfu27W7AQXllSE,2860
27
27
  rclone_api/scan_missing_folders.py,sha256=-8NCwpCaHeHrX-IepCoAEsX1rl8S-GOCxcIhTr_w3gA,4747
@@ -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.17.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
58
- rclone_api-1.5.17.dist-info/METADATA,sha256=BkNxUxGH2-ZTFkBL2vfpCEf03jm8IVizA0uuzDh6gDQ,32696
59
- rclone_api-1.5.17.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
60
- rclone_api-1.5.17.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
61
- rclone_api-1.5.17.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
62
- rclone_api-1.5.17.dist-info/RECORD,,
57
+ rclone_api-1.5.18.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
58
+ rclone_api-1.5.18.dist-info/METADATA,sha256=u0TSArQPF3xtUyFdUbZ84vfgNoaZxv3Bx-RklZlvi9g,32696
59
+ rclone_api-1.5.18.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
60
+ rclone_api-1.5.18.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
61
+ rclone_api-1.5.18.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
62
+ rclone_api-1.5.18.dist-info/RECORD,,