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
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.
...
@@ -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.
...
...
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