Skip to content

Commit ee88875

Browse files
author
shrey
committed
add: docstrings to rclone function, change arugment order
1 parent 91f2454 commit ee88875

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

datashuttle/datashuttle_class.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,8 @@ def _setup_rclone_gdrive_config(
15701570
) -> None:
15711571
rclone.setup_rclone_config_for_gdrive(
15721572
self.cfg,
1573-
gdrive_client_secret,
15741573
self.cfg.get_rclone_config_name("gdrive"),
1574+
gdrive_client_secret,
15751575
config_token,
15761576
log=log,
15771577
)
@@ -1581,8 +1581,8 @@ def _setup_rclone_aws_config(
15811581
) -> None:
15821582
rclone.setup_rclone_config_for_aws(
15831583
self.cfg,
1584-
aws_secret_access_key,
15851584
self.cfg.get_rclone_config_name("aws"),
1585+
aws_secret_access_key,
15861586
log=log,
15871587
)
15881588

datashuttle/utils/rclone.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,34 @@ def setup_rclone_config_for_ssh(
158158

159159
def setup_rclone_config_for_gdrive(
160160
cfg: Configs,
161-
gdrive_client_secret: str | None,
162161
rclone_config_name: str,
162+
gdrive_client_secret: str | None,
163163
config_token: Optional[str] = None,
164164
log: bool = True,
165165
):
166+
"""
167+
Sets up rclone config for connections to Google Drive. This must
168+
contain the `gdrive_root_folder_id` and optionally a `gdrive_client_id`
169+
which also mandates for the presence of a Google Drive client secret.
170+
171+
Parameters
172+
----------
173+
174+
cfg : Configs
175+
datashuttle configs UserDict.
176+
177+
rclone_config_name : rclone config name
178+
canonical config name, generated by
179+
datashuttle.cfg.get_rclone_config_name()
180+
181+
gdrive_client_secret : Google Drive client secret, mandatory when
182+
using a Google Drive client.
183+
184+
config_token : a token to setup rclone config without opening a browser,
185+
needed if the user's machine doesn't have access to a browser.
186+
187+
log : whether to log, if True logger must already be initialised.
188+
"""
166189
client_id_key_value = (
167190
f"client_id {cfg['gdrive_client_id']} "
168191
if cfg["gdrive_client_id"]
@@ -202,10 +225,28 @@ def setup_rclone_config_for_gdrive(
202225

203226
def setup_rclone_config_for_aws(
204227
cfg: Configs,
205-
aws_secret_access_key: str,
206228
rclone_config_name: str,
229+
aws_secret_access_key: str,
207230
log: bool = True,
208231
):
232+
"""
233+
Sets up rclone config for connections to AWS S3 buckets. This must
234+
contain the `aws_access_key_id` and `aws_region`.
235+
236+
Parameters
237+
----------
238+
239+
cfg : Configs
240+
datashuttle configs UserDict.
241+
242+
rclone_config_name : rclone config name
243+
canonical config name, generated by
244+
datashuttle.cfg.get_rclone_config_name()
245+
246+
aws_secret_access_key : the aws secret access key provided by the user.
247+
248+
log : whether to log, if True logger must already be initialised.
249+
"""
209250
output = call_rclone(
210251
"config create "
211252
f"{rclone_config_name} "

0 commit comments

Comments
 (0)