Skip to content

Commit 5ca2e72

Browse files
authored
Make logging optional in 'create_folders', improve docstring. (#379)
1 parent 617ab13 commit 5ca2e72

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

datashuttle/datashuttle.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def create_folders(
148148
ses_names: Optional[Union[str, List[str]]] = None,
149149
datatype: Union[str, List[str]] = "",
150150
bypass_validation: bool = False,
151+
log: bool = True,
151152
) -> List[Path]:
152153
"""
153154
Create a subject / session folder tree in the project
@@ -160,31 +161,36 @@ def create_folders(
160161
Parameters
161162
----------
162163
163-
sub_names :
164+
top_level_folder : TopLevelFolder
165+
Whether to make the folders in `rawdata` or
166+
`derivatives`.
167+
168+
sub_names : Union[str, List[str]]
164169
subject name / list of subject names to make
165170
within the top-level project folder
166171
(if not already, these will be prefixed with
167172
"sub-")
168-
ses_names :
173+
174+
ses_names : Optional[Union[str, List[str]]]
169175
(Optional). session name / list of session names.
170176
(if not already, these will be prefixed with
171177
"ses-"). If no session is provided, no session-level
172178
folders are made.
173-
datatype :
179+
180+
datatype : Union[str, List[str]]
174181
The datatype to make in the sub / ses folders.
175182
(e.g. "ephys", "behav", "anat"). If "all"
176183
is selected, all datatypes permitted in
177184
NeuroBlueprint will be created. If "" is passed
178185
no datatype will be created.
179186
180-
top_level_folder :
181-
Whether to make the folders in `rawdata` or
182-
`derivatives`.
183-
184-
bypass_validation :
187+
bypass_validation : bool
185188
If `True`, folders will be created even if they are not
186189
valid to NeuroBlueprint style.
187190
191+
log : bool
192+
If `True`, details of folder creation will be logged.
193+
188194
Notes
189195
-----
190196
@@ -212,7 +218,9 @@ def create_folders(
212218
["ses-001", "ses-002"],
213219
["ephys", "behav"])
214220
"""
215-
self._start_log("create-folders", local_vars=locals())
221+
if log:
222+
self._start_log("create-folders", local_vars=locals())
223+
216224
self._check_top_level_folder(top_level_folder)
217225

218226
utils.log("\nFormatting Names...")
@@ -244,12 +252,14 @@ def create_folders(
244252
log=True,
245253
)
246254

247-
utils.print_message_to_user(
248-
f"Finished making folders. \nFor log of all created "
249-
f"folders, please see {self.cfg.logging_path}"
250-
)
255+
utils.print_message_to_user("Finished making folders.")
251256

252-
ds_logger.close_log_filehandler()
257+
if log:
258+
utils.print_message_to_user(
259+
f"For log of all created folders, "
260+
f"please see {self.cfg.logging_path}"
261+
)
262+
ds_logger.close_log_filehandler()
253263

254264
return created_paths
255265

0 commit comments

Comments
 (0)