Skip to content

Commit c6fb2ca

Browse files
authored
Merge pull request #171 from GMerakis/patch-1
Thank you @GMerakis for this PR. I think this will be the last PR and release before jumping to dcm2bids 3.0.0 with a cleaner and more flexible API. Support output_dir override #170
2 parents 217bdfb + a761cc6 commit c6fb2ca

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

dcm2bids/scaffold/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import shutil
99
import importlib.resources as resources
10+
from typing import Optional
1011
from ..utils import write_txt
1112

1213

@@ -34,27 +35,28 @@ def _get_arguments():
3435
return args
3536

3637

37-
def scaffold():
38+
def scaffold(output_dir_override: Optional[str] = None):
3839
"""scaffold entry point"""
3940
args = _get_arguments()
41+
output_dir_ = output_dir_override if output_dir_override is not None else args.output_dir
4042

4143
for _ in ["code", "derivatives", "sourcedata"]:
42-
os.makedirs(os.path.join(args.output_dir, _), exist_ok=True)
44+
os.makedirs(os.path.join(output_dir_, _), exist_ok=True)
4345

4446
for _ in [
4547
"dataset_description.json",
4648
"participants.json",
4749
"participants.tsv",
4850
"README",
4951
]:
50-
dest = os.path.join(args.output_dir, _)
52+
dest = os.path.join(output_dir_, _)
5153
with resources.path(__name__, _) as src:
5254
shutil.copyfile(src, dest)
5355

5456
with resources.path(__name__, "CHANGES") as changes_template:
5557
with open(changes_template) as _:
5658
data = _.read().format(datetime.date.today().strftime("%Y-%m-%d"))
5759
write_txt(
58-
os.path.join(args.output_dir, "CHANGES"),
60+
os.path.join(output_dir_, "CHANGES"),
5961
data.split("\n")[:-1],
6062
)

0 commit comments

Comments
 (0)