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
edfafa71
Commit
edfafa71
authored
6 years ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
BUG: actually unset variable if set to None
parent
3a1a890a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/utils/filetree/filetree.py
+4
-1
4 additions, 1 deletion
fsl/utils/filetree/filetree.py
tests/test_filetree/test_read.py
+2
-2
2 additions, 2 deletions
tests/test_filetree/test_read.py
with
6 additions
and
3 deletions
fsl/utils/filetree/filetree.py
+
4
−
1
View file @
edfafa71
...
...
@@ -190,11 +190,14 @@ class FileTree(object):
Creates a new FileTree with updated variables
:param variables: new values for the variables
Setting variable
s
to None will
forc
e th
at
variable to be
empty (useful for non-optional variables)
Setting
a
variable to None will
caus
e th
e
variable to be
unset
:return: New FileTree with same templates for directory names and filenames, but updated variables
"""
new_tree
=
deepcopy
(
self
)
new_tree
.
variables
.
update
(
variables
)
for
key
,
value
in
variables
.
items
():
if
value
is
None
:
del
new_tree
.
variables
[
key
]
return
new_tree
def
extract_variables
(
self
,
short_name
:
str
,
filename
:
str
)
->
Dict
[
str
,
str
]:
...
...
This diff is collapsed.
Click to expand it.
tests/test_filetree/test_read.py
+
2
−
2
View file @
edfafa71
...
...
@@ -77,8 +77,8 @@ def test_custom_tree():
assert
len
(
tree
.
get_all
(
'
sub_file
'
,
glob_vars
=
'
all
'
))
==
2
assert
len
(
tree
.
get_all
(
'
sub_file
'
))
==
1
assert
len
(
tree
.
update
(
opt
=
None
).
get_all
(
'
sub_file
'
))
==
1
assert
len
(
tree
.
update
(
opt
=
None
).
get_all
(
'
sub_file
'
,
glob_vars
=
[
'
opt
'
]))
==
1
assert
len
(
tree
.
update
(
opt
=
None
).
get_all
(
'
sub_file
'
,
glob_vars
=
'
all
'
))
==
1
assert
len
(
tree
.
update
(
opt
=
None
).
get_all
(
'
sub_file
'
,
glob_vars
=
[
'
opt
'
]))
==
2
assert
len
(
tree
.
update
(
opt
=
None
).
get_all
(
'
sub_file
'
,
glob_vars
=
'
all
'
))
==
2
for
fn
,
settings
in
zip
(
tree
.
get_all
(
'
sub_file
'
,
glob_vars
=
'
all
'
),
tree
.
get_all_vars
(
'
sub_file
'
,
glob_vars
=
'
all
'
)):
...
...
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