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
6bd0d7c2
Commit
6bd0d7c2
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH,RF: Support for optional variables - a value of None is used for matches
for which an optional variable is not present
parent
689f5fc3
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/utils/filetree/query.py
+8
-9
8 additions, 9 deletions
fsl/utils/filetree/query.py
with
8 additions
and
9 deletions
fsl/utils/filetree/query.py
+
8
−
9
View file @
6bd0d7c2
...
@@ -103,9 +103,6 @@ class FileTreeQuery(object):
...
@@ -103,9 +103,6 @@ class FileTreeQuery(object):
idx
=
[]
idx
=
[]
for
var
in
snvars
:
for
var
in
snvars
:
# TODO handle optional variables. Need
# an extra element on each axis which
# represents a missing value
val
=
match
.
variables
[
var
]
val
=
match
.
variables
[
var
]
idx
.
append
(
snvaridxs
[
var
][
val
])
idx
.
append
(
snvaridxs
[
var
][
val
])
...
@@ -194,10 +191,7 @@ def scan(tree):
...
@@ -194,10 +191,7 @@ def scan(tree):
if
not
op
.
isfile
(
filename
):
if
not
op
.
isfile
(
filename
):
continue
continue
variables
=
tree
.
extract_variables
(
template
,
filename
)
variables
=
dict
(
tree
.
extract_variables
(
template
,
filename
))
variables
=
{
var
:
val
for
var
,
val
in
variables
.
items
()
if
val
is
not
None
}
matches
.
append
(
Match
(
filename
,
template
,
variables
))
matches
.
append
(
Match
(
filename
,
template
,
variables
))
...
@@ -232,7 +226,12 @@ def allVariables(tree, matches) -> Tuple[Dict[str, List], Dict[str, List]]:
...
@@ -232,7 +226,12 @@ def allVariables(tree, matches) -> Tuple[Dict[str, List], Dict[str, List]]:
allvars
[
var
]
.
add
(
val
)
allvars
[
var
]
.
add
(
val
)
allshortnames
[
m
.
short_name
].
add
(
var
)
allshortnames
[
m
.
short_name
].
add
(
var
)
allvars
=
{
var
:
list
(
sorted
(
vals
))
# allow us to compare None with strings
def
key
(
v
):
if
v
is
None
:
return
''
else
:
return
v
allvars
=
{
var
:
list
(
sorted
(
vals
,
key
=
key
))
for
var
,
vals
in
allvars
.
items
()}
for
var
,
vals
in
allvars
.
items
()}
allshortnames
=
{
sn
:
list
(
sorted
(
vars
))
allshortnames
=
{
sn
:
list
(
sorted
(
vars
))
for
sn
,
vars
in
allshortnames
.
items
()}
for
sn
,
vars
in
allshortnames
.
items
()}
...
@@ -261,7 +260,7 @@ class Match(object):
...
@@ -261,7 +260,7 @@ class Match(object):
def
__repr__
(
self
):
def
__repr__
(
self
):
"""
Returns a string representation of this ``Match``.
"""
"""
Returns a string representation of this ``Match``.
"""
return
'
Match({})
'
.
format
(
self
.
filename
)
return
'
Match({})
{}
'
.
format
(
self
.
filename
,
self
.
variables
)
def
__str__
(
self
):
def
__str__
(
self
):
...
...
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