Skip to content

Commit

Permalink
Allow --options to be a file
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Feb 2, 2024
1 parent 7339261 commit f63299d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion print_fetal_brain_atlases_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
}

if __name__ == "__main__":
json.dump(FILENAME_MAPPING, sys.stdout)
json.dump(FILENAME_MAPPING, sys.stdout, indent=2)
2 changes: 1 addition & 1 deletion pubchrisvisual/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
|_|
"""

__version__ = '0.0.1'
__version__ = '0.0.2'
10 changes: 8 additions & 2 deletions pubchrisvisual/one.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
parser.add_argument('--order', type=str,
help='Order of preference for file names as a comma-separated list')
parser.add_argument('--options', type=str, default='{}',
help='Mapping of file names to default Niivue options as stringified JSON')
help='Mapping of file names to default Niivue options. '
'Should either be a relative path or stringified JSON')
parser.add_argument('--readme', type=str,
help='README file content')

Expand All @@ -36,7 +37,7 @@
min_cpu_limit='200m',
)
def main(options: Namespace, inputdir: Path, outputdir: Path):
configs = deserialize_mapping(options.options)
configs = deserialize_mapping(path_or_fname(inputdir, options.options))
order = [name.strip() for name in ','.strip(options.order)]
print(DISPLAY_TITLE, flush=True)
shutil.copytree(inputdir, outputdir, dirs_exist_ok=True)
Expand Down Expand Up @@ -92,5 +93,10 @@ def deserialize_mapping(x: str) -> dict[str, ChrisViewerFileOptions]:
sys.exit(1)


def path_or_fname(parent_dir: Path, value: str):
p = parent_dir / value
return p.read_text() if p.is_file() else value


if __name__ == '__main__':
main()

0 comments on commit f63299d

Please sign in to comment.