|
7 | 7 | import os
|
8 | 8 | import shutil
|
9 | 9 | import importlib.resources as resources
|
| 10 | +from typing import Optional |
10 | 11 | from ..utils import write_txt
|
11 | 12 |
|
12 | 13 |
|
@@ -34,27 +35,28 @@ def _get_arguments():
|
34 | 35 | return args
|
35 | 36 |
|
36 | 37 |
|
37 |
| -def scaffold(): |
| 38 | +def scaffold(output_dir_override: Optional[str] = None): |
38 | 39 | """scaffold entry point"""
|
39 | 40 | args = _get_arguments()
|
| 41 | + output_dir_ = output_dir_override if output_dir_override is not None else args.output_dir |
40 | 42 |
|
41 | 43 | 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) |
43 | 45 |
|
44 | 46 | for _ in [
|
45 | 47 | "dataset_description.json",
|
46 | 48 | "participants.json",
|
47 | 49 | "participants.tsv",
|
48 | 50 | "README",
|
49 | 51 | ]:
|
50 |
| - dest = os.path.join(args.output_dir, _) |
| 52 | + dest = os.path.join(output_dir_, _) |
51 | 53 | with resources.path(__name__, _) as src:
|
52 | 54 | shutil.copyfile(src, dest)
|
53 | 55 |
|
54 | 56 | with resources.path(__name__, "CHANGES") as changes_template:
|
55 | 57 | with open(changes_template) as _:
|
56 | 58 | data = _.read().format(datetime.date.today().strftime("%Y-%m-%d"))
|
57 | 59 | write_txt(
|
58 |
| - os.path.join(args.output_dir, "CHANGES"), |
| 60 | + os.path.join(output_dir_, "CHANGES"), |
59 | 61 | data.split("\n")[:-1],
|
60 | 62 | )
|
0 commit comments