Skip to content

Commit

Permalink
Add _check_top_level_folder option. (#381)
Browse files Browse the repository at this point in the history
* Add _check_top_level_folder option.

* Add double backticks in docstring.

Co-authored-by: Niko Sirmpilatze <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Niko Sirmpilatze <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 2, 2024
1 parent 3746b4f commit 69f8a84
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions datashuttle/datashuttle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
)

0 comments on commit 69f8a84

Please sign in to comment.