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
Evan Edmond
fslpy
Commits
5cd934ab
Commit
5cd934ab
authored
Jul 07, 2018
by
Paul McCarthy
🚵
Browse files
ENH: New path function to return all files in ditectory
parent
57ed2024
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/utils/path.py
View file @
5cd934ab
...
@@ -13,6 +13,7 @@ paths.
...
@@ -13,6 +13,7 @@ paths.
deepest
deepest
shallowest
shallowest
allFiles
hasExt
hasExt
addExt
addExt
removeExt
removeExt
...
@@ -24,8 +25,9 @@ paths.
...
@@ -24,8 +25,9 @@ paths.
"""
"""
import
glob
import
os.path
as
op
import
os.path
as
op
import
os
import
glob
class
PathError
(
Exception
):
class
PathError
(
Exception
):
...
@@ -78,6 +80,20 @@ def shallowest(path, suffixes):
...
@@ -78,6 +80,20 @@ def shallowest(path, suffixes):
return
None
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
):
def
hasExt
(
path
,
allowedExts
):
"""Convenience function which returns ``True`` if the given ``path``
"""Convenience function which returns ``True`` if the given ``path``
ends with any of the given ``allowedExts``, ``False`` otherwise.
ends with any of the given ``allowedExts``, ``False`` otherwise.
...
...
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