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
Michiel Cottaar
fslpy
Commits
87844728
Commit
87844728
authored
Mar 18, 2020
by
Paul McCarthy
🚵
Browse files
ENH: BIDSFile.match option to disable suffix match
parent
cbf70da9
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/utils/bids.py
View file @
87844728
...
...
@@ -9,6 +9,7 @@
.. autosummary::
:nosignatures:
BIDSFile
isBIDSDir
inBIDSDir
isBIDSFile
...
...
@@ -57,20 +58,34 @@ class BIDSFile(object):
self
.
suffix
=
suffix
def
match
(
self
,
other
):
def
__str__
(
self
):
"""Return a strimg representation of this ``BIDSFile``. """
return
'BIDSFile({})'
.
format
(
self
.
filename
)
def
__repr__
(
self
):
"""Return a strimg representation of this ``BIDSFile``. """
return
str
(
self
)
def
match
(
self
,
other
,
suffix
=
True
):
"""Compare this ``BIDSFile`` to ``other``.
:arg other: ``BIDSFile`` to compare
:returns: ``True`` if ``self.suffix == other.suffix`` and if
all of the entities in ``other`` are present in ``self``,
``False`` otherwise.
:arg other: ``BIDSFile`` to compare
:arg suffix: Defaults to ``True``. If ``False``, the comparison
is made solely on the entity values.
:returns: ``True`` if ``self.suffix == other.suffix`` (unless
``suffix`` is ``False``) and if all of the entities in
``other`` are present in ``self``, ``False`` otherwise.
"""
suffix
=
self
.
suffix
==
other
.
suffix
suffix
=
(
not
suffix
)
or
(
self
.
suffix
==
other
.
suffix
)
entities
=
True
for
key
,
value
in
other
.
entities
.
items
():
entities
=
entities
and
self
.
entities
.
get
(
key
,
None
)
==
value
entities
=
entities
and
(
self
.
entities
.
get
(
key
,
None
)
==
value
)
return
suffix
and
entities
...
...
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