Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 6fec9b7edb08fd9989088709d864a7826dc74e80 # frozen: v0.15.12
rev: 39d9ac5938dadb73df0564a45f163e25ff9fa6e2 # frozen: v0.16.1
hooks:
- id: ruff-check
args: [ --fix, --show-fixes ]
Expand Down
29 changes: 16 additions & 13 deletions wrapper/src/fmriprep_docker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ def _get_posargs(usage):
line = targ.lstrip()
if line.startswith('usage'):
continue
if line[0].isalnum() or line[0] == '{':
posargs.append(line)
elif line[0] == '[' and (line[1].isalnum() or line[1] == '{'):
if (
line[0].isalnum()
or line[0] == '{'
or line[0] == '['
and (line[1].isalnum() or line[1] == '{')
):
posargs.append(line)
return ' '.join(posargs)

Expand Down Expand Up @@ -291,7 +294,7 @@ def _is_file(path, parser):
'--image',
metavar='IMG',
type=str,
default='nipreps/fmriprep:{}'.format(__version__),
default=f'nipreps/fmriprep:{__version__}',
help='image name',
)

Expand Down Expand Up @@ -418,7 +421,7 @@ def main():
check = check_docker()
if check < 1:
if opts.version:
print('fmriprep wrapper {!s}'.format(__version__))
print(f'fmriprep wrapper {__version__!s}')
if opts.help:
parser.print_help()
if check == -1:
Expand All @@ -431,7 +434,7 @@ def main():
if not check_image(opts.image):
resp = 'Y'
if opts.version:
print('fmriprep wrapper {!s}'.format(__version__))
print(f'fmriprep wrapper {__version__!s}')
if opts.help:
parser.print_help()
if opts.version or opts.help:
Expand Down Expand Up @@ -484,7 +487,7 @@ def main():
# Patch working repositories into installed package directories
if opts.patch:
for pkg, repo_path in opts.patch.items():
command.extend(['-v', '{}:{}/{}:ro'.format(repo_path, PKG_PATH, pkg)])
command.extend(['-v', f'{repo_path}:{PKG_PATH}/{pkg}:ro'])

if opts.env:
for envvar in opts.env:
Expand All @@ -494,7 +497,7 @@ def main():
command.extend(['-u', opts.user])

if opts.fs_license_file:
command.extend(['-v', '{}:/opt/freesurfer/license.txt:ro'.format(opts.fs_license_file)])
command.extend(['-v', f'{opts.fs_license_file}:/opt/freesurfer/license.txt:ro'])

main_args = []
if opts.bids_dir:
Expand All @@ -509,19 +512,19 @@ def main():
main_args.append(opts.analysis_level)

if opts.fs_subjects_dir:
command.extend(['-v', '{}:/opt/subjects'.format(opts.fs_subjects_dir)])
command.extend(['-v', f'{opts.fs_subjects_dir}:/opt/subjects'])
unknown_args.extend(['--fs-subjects-dir', '/opt/subjects'])

if opts.config_file:
command.extend(['-v', '{}:/tmp/config.toml'.format(opts.config_file)])
command.extend(['-v', f'{opts.config_file}:/tmp/config.toml'])
unknown_args.extend(['--config-file', '/tmp/config.toml'])

# Patch derivatives for searching
if opts.derivatives:
unknown_args.append('--derivatives')
for deriv, deriv_path in opts.derivatives.items():
command.extend(['-v', '{}:/deriv/{}:ro'.format(deriv_path, deriv)])
unknown_args.append('/deriv/{}'.format(deriv))
command.extend(['-v', f'{deriv_path}:/deriv/{deriv}:ro'])
unknown_args.append(f'/deriv/{deriv}')

if opts.work_dir:
command.extend(['-v', ':'.join((opts.work_dir, '/scratch'))])
Expand Down Expand Up @@ -593,7 +596,7 @@ def main():
print('RUNNING: ' + ' '.join(command))
ret = subprocess.run(command)
if ret.returncode:
print('fMRIPrep: Please report errors to {}'.format(__bugreports__))
print(f'fMRIPrep: Please report errors to {__bugreports__}')
return ret.returncode


Expand Down
Loading