Commit ab6a567b authored by Paul McCarthy's avatar Paul McCarthy 🚵
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 464f18d8
...@@ -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 as fslimage import 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,, dest), 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,
for src in srcs:
return return
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment