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
5cd934ab
Commit
5cd934ab
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New path function to return all files in ditectory
parent
57ed2024
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/path.py
+17
-1
17 additions, 1 deletion
fsl/utils/path.py
with
17 additions
and
1 deletion
fsl/utils/path.py
+
17
−
1
View file @
5cd934ab
...
...
@@ -13,6 +13,7 @@ paths.
deepest
shallowest
allFiles
hasExt
addExt
removeExt
...
...
@@ -24,8 +25,9 @@ paths.
"""
import
glob
import
os.path
as
op
import
os
import
glob
class
PathError
(
Exception
):
...
...
@@ -78,6 +80,20 @@ def shallowest(path, suffixes):
return
None
def
allFiles
(
root
):
"""
Return a list containing all files which exist underneath the specified
``root`` directory.
"""
files
=
[]
for
dirpath
,
_
,
filenames
in
os
.
walk
(
root
):
filenames
=
[
op
.
join
(
dirpath
,
f
)
for
f
in
filenames
]
files
.
extend
(
filenames
)
return
files
def
hasExt
(
path
,
allowedExts
):
"""
Convenience function which returns ``True`` if the given ``path``
ends with any of the given ``allowedExts``, ``False`` otherwise.
...
...
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