Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Evan Edmond
fslpy
Commits
07bec037
Commit
07bec037
authored
Nov 17, 2016
by
Paul McCarthy
Browse files
Paths passed to removeDuplicates must exist. Immv/cp scripts raise error
when called programmatically.
parent
02629feb
Changes
3
Show whitespace changes
Inline
Side-by-side
fsl/scripts/imcp.py
View file @
07bec037
...
...
@@ -58,13 +58,13 @@ def main(argv=None):
fileGroups
=
fslimage
.
FILE_GROUPS
)
for
src
in
srcs
:
try
:
imcp
.
imcp
(
src
,
dest
,
useDefaultExt
=
True
)
except
Exception
as
e
:
print
(
e
)
break
if
__name__
==
'__main__'
:
try
:
main
()
except
Exception
as
e
:
print
(
e
)
sys
.
exit
(
1
)
fsl/scripts/immv.py
View file @
07bec037
...
...
@@ -59,13 +59,12 @@ def main(argv=None):
fileGroups
=
fslimage
.
FILE_GROUPS
)
for
src
in
srcs
:
try
:
imcp
.
immv
(
src
,
dest
,
useDefaultExt
=
True
)
except
Exception
as
e
:
print
(
e
)
break
if
__name__
==
'__main__'
:
try
:
main
()
except
Exception
as
e
:
print
(
e
)
sys
.
exit
(
1
)
fsl/utils/path.py
View file @
07bec037
...
...
@@ -246,7 +246,10 @@ def removeDuplicates(paths, allowedExts=None, fileGroups=None):
['001.img', '002.img', '003.img']
:arg paths: List of paths to reduce.
A :exc:`PathError` is raised if any of the paths do not exist.
:arg paths: List of paths to reduce. If ``allowedExts`` is not
``None``, may be incomplete.
:arg allowedExts: Allowed/recognised file extensions.
...
...
@@ -257,11 +260,20 @@ def removeDuplicates(paths, allowedExts=None, fileGroups=None):
for
path
in
paths
:
path
=
addExt
(
path
,
mustExist
=
True
,
allowedExts
=
allowedExts
,
fileGroups
=
fileGroups
)
groupFiles
=
getFileGroup
(
path
,
allowedExts
,
fileGroups
)
if
not
any
([
g
in
unique
for
g
in
groupFiles
]):
if
len
(
groupFiles
)
==
0
:
if
path
not
in
unique
:
unique
.
append
(
path
)
elif
not
any
([
p
in
unique
for
p
in
groupFiles
]):
unique
.
append
(
groupFiles
[
0
])
return
unique
...
...
@@ -320,7 +332,7 @@ def getFileGroup(path, allowedExts=None, fileGroups=None, fullPaths=True):
for
group
in
fileGroups
:
if
ext
not
in
group
:
if
ext
!=
''
and
ext
not
in
group
:
continue
groupFiles
=
[
base
+
s
for
s
in
group
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment