From 0f0db4d9023fa396c5d6c2d014a9194b86106aaa Mon Sep 17 00:00:00 2001 From: JoeZiminski Date: Mon, 29 Apr 2024 22:04:44 +0100 Subject: [PATCH 1/3] Add _check_top_level_folder option. --- datashuttle/datashuttle.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/datashuttle/datashuttle.py b/datashuttle/datashuttle.py index c8213f03..8db4a3e3 100644 --- a/datashuttle/datashuttle.py +++ b/datashuttle/datashuttle.py @@ -213,6 +213,7 @@ def create_folders( ["ephys", "behav"]) """ self._start_log("create-folders", local_vars=locals()) + self._check_top_level_folder(top_level_folder) utils.log("\nFormatting Names...") ds_logger.log_names(["sub_names", "ses_names"], [sub_names, ses_names]) @@ -353,6 +354,8 @@ def upload_custom( if init_log: self._start_log("upload-custom", local_vars=locals()) + self._check_top_level_folder(top_level_folder) + TransferData( self.cfg, "upload", @@ -424,6 +427,8 @@ def download_custom( if init_log: self._start_log("download-custom", local_vars=locals()) + self._check_top_level_folder(top_level_folder) + TransferData( self.cfg, "download", @@ -1451,3 +1456,16 @@ def _update_settings_with_new_canonical_keys(self, settings: Dict): for key in ["overwrite_existing_files", "dry_run"]: if key not in settings["tui"]: settings["tui"][key] = canonical_tui_configs["tui"][key] + + def _check_top_level_folder(self, top_level_folder): + """ + Raise an error if `top_level_folder` not correct. + """ + canonical_top_level_folders = canonical_folders.get_top_level_folders() + + if top_level_folder not in canonical_top_level_folders: + utils.log_and_raise_error( + f"`top_level_folder` must be one of " + f"{canonical_top_level_folders}", + ValueError, + ) From d886646e048cd8cb888e52fe75a612c30ae52240 Mon Sep 17 00:00:00 2001 From: Joe Ziminski <55797454+JoeZiminski@users.noreply.github.com> Date: Thu, 2 May 2024 15:44:58 +0100 Subject: [PATCH 2/3] Add double backticks in docstring. Co-authored-by: Niko Sirmpilatze --- datashuttle/datashuttle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datashuttle/datashuttle.py b/datashuttle/datashuttle.py index 8db4a3e3..2800c93a 100644 --- a/datashuttle/datashuttle.py +++ b/datashuttle/datashuttle.py @@ -1459,7 +1459,7 @@ def _update_settings_with_new_canonical_keys(self, settings: Dict): def _check_top_level_folder(self, top_level_folder): """ - Raise an error if `top_level_folder` not correct. +Raise an error if ``top_level_folder`` not correct. """ canonical_top_level_folders = canonical_folders.get_top_level_folders() From b7df5e53cf09f0875c9e9a20b1cfc3e89dea2ab6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 14:46:18 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- datashuttle/datashuttle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datashuttle/datashuttle.py b/datashuttle/datashuttle.py index 2800c93a..8ce229e1 100644 --- a/datashuttle/datashuttle.py +++ b/datashuttle/datashuttle.py @@ -1459,7 +1459,7 @@ def _update_settings_with_new_canonical_keys(self, settings: Dict): def _check_top_level_folder(self, top_level_folder): """ -Raise an error if ``top_level_folder`` not correct. + Raise an error if ``top_level_folder`` not correct. """ canonical_top_level_folders = canonical_folders.get_top_level_folders()