Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
4e4189de
Commit
4e4189de
authored
6 years ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
BUG: don't allow variable to span more than one directory or file name
parent
edfafa71
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/utils/filetree/utils.py
+2
-0
2 additions, 0 deletions
fsl/utils/filetree/utils.py
tests/test_filetree/test_template.py
+4
-0
4 additions, 0 deletions
tests/test_filetree/test_template.py
with
6 additions
and
0 deletions
fsl/utils/filetree/utils.py
+
2
−
0
View file @
4e4189de
...
...
@@ -170,6 +170,8 @@ def extract_variables(template, filename, known_vars=None):
raise
ValueError
(
'
Multiple values found for {}
'
.
format
(
var
))
else
:
extracted_value
[
var
]
=
value
if
any
(
'
/
'
in
value
for
value
in
extracted_value
.
values
()):
continue
for
name
in
find_variables
(
template
):
if
name
not
in
extracted_value
:
extracted_value
[
name
]
=
None
...
...
This diff is collapsed.
Click to expand it.
tests/test_filetree/test_template.py
+
4
−
0
View file @
4e4189de
...
...
@@ -21,3 +21,7 @@ def test_get_variables():
utils
.
extract_variables
(
'
{var}[_{other_var}]_{var}
'
,
'
test_foo_bar
'
)
with
pytest
.
raises
(
ValueError
):
utils
.
extract_variables
(
'
bar{var}[_{other_var}]_{var}
'
,
'
test
'
)
assert
{
'
subject
'
:
'
01
'
,
'
session
'
:
'
A
'
}
==
utils
.
extract_variables
(
'
sub-{subject}/[ses-{session}]/T1w.nii.gz
'
,
'
sub-01/ses-A/T1w.nii.gz
'
)
with
pytest
.
raises
(
ValueError
):
utils
.
extract_variables
(
'
sub-{subject}/[ses-{session}]/T1w.nii.gz
'
,
'
sub-01/other/T1w.nii.gz
'
)
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