Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-imcflibs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
imcf
python-imcflibs
Commits
cf1e2906
Commit
cf1e2906
authored
6 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add optional parameter "fullpath" to listdir_matching()
parent
0ad2964e
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
src/imcflibs/pathtools.py
+9
-2
9 additions, 2 deletions
src/imcflibs/pathtools.py
with
9 additions
and
2 deletions
src/imcflibs/pathtools.py
+
9
−
2
View file @
cf1e2906
...
...
@@ -76,7 +76,7 @@ def jython_fiji_exists(path):
return
False
def
listdir_matching
(
path
,
suffix
):
def
listdir_matching
(
path
,
suffix
,
fullpath
=
False
):
"""
Get a list of files in a directory matching a given suffix.
Parameters
...
...
@@ -85,6 +85,10 @@ def listdir_matching(path, suffix):
The directory to scan for files.
suffix : str
The suffix to match filenames against.
fullpath : bool, optional
If set to True, the list returned by the function will contain the full
paths to the matching files (the default is False, which will result in
the file names only, without path).
Returns
-------
...
...
@@ -95,7 +99,10 @@ def listdir_matching(path, suffix):
for
candidate
in
os
.
listdir
(
path
):
if
candidate
.
lower
().
endswith
(
suffix
.
lower
()):
# log.debug("Found file %s", candidate)
matching_files
.
append
(
candidate
)
if
fullpath
:
matching_files
.
append
(
os
.
path
.
join
(
path
,
candidate
))
else
:
matching_files
.
append
(
candidate
)
return
matching_files
...
...
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