Skip to content

Commit

Permalink
Support output_dir override #170
Browse files Browse the repository at this point in the history
  • Loading branch information
GMerakis authored Jun 12, 2022
1 parent 217bdfb commit a761cc6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions dcm2bids/scaffold/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import shutil
import importlib.resources as resources
from typing import Optional
from ..utils import write_txt


Expand Down Expand Up @@ -34,27 +35,28 @@ def _get_arguments():
return args


def scaffold():
def scaffold(output_dir_override: Optional[str] = None):
"""scaffold entry point"""
args = _get_arguments()
output_dir_ = output_dir_override if output_dir_override is not None else args.output_dir

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

for _ in [
"dataset_description.json",
"participants.json",
"participants.tsv",
"README",
]:
dest = os.path.join(args.output_dir, _)
dest = os.path.join(output_dir_, _)
with resources.path(__name__, _) as src:
shutil.copyfile(src, dest)

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

0 comments on commit a761cc6

Please sign in to comment.