Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
bbd81728
Commit
bbd81728
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: If outprefix is set to LOAD, all outputs are loaded.
parent
6d16a2a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/wrappers/wrapperutils.py
+28
-9
28 additions, 9 deletions
fsl/wrappers/wrapperutils.py
with
28 additions
and
9 deletions
fsl/wrappers/wrapperutils.py
+
28
−
9
View file @
bbd81728
...
...
@@ -90,6 +90,8 @@ import os
import
sys
import
glob
import
shutil
import
random
import
string
import
fnmatch
import
inspect
import
logging
...
...
@@ -616,14 +618,16 @@ class _FileOrThing(object):
for
filename
in
allPrefixed
:
basename
=
op
.
basename
(
filename
)
for
pref
ix
in
prefixes
:
if
fnmatch
.
fnmatch
(
basename
,
'
{}*
'
.
format
(
pref
ix
)):
for
pref
Pat
,
prefName
in
prefixes
.
items
()
:
if
fnmatch
.
fnmatch
(
basename
,
'
{}*
'
.
format
(
pref
Pat
)):
log
.
debug
(
'
Loading prefixed output %s: %s
'
,
pref
ix
,
filename
)
log
.
debug
(
'
Loading prefixed output %s
[%s]
: %s
'
,
pref
Pat
,
prefName
,
filename
)
fval
=
self
.
__load
(
filename
)
basename
=
self
.
__removeExt
(
basename
)
basename
=
basename
.
replace
(
prefPat
,
prefName
)
result
[
basename
]
=
fval
break
...
...
@@ -669,15 +673,15 @@ class _FileOrThing(object):
- A dictionary of ``{ name : filename }`` mappings,
for all arguments with a value of ``LOAD``.
- A
list
``
[
file
name ]
`` paths, for
all
output-prefix arguments with a value of ``LOAD``.
- A
dictionary
``
{
file
pat : replstr }
`` paths, for
all
output-prefix arguments with a value of ``LOAD``.
"""
# These containers keep track
# of output files which are to
# be loaded into memory
outfiles
=
dict
()
prefixedFiles
=
[]
prefixedFiles
=
dict
()
allargs
=
{
k
:
v
for
k
,
v
in
zip
(
argnames
,
args
)}
allargs
.
update
(
kwargs
)
...
...
@@ -696,9 +700,23 @@ class _FileOrThing(object):
# accept an output prefix which contains
# a directory path.
if
prefix
is
not
None
:
# If prefix is set to LOAD,
# all generated output files
# should be loaded - we use a
# randomly generated prefix,
# and add it to prefixedFiles,
# so that every file which
# starts with it will be
# loaded.
if
prefix
is
LOAD
:
prefix
=
random
.
sample
(
string
.
ascii_letters
,
10
)
prefix
=
''
.
join
(
prefix
)
realPrefix
=
prefix
prefix
=
op
.
basename
(
prefix
)
allargs
[
self
.
__outprefix
]
=
op
.
join
(
workdir
,
prefix
)
prefixedFiles
[
prefix
]
=
self
.
__outprefix
if
len
(
self
.
__things
)
>
0
:
things
=
self
.
__things
else
:
things
=
allargs
.
keys
()
...
...
@@ -717,7 +735,8 @@ class _FileOrThing(object):
# be given a value of LOAD
if
isprefixed
and
val
is
not
LOAD
:
raise
ValueError
(
'
Cannot specify name of prefixed file - the
'
'
name is defined by the output prefix
'
)
'
name is defined by the output prefix:
'
'
{}
'
.
format
(
name
))
if
val
is
LOAD
:
...
...
@@ -728,7 +747,7 @@ class _FileOrThing(object):
# function. So we don't pass it
# through.
if
isprefixed
:
prefixedFiles
.
append
(
name
)
prefixedFiles
[
name
]
=
name
allargs
.
pop
(
name
)
# regular output-file argument
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment