Skip to content
Snippets Groups Projects
Commit 05c5cbdf authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Two more fixes to imcp:

  - if moving a file from a group, need to remove the entire group
  - Special test for when dest is a non-existent directory
parent 401facbb
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,8 @@ import os ...@@ -18,6 +18,8 @@ import os
import os.path as op import os.path as op
import shutil import shutil
import nibabel as nib
import fsl.utils.path as fslpath import fsl.utils.path as fslpath
import fsl.data.image as fslimage import fsl.data.image as fslimage
...@@ -53,7 +55,9 @@ def imcp(src, ...@@ -53,7 +55,9 @@ def imcp(src,
copied. See :func:`immv`. copied. See :func:`immv`.
""" """
import nibabel as nib # special case - non-existent directory
if dest.endswith('/') and not op.isdir(dest):
raise fslpath.PathError('Directory does not exist: {}'.format(dest))
if op.isdir(dest): if op.isdir(dest):
dest = op.join(dest, op.basename(src)) dest = op.join(dest, op.basename(src))
...@@ -135,7 +139,13 @@ def imcp(src, ...@@ -135,7 +139,13 @@ def imcp(src,
nib.save(img, dest) nib.save(img, dest)
if move: if move:
os.remove(src) # if input is an image pair, we
# need to remove all input files
srcs = fslpath.getFileGroup(src,
fslimage.ALLOWED_EXTENSIONS,
fslimage.FILE_GROUPS)
for src in srcs:
os.remove(src)
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment