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
87844728
Commit
87844728
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: BIDSFile.match option to disable suffix match
parent
cbf70da9
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/bids.py
+22
-7
22 additions, 7 deletions
fsl/utils/bids.py
with
22 additions
and
7 deletions
fsl/utils/bids.py
+
22
−
7
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
...
...
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