rclone-api 1.5.29__py3-none-any.whl → 1.5.31__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/__init__.py CHANGED
@@ -210,6 +210,23 @@ class Rclone:
210
210
  """
211
211
  return self.impl.obscure(password=password)
212
212
 
213
+ def config_show(
214
+ self, remote: str | None = None, obscure: bool = False, no_obscure: bool = False
215
+ ) -> list[Path] | Exception:
216
+ """Show the current configuration.
217
+
218
+ Args:
219
+ remote: Optional remote name to show configuration for
220
+ obscure: Show obscured passwords
221
+ no_obscure: Show passwords in plain text
222
+
223
+ Returns:
224
+ Configuration as text or an Exception if an error occurred
225
+ """
226
+ return self.impl.config_paths(
227
+ remote=remote, obscure=obscure, no_obscure=no_obscure
228
+ )
229
+
213
230
  def ls_stream(
214
231
  self,
215
232
  src: str,
rclone_api/config.py CHANGED
@@ -1,6 +1,7 @@
1
+ import os
1
2
  from dataclasses import dataclass, field
2
3
  from pathlib import Path
3
- from typing import Dict, List
4
+ from typing import Any, Dict, List
4
5
 
5
6
 
6
7
  @dataclass
@@ -56,8 +57,9 @@ class Config:
56
57
  return Parsed.parse(self.text)
57
58
 
58
59
 
59
- def find_conf_file() -> Path | None:
60
- import os
60
+ def find_conf_file(rclone: Any | None = None) -> Path | None:
61
+ from rclone_api import Rclone
62
+ from rclone_api.rclone_impl import RcloneImpl
61
63
 
62
64
  # if os.environ.get("RCLONE_CONFIG"):
63
65
  # return Path(os.environ["RCLONE_CONFIG"])
@@ -68,6 +70,21 @@ def find_conf_file() -> Path | None:
68
70
  return Path(os.environ["RCLONE_CONFIG"])
69
71
  if (conf := Path.cwd() / "rclone.conf").exists():
70
72
  return conf
73
+ if rclone is not None:
74
+ if isinstance(rclone, Rclone):
75
+ rclone = rclone.impl
76
+ else:
77
+ assert isinstance(rclone, RcloneImpl)
78
+ rclone_impl: RcloneImpl = rclone
79
+ assert isinstance(rclone_impl, RcloneImpl)
80
+ paths_or_err = rclone_impl.config_paths()
81
+ if isinstance(paths_or_err, Exception):
82
+ return None
83
+ paths = paths_or_err
84
+ path: Path
85
+ for path in paths:
86
+ if path.exists():
87
+ return path
71
88
  return None
72
89
 
73
90